Circularity of an image
Show older comments

I am trying to find circularity for my shape feature requirement in MRI image classification. I have used the matlab function REGIONPROPS to find area and perimeter and the circularity formula: 4*pi*area/(perimeter)^2.
My problem is i am getting perimeter as 0 value for many regions in an image. Then circularity will become infinite. I have attached a screenshot of perimeter values i am getting for a single image. Someone please suggest me how to calculate circularity in such case???
Accepted Answer
More Answers (1)
Image Analyst
on 3 Dec 2014
What is the area of the blobs that have zero perimeter? Is it 1? Like 1 pixel? If so, maybe you just don't want to consider those. You can use bwareaopen() to filter out tiny things. By the way, I use the inverse of your equation.
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
Of course zero perimeter is not a problem there.
11 Comments
Image Analyst
on 3 Dec 2014
By the way, you shouldn't call regionprops() twice. Just get everything all in one shot:
measurements = regionprops(logical(BW), 'Area', 'Perimeter');
purti choudhary
on 3 Dec 2014
Image Analyst
on 3 Dec 2014
OK, so like I thought, the solution is to call bwareaopen(binaryImage, 1) to get rid of pixels that are of size 1 or less. Personally I'd use a min blob size of a few hundred.
Image Analyst
on 3 Dec 2014
Attach your script if you want me to try it. Also, im2bw() is usually not good at picking thresholds in my experience. Anyway, you probably need to call imfill(binaryImage, 'holes') after you call im2bw().
purti choudhary
on 4 Dec 2014
Image Analyst
on 4 Dec 2014
Where's your script so I can try it?
purti choudhary
on 5 Dec 2014
purti choudhary
on 5 Dec 2014
Image Analyst
on 5 Dec 2014
That's a poor decision.
And why didn't you take my advice on how to calculate things:
measurements = regionprops(labeledImage, 'Area', 'Perimeter');
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
purti choudhary
on 6 Dec 2014
Image Analyst
on 6 Dec 2014
It's an integer valued image. You can display it as a grayscale image if you want
imshow(labeledImage, []);
Or you can pseudocolor the blobs and show that:
% Assign labeled blobs rainbow colors.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
imshow(coloredLabels);
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
