Multiple channel data transform

I’m trying to use the dataset from ISBI challenge, The dataset structure is as follows:

  • Orginal training image, 8-bit grayscale, 512x512x30 pixels
  • Training image labels (0 - membranes, 255 - non-membranes), 8-bit grayscale, 512x512x30 pixels

If I want to do the transforms such as ToTensor and form the dataloader, I encountered a problem.

  • If I treat the training image as 30 different 512x512 grayscale images. If I want to do the ToTensor transform, it doesn’t have channel any more.
  • If I treat the training image as one 512x512x30 image, the ToTensor transform work but I can’t visualize the image anymore

I am wondering if someone has done this before using this dataset.
Thank you for advance

Permute the images to 30x512x512 and now you can treat it as batch of 30 images
then reshape this to 30x1x512x512 so you get channel 1 for all 30 images.

if img is 512x512x30 do following

img = img.permute(2, 0, 1)
img = torch.reshape(img, (30, 1, 512, 512))
1 Like