Circularity of an image
显示 更早的评论

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???
采纳的回答
更多回答(1 个)
Image Analyst
2014-12-3
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 个评论
Image Analyst
2014-12-3
By the way, you shouldn't call regionprops() twice. Just get everything all in one shot:
measurements = regionprops(logical(BW), 'Area', 'Perimeter');
purti choudhary
2014-12-3
Image Analyst
2014-12-3
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
2014-12-3
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
2014-12-4
Image Analyst
2014-12-4
Where's your script so I can try it?
purti choudhary
2014-12-5
purti choudhary
2014-12-5
Image Analyst
2014-12-5
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
2014-12-6
Image Analyst
2014-12-6
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);
类别
在 帮助中心 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

