Removing square objects

微笑、不失礼 提交于 2019-12-17 16:31:38

问题


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.

My question is that is there any other parameter or way to detect square objects?


回答1:


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.

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.

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.




回答2:


There exists a Hough transform (imfindcircles) in order to find circles within an image which is what you needed in the first place.



来源:https://stackoverflow.com/questions/24802059/removing-square-objects

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