Page 1 of 1

Subtract images - Bug or incompetence

Posted: 2008-10-08T00:47:18-07:00
by Hasek1984
Hello this is a short question regarding pixelcalculation in c/c++.

darkpic.composite(brightpic,0,0,MinusCompositeOp);

As you can see, I use the MinusCompositeOp operation, but tried also DifferenceOp and SubtractOp.
Usually it works but some pixels are calculated wrong.
Image A (value 2038) - Image B (value 2004) should be value 34!
But in the resulting Image there is the wrong value 65525. Bug?
Both images are 16-bit tif and I work with Windows Vista(64).
By the way...is there a possibility to avoid updating the current image (darkpic) but the other (brightpic)?.
Thank you in advance.

Re: Subtract images - Bug or incompetence

Posted: 2008-10-08T09:49:51-07:00
by el_supremo
By the way...is there a possibility to avoid updating the current image (darkpic) but the other (brightpic)?.
Wouldn't this work?

Code: Select all

brightpic.composite(darkpic,0,0,MinusCompositeOp);
Pete

Re: Subtract images - Bug or incompetence

Posted: 2008-10-08T23:59:40-07:00
by anthony
As hinted by el_supremo, you probably have the images the wrong way around.

Re: Subtract images - Bug or incompetence

Posted: 2008-10-09T00:24:36-07:00
by Hasek1984
Thank you for your replies.

My intention is to subtract a dark picture from a bright one (same object) due to remove the "dark-current" artefacts.

If I change the way of subtraction then the result is a complete dark picture.
Because dark picture - bright picture = dark picture (overflow cropped to zero).


Am I wrong with my assumption?

Re: Subtract images - Bug or incompetence

Posted: 2008-10-09T17:35:14-07:00
by anthony
You are wrong in your ordering.

You were subtracting the bright picture from the dark picture.
"Subtract" is a 'modulus' subtraction. If you used minus, you would have gotten all zeros.

Look at http://www.imagemagick.org/Usage/compose/tables/
and especially the gradient compose test results at the bottom.

I just updated this to include the Add and Subtract modulus compositions, which will appear in a day or so.