Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing square objects

enter image description here

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?

like image 967
ffttyy Avatar asked Jul 17 '14 11:07

ffttyy


2 Answers

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.

like image 105
Shai Avatar answered Oct 06 '22 05:10

Shai


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

like image 34
Emilien Avatar answered Oct 06 '22 05:10

Emilien