MATLAB: Can someone explain to me exactly how this works

binaryfunctionimagetransform

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

Best 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.
Related Question