Removing square objects
Asked Answered
F

2

5

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?

Friedafriedberg answered 17/7, 2014 at 11:15 Comment(4)
can you please post an example image?Intoxicative
I added a sample imageFriedafriedberg
Do you want to keep the ellipses?Carlyle
I do not want to keep all of them. I just keep the ellipses whose shape is close to circular. For example eccentricity<0.90Friedafriedberg
I
11

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.

Intoxicative answered 17/7, 2014 at 11:44 Comment(6)
I saw this formula in a mathworks tutorial not long ago, but for some reason I cannot find it now... If anyone can find this tutorial - a link would be highly appreciated!Intoxicative
I think you meant this example: Identifying Round Objects (see step 5)Cyprinoid
@Cyprinoid YES!!!! THank you! I was googling for "circles" never thought to try "round" :OIntoxicative
I remembered this formula too, but I also recall it using regionprops so it was easier to find from there :)Cyprinoid
@Cyprinoid the tutorial does not use the 'Perimeter' property, but rather computes it from the boundary mask... The method there might be more robust than the method used by regionprops.Intoxicative
yes I think regionprops(..,'Perimeter') returns the length in pixel units.Cyprinoid
L
2

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

Links answered 17/7, 2014 at 11:30 Comment(1)
actually this will perform badly on the above image, as the square will be fitted a circle too. Here is a friendly GUI app to experiment with imfindcircles: mathworks.com/matlabcentral/fileexchange/34365-findcirclesguiCyprinoid

© 2022 - 2024 — McMap. All rights reserved.