Subtracting Image from it modified self (by setting zero least significant bit of pixels)

4 views (last 30 days)
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.
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);

Accepted Answer

Image Analyst
Image Analyst on 19 Oct 2013
Edited: Image Analyst on 19 Oct 2013
% 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 Comments
Image Analyst
Image Analyst on 20 Oct 2013
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.

Sign in to comment.

More Answers (1)

Dexian
Dexian on 25 Nov 2014
How to set MSB=0?What the code in MATLAB?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!