How to subtract a 16 bit image from 8 bit image?
3 views (last 30 days)
Show older comments
How to subtract a 16 bit image from 8 bit image?
4 Comments
Answers (2)
Image Analyst
on 28 Aug 2014
Then, if the 16 bit image takes up the whole range, just read in the 16 bit image and divide by 256. Then subtract the 8 bit image from that, or vice versa. Cast to double if you want to get both positive and negative numbers.
2 Comments
Image Analyst
on 28 Aug 2014
To scale each image to between 0 and 255, try this:
a8 = uint8(255*mat2gray(a));
b8 = uint8(255*mat2gray(b));
differenceImage = b8-a8;
imshow(differenceImage, []);
colormap(gray(256));
Adam
on 28 Aug 2014
a = imread('background_subtract.png');
b = imread('L3_cavity_emmison.png');
a = double( a(:,:,1) ) * 255;
diff = double(b) - a;
That seems to remove the background as expected when I tried it just now. Going the other way down to 8-bit size should work equally well so long as you cast to doubles in the right place and don't do maths as integer before the cast.
0 Comments
See Also
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!