MATLAB: How to find maximum pixel intensity of the two regions obtained after finding the threshold of the image

atmospheric light estimationdigital image processinggray scaleImage Processing Toolboxpixelsregionsthreshold

We are working on DIP project where we found out the threshold of the gray scale image. Now we have to * find the maximum intensity of the two regions that we got, one region whose pixels are less than the threshold and the other whose pixels are greater than it. * PS. We are not converting the image into binary image after finding the threshold. We just have to separate pixels in two regions and find the maximum intensity in each region bold

Best Answer

  • Try something like this
    % grayImage = imread('cameraman.tif');
    someThreshold = 190;
    binaryImage = grayImage < someThreshold;
    labeledImage = bwlabel(binaryImage);
    measurements = regionprops(labeledImage, grayImage, 'MaxIntensity');
    maxIntensities = [measurements.MaxIntensity]
    That gives a blob-by-blob accounting of the max. If you just want the max of the image above and below the threshold, you can simply do this
    mask = grayImage < someThreshold;
    maxAbove = max(grayImage(mask))
    maxBelow = max(grayImage(~mask))