Search code examples
matlabpixelarea

Calculating average intensity of area with matlab regionprops


I have a grayscaled picture, where there are some objects with different shapes. Also i have binary image of this grayscaled picture.

With MajorAxesLength and MinorAxisLength ratio (from regionprops) i can identify each of them, but how i can calculate average intensity each of that objects?

And is it possible to calculate average intensity of lines, that gives MinorAxisLength and MajorAxisLength?


Solution

  • add to regionprops the 'PixelIdxList' handle. Then you can do the following:

    s = regionprops(BW,'PixelIdxList');
    for n=1:numel(s)
         meanI(n)=mean(image(s(n).PixelIdxList));
    end
    

    this assumes that BW is the binary image and image is the grayscale one.