フィルターのクリア

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.
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 件のコメント
Image Analyst
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.
John Snow
John Snow 2013 年 10 月 20 日
Alright that makes sense.Thank you for your help I will confirm with teacher next week

サインインしてコメントする。

その他の回答 (1 件)

Dexian
Dexian 2014 年 11 月 25 日
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!

Translated by