blackbug
blackbug

Reputation: 1128

Image Mean subtraction

I am confused whether the image mean subtraction is helpful in my use case.

I am training SegNet network with road images, and I am subtracting the mean during the training.

When I compare the images before and after the mean subtraction, the image without mean subtraction appears to have more features and detailed pixel information.

I understand the importance of mean subtraction as it reduce the effect of varied illumination, and also helps in the gradient calculation during the training process. But, doesnt it mean that I loose some important information. I am attachting images for reference.

Original

Original image

With mean subtraction

Mean subtraction

Looking the pictures above, I have an assumption that image without mean subtraction can learn more features especially about the Cars ( which is very imp here ). The image with mean subtraction is mostly dark around the Cars.

An explaination or link to some source which might explain this, will be greatly appreciated. Thank you.

Upvotes: 0

Views: 1799

Answers (1)

Cris Luengo
Cris Luengo

Reputation: 60554

There are two things to consider here:

  1. The pixel values themselves
  2. How those pixel values are shown on your screen

If your images is of an unsigned integer type (say uint8), and you subtract the mean without casting the image to a different type, you will likely destroy image information. For example, if your image contains pixel values

204 208 100  75  86

and the mean is 100.3, the uint8 result of subtracting that mean is either

104 108   0   0   0    -- saturated subtraction

or

104 108   0 231 242    -- C-style subtraction

depending on if you use saturated subtraction or C-style arithmetic. In both cases the image no longer contains the same information it did before.

Correct of course is to use floating-point values:

103.7  107.7   -0.3  -25.3  -14.3    -- floating-point subtraction

In this case, the data still contains exactly the same information, only now it is zero-mean.

Now, how to display this zero-mean image to the screen? You can either map every value <0 to 0, and every value >255 to 255, so that values outside of the valid range [0,255] are saturated; or you can find the minimum and maximum values in your data, linearly map the pixel values to the valid range. In the first case it will look like you corrupted the image (as in your example), in the second case it will look like not much changed in the image. That is to say, there is no way of showing the image on screen and still see the effect of mean subtraction.

Upvotes: 4

Related Questions