MATLAB: Image thresholding using min and max pixel intensity values

image processingImage Processing Toolboxthresholding

Hi,
I'm trying to create a mask based on a minimum and maximum intensity value. All the examples I find are basically thresholding the image from a fixed value (say, 176) to 255. What I need to do is to mask pixels between 165 and 166 to find ROIs on the image.
Thanks!

Best Answer

Try this:
mask = grayImage >= 165 & grayImage <= 166 % Mask of only pixels with GLs of 165 and 166
grayImage(~mask) = 0; % blacken outside the mask.