Regionprops与PodczeckShapes/DIPimage圆度问题-Matlab [英] Regionprops vs. PodczeckShapes/DIPimage Circularity question - Matlab

查看:209
本文介绍了Regionprops与PodczeckShapes/DIPimage圆度问题-Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释一下为什么Matlab中的圆度"是通过(4 * Area * pi)/(Perimeter ^ 2)来计算的,而在Podczeck形状中它是Area/(Pi/4 * sp ^ 2) https://qiftp.tudelft.nl/dipref/FeatureShape.html )?还是只是简单地定义不同?

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?

我试图在Matlab中编写Podczeck Shape圆度代码,我认为"MaxFeretDiameter"垂直于"MinFeretDiameter",对吗?

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

代码:

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

推荐答案

regionprops中的圆度"度量定义为

The 'Circularity' measure in regionprops is defined as

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

对于一个圆圈,其中Area = π r²Perimeter = 2 π r的位置是:

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的圆度是一种不同的度量.定义为

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

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

在链接的文档中,其将Height称为sp,并将其定义为垂直于s的雪貂直径",并将s定义为最短费雷特直径".因此,sp是最小边界框的两侧中最大的一个.

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.

对于一个圆,最小边界框的Height等于直径.我们再次替换:

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

对于任何其他形状,高度将相对较大,因此Podczeck圆度度量将较小.

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

请注意,最大和最小费雷特直径不一定是垂直的.一个简单的例子是正方形:最大直径是正方形的对角线;最大直径是正方形的对角线.最小直径是高度或宽度;这两个彼此成45度角. Podczeck圆形度度量使用垂直于最小投影的投影大小,对于正方形,该大小等于最小投影且小于最大投影.最小的投影及其垂直投影形成最小的边界矩形(通常,尽管显然不是必须这样吗?).但是,regionprops具有轴对齐的'BoundingBox',因此不适用.我不知道如何从regionprops中获取所需的值.

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.

您必须遵循的方法是将regionprops的"PixelList"输出与"MinFeretAngle"一起使用. "PixelList"是属于对象的像素坐标的列表.您将根据"MinFeretAngle"旋转这些坐标,以使与轴对齐的边界矩形现在与最小边界矩形相对应.然后,您可以通过获取旋转坐标的最小值和最大值来确定框的大小.

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.

这篇关于Regionprops与PodczeckShapes/DIPimage圆度问题-Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆