0

Im trying to learn a segmentation network using CNN, my network is producing very poor results. I looked at the images and I'm wondering if this is the reason. My input images are stack of images in a .tif file. In Windows image viewer below is what I get: enter image description here

I am trying to detect and segment the bright spots shown above But when I open the same in Matlab using imshow() I get

enter image description here

All the information is basically lost. However when I use imagesc() I get the following:

enter image description here

Which is much better, but why are my images not working with my network? I am getting very very unpredictable losses and accuracy even with tried and tested networks.

Is it because my image is reading in the version shown in imshow()?

Community
  • 1
  • 1
StuckInPhDNoMore
  • 2,507
  • 4
  • 41
  • 73

2 Answers2

2

In MATLAB, the following convention is used for images:

  • uint8: pixels are in the range [0,255].

  • double: pixels are in the range [0,1].

When using imshow on a double image, values between 0 and 1 are mapped to a color scale (typically black to white). Any value above 1 is also mapped to white. This is what is happening to you: most of your pixels are shown as white.

It is likely that the CNN you are using makes the same assumptions and therefore clips your data.

The solution is to properly scale your images when you read them in. See for example im2double.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
1

Neither imshow nor imagesc is designed to handle tiff stacks. They are for viewing, not reading image data. You may see a warning along the lines of the following, also:

"Can only display one frame from this multiframe file"

You can use imread to read in each of the frames in the file separately, as per this answer, or tiff which is a Matlab gateway to LibTiff library routines and provides more detailed control of how you read in your images if imread doesn't hack it.

nkjt
  • 7,825
  • 9
  • 22
  • 28
  • Ive read in my ``tiff`` files exactly as has been explained in the answer you linked. The output shown here is for ``imageStack(:,:,7)``. Im trying to understand why my network is giving poor results and must be something to do with my inputs, hence the question here. How is the raw data processed by the CNN? is it according to what I see in ``imshow()``? – StuckInPhDNoMore Dec 16 '18 at 13:35
  • It is `Tiff`, not `tiff`. MATLAB is case sensitive. – Cris Luengo Dec 16 '18 at 15:37