Needing to take the difference of the two images to get part C. I feel book maybe wrong in way it describes how to do it.

1 view (last 30 days)
I have parts A and B working properly, verified by setting the 8th bit to 0 and returning a almost completely black image which would be MSB. I tried several ways to finding the difference between the two and always get a completely black and white grainy image. Please help I think the book is wrong because subtracting the two images just gives me ones and zeros when part C has grey elements.
  1 Comment
Walter Roberson
Walter Roberson on 19 Feb 2019
You are overwriting all of B in each iteration of the for i , for j loops.
Each iteration of for i, for j, you are setting bit #1 for all of y.

Sign in to comment.

Answers (1)

Ankit Dutta
Ankit Dutta on 21 Feb 2019
Setting the LSB to zero i.e.
bitset(y, 1, 0)
will simply round every pixel down to the nearest multiple of 2 (i.e. 2^0 which is 1 to 0). 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. However, I am not sure using which function they were able to get an image that looks grayscale as in the book.

Community Treasure Hunt

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

Start Hunting!