删除方形对象 [英] Removing square objects
问题描述
>
图像包括圆形,椭圆形,正方形的对象和像这样的东西。我想得到只有循环对象。我应用了一个过滤器,通过使用对象的稠度和偏心水平,但我不能删除方形对象。
I have the image includes circular, elipsoidal, square objects and somethings like these. I want to get only circual objects. I applyed a filter by using Solidity and Enccentricity levels of objets but I could not remove square objects. Square objects which have not sharp corners have nearly same Solidity and Enccentricity level with circular objects.
我的问题是,是否有任何其他参数或方法来检测方形对象? / p>
My question is that is there any other parameter or way to detect square objects?
推荐答案
您可以使用以下公式比较面具的面积与其周长:
You can compare the area of the mask to its perimeter using the following formula
ratio = 4 * pi * Area / ( Perimeter^2 )
对于圆,这个比率应该非常接近一个,对于其他形状,它应该显着降低。
参见
For circles this ration should be very close to one, for other shapes it should be significantly lower.
See this tutorial for an example.
这个公式背后的理由:圆圈在周长上是最佳的 - 给定周长的面积比 - 最大面积。给定周长,您可以使用估计的 R
估计 Perimeter = 2 * pi * R
可以使用 eqArea = pi * R ^ 2
计算等效圆面积。现在你只需要检查形状的实际面积和计算的等效面积之间的比率。
The rationale behind this formula: circles are optimal in their perimeter-area ratio - max area for given perimeter. Given Perimeter, you can estimate radius of equivalent circle by Perimeter = 2*pi*R
, using this estimated R
you can compute the "equivalent circle area" using eqArea = pi*R^2
. Now you only need to check the ratio between the actual area of the shape and the "equivalent area" computed.
注意:因为 code>和
周界
中的对象基于像素级离散估计,这些估计可能是相当粗糙的,特别是对于小形状。如果您注意到量化/离散错误,请考虑使用更高分辨率的掩码。
Note: since Area
and Perimeter
of objects in mask are estimated based on the pixel-level discretization these estimates may be quite crude especially for small shapes. Consider working with higher resolution masks if you notice quantization/discretization errors.
这篇关于删除方形对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!