Regionprops vs. PodczeckShapes/DIPimage Circularity question - Matlab

自作多情 提交于 2020-07-09 08:29:31

问题


Can someone please explain me why the 'Circularity' in Matlab is calculated by (4*Area*pi)/(Perimeter^2) while in Podczeck Shape it is Area/(Pi/4*sp^2) https://qiftp.tudelft.nl/dipref/FeatureShape.html)? Or is it just simply defined differently?

I tried to write a Podczeck Shape circularity code in Matlab and I assume that ‘MaxFeretDiameter’ is perpendicular to ‘MinFeretDiameter’, am I correct?

Code:

clc;
clear all;
close all;

Pi=pi;
Image = rgb2gray(imread('pillsetc.png'));

BW = imbinarize(Image);
BW = imfill(BW,'holes');
BW = bwareaopen(BW, 100);
imshow(BW);

[B,L] = bwboundaries(BW,'noholes');

i=2; 
stat = regionprops(BW, 'Area', 'Circularity', 'MaxFeretProperties', 'MinFeretProperties');
OArea = stat(i).Area;
OMaxFeretProperties = stat(i).MaxFeretDiameter; 
OMinFeretProperties = stat(i).MinFeretDiameter;   
OCircularityPodzeck = OArea/(Pi/4 * (OMaxFeretProperties^2))
OCircularityMatlab = stat(i).Circularity

回答1:


The 'Circularity' measure in regionprops is defined as

Circularity = (4 Area π)/(Perimeter²)

For a circle, where Area = π r² and Perimeter = 2 π r, this comes out to:

Circularity = (4 π r² π)/((2 π r)²) = (4 π² r²)/(4 π² r²) = 1

For any other shape, the perimeter will be relatively longer (this is a characteristic of the circle!), and so the 'Circularity' measure will be smaller.

Podczeck's Circularity is a different measure. It is defined as

Podczeck Circularity = Area/(π/4 Height²)

In the documentation you link it refers to Height as sp, and defines it as "Feret diameter perpendicular to s", and defines s as "the shortest Feret diameter". Thus, sp is the largest of the two sides of the minimal bounding box.

For a circle, the minimal bounding box has Height equal to the diameter. We substitute again:

Podczeck Circularity = (π r²)/(π/4 (2 r)²) = (π r²)/(π/4 4 r²) = 1

For any other shape, the height will be relatively larger, and so the Podczeck Circularity measure will be smaller.


Do note that the max and min Feret diameters are not necessarily perpendicular. A simple example is a square: the largest diameter is the diagonal of the square; the smallest diameter is the height or width; these two are at 45 degrees from each other. The Podczeck Circularity measure uses the size of the project perpendicular to the smallest projection, which for a square is equal to the smallest projection, and smaller than the largest projection. The smallest projection and its perpendicular projection form the minimal bounding rectangle (typically, though apparently this is not necessarily the case?). However, regionprops has a 'BoundingBox' that is axis-aligned, and therefore not suitable. I don't know how to get the required value out of regionprops.

The approach you would have to follow is to use the 'PixelList' output of regionprops, together with the 'MinFeretAngle'. 'PixelList' is a list of pixel coordinates that belong to the object. You would rotate these coordinates according to 'MinFeretAngle', such that the axis-aligned bounding rectangle now corresponds to the minimal bounding rectangle. You can then determine the size of the box by taking the minimum and maximum values of the rotated coordinates.



来源:https://stackoverflow.com/questions/61233636/regionprops-vs-podczeckshapes-dipimage-circularity-question-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!