tags:

views:

72

answers:

2

Hi,

I want to subtract two images. My problem ist that the cvSub()-funtion saturates. What I want to do is:

1) Convert the original images to grayscale.

2) Take the grayscale-images (values from 0-255).

3) Subtract the images (values from -255 to 255) -> problem of rescaling using cvSub().

4) Rescale by multiplying with 0.5 and adding 128.

I thought of changing the gray-scale images from 8bit to 16bit, but then everything got worse and it became many lines of code and in the end it didn't work out.

Thanks for any help.

A: 

You need to convert from 8bit to 16bit. Then add 255 to the first image, then subtract the second image from it. Then divide by two and convert back to 8bit.

Tell me how this goes, it should work.

Alexander Rafferty
+3  A: 
Frank Bollack
Thanks for the simple solution!!! It worked out! - Good idea to do the scaling first and then subtract the pictures.
supergranu
The only problem is that one looses information. In that case it's better to choose the version of Alexander Rafferty.
supergranu
Can you tell me where do you think, you loose information? Do you mean precision?
Frank Bollack
I think it's an 8bit image. If I multiply by 0.5 I can only use 128 values to store the image's information. 256 values are reduced to 128. I will loose resolution of the original image. - Tell me if this thought is wrong.
supergranu
Thanks for the answer!
supergranu