How to handle normalizing image with blank pixels in a Unet for image segmentation?

Hello,
I am doing my first unguided project and just need a little advice. I’ve done a lot of reading and some online courses, but have not been able to find information on how to handle blank space. I do not want to tell exactly what I am doing, but here is some information that I can give:

-I have hundreds of images that are inconsistent shapes (curved edges, different sizes) and cropping part of the image is not an option. I put these images in a rectangular matrix so all my data is the same shape, but because of that I have a bunch of blank pixels.

-There is only 1 feature/class I am trying to model, but there is a large class imbalance in terms of the number of pixels(<1:100), so I am using a binaryfocalloss function. The range of values in the actual images is about 100-400. So I could set the blank pixels to zero then normalize or 100 then normalize. I am not sure it matters.

-For the training data, the features are determined by taking the difference in the values of 2 of the image channels and manually identifying the pattern of that feature.

Bonus question: If my channels have different value ranges (like 100-150 vs 300-400) should I normalize each channel by the range of that channel or the range of all the channels? I think the latter?

Thanks for your help!

If the ranges are “similar” it porobably doesn’t matter. But if the difference is large, I’d normalize by the channel’s individual range.

What?

It sounds like you just need a binary image for the labels, and a logit-image for the predictions.

Thank you for your reply.

To rephrase, what value should I give the blank pixels? Does it matter?

So the “on” pixels have a range of 100-400, okay, I think I’m with you now.

zero then normalize or 100 then normalize

One advantage to using 0 instead of 100, is that it’s easy to tell that zero is not in that valid range.
If you set the background pixels to 100, when you see a 100, it’s never clear if that’s a valid 100 or a background 100.

Another option here would be to add a valid [0,1] channel to the images so your network can see which pixels are valid, then the fill value would matter less.

1 Like

Yes! sorry for the confusion.

Both of those ideas make sense. Thank you for your help!!

Hi Dear!
I read you answer.
I know you can help me to solve my problem.
I predicted an image using Unet the image show blank in yellow colour. I multiply 255 to change pixel values. Now the pixel values are from 180 to 255 with single channel.
Now I want to convert the image into black and white to draw contour on original image.

How I can convert the image into black and white(mask).