How to replace certain gray level values in image to find information loss in both?

2 views (last 30 days)
h612 on 2 Apr 2016
Commented: h612 on 4 Apr 2016
I'm finding information loss in Img1 and its replica Img2 when only a certain gray level values are allowed.
where img2 must not have gray values other than eg.
only_include=[20, 30, 50].
However my result is all zeros image of img2. Can anyone assist me..

Accepted Answer

Walter Roberson
Walter Roberson on 2 Apr 2016
mask = ismember(img1, only_include);
img2 = img1;
img2(~mask) = 0;
h612 on 4 Apr 2016
Well this did work. Thank you. I tried using the class type only at first..but it didn't work. Using for loop did. Wondering what is wrong in the previously suggested method.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!