# 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

% grayImage = imread('cameraman.tif');someThreshold = 190;binaryImage = grayImage < someThreshold;labeledImage = bwlabel(binaryImage);measurements = regionprops(labeledImage, grayImage, 'MaxIntensity');maxIntensities = [measurements.MaxIntensity]
mask = grayImage < someThreshold;maxAbove = max(grayImage(mask))maxBelow = max(grayImage(~mask))