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

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);

 채택된 답변

Image Analyst
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

grayImage/grayImage2 look like figures a/b from the book however diffImage does not look like figure c but instead it looks like this
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.
Alright that makes sense.Thank you for your help I will confirm with teacher next week

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

질문:

2013년 10월 19일

답변:

2014년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by