Subtracting Image from it modified self (by setting zero least significant bit of pixels)
4 次查看(过去 30 天)
显示 更早的评论
We have a homework of which we need to set the least significant bit of every pixel to zero and then subtract the new image from the original. Here is an example of what I want to do directly from the book.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150900/image.jpeg)
The code I am trying to use cannot produce image (C) instead it produces a black image.This is my attempt: could anybody point out what im doing wrong please?
raw = imgetfile;
A = imread (raw);
for k = 0:7
B = bitset(A, 8-k, 0);
end
C = imsubtract (A,B);
0 个评论
采纳的回答
Image Analyst
2013-10-19
编辑:Image Analyst
2013-10-19
% Set LSB = 0
grayImage2 = grayImage - rem(grayImage, 2);
% Subtract from original
diffImage= double(grayImage) - double(grayImage2);
% Display it.
imshow(diffImage, []);
Note that the image referred to in (c) is simply rem(grayImage, 2) and is just 0's and 1's.
3 个评论
Image Analyst
2013-10-20
Setting the LSB to zero will simply round every pixel down to the nearest multiple of 2. For example 131 will go to 130. But if the pixel already had an LSB of 0, it's already an even number and won't change, so if it's 140 it will stay 140. So when you subtract the original you will get 1's where there were odd valued pixels and zero where the pixels were even. Thus the image is just 1's and 0's and is the same as the rem() image. I don't understand how they could get an image that sort of looks grayscale.
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!