Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Subtracting arrays in grayscale

Hi,

 

Im doing a project at college, ESPI. What i'm trying to do is subtract two arrays but when I subtract them instead of getting negative values say, 10-11=-1, I get 255. Has anybody got any ideas on how to solve this? Also how do I make it so values that go below 0 will just stay 0.

 

Colmsxv

0 Kudos
Message 1 of 3
(2,808 Views)

If you subtract images from each other, they should be limited at the extreme values without wrapping.  This means all negative numbers should be rounded to zero.

 

If you convert the images to arrays, then subtracting images will wrap the values.  -1 wraps to 255, -2 wraps to 254, etc.

 

If you want to have negative values, convert your images to I16 before subtracting.

 

There is also an option to do absolute subtraction, where the absolute value of the difference is retained.  -1 becomes 1, -2 becomes 2, etc.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 3
(2,789 Views)

Thanks Bruce, that worked!

 

Colmsxv

0 Kudos
Message 3 of 3
(2,710 Views)