[Solved] How to reduce blob using aspect ratio?


you can use regionprops for that , for example:

 s=regionprops(bw,'BoundingBox','PixelIdxList');

where bw is your binary image.

The output of s.BoundingBox is a [x,y,width,height] vector
you can loop over s

for i=1:numel(s)
    ar(i) = s(i).BoundingBox(3)/s(i).BoundingBox(4)          
end

and see if the width/height ratio ar (or whatever you define aspect ratio) is approx above 1 or not (because of noise I’d take a value of ar>1.2) . Then for that i use you can use the pixel list s(i).PixelIdxList

 bw(s(ar>1.2).PixelIdxList)=0; 

to zero these intensities…

2

solved How to reduce blob using aspect ratio?