Can someone explain to me exactly how this works?

J=I(:,:,1)>160;
I know it converts an image to binary, but how?
matlab newbie

 Accepted Answer

It converts the RED channel (assuming an RGB image) into a binary image, based on the red (first) channel. Or if the image is an LAB image, it might be working on the L* channel. You have not said how the image is stored.
In any case, it converts anything into white that is above 160 in that channel. All other pixels go to black. This happens because inequality tests return a 0 or 1, depending on the truth of the test as done.

1 Comment

That's exactly what it does. Converting everything that is above 160 into white and the rest to black. Thank you!

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!