MATLAB Answers


How to detect certain shapes in binary image

Asked by Prashant Kashid on 30 Jan 2013

I have a binary image containing circular shape; I want to detect the circular shape and eliminate rest of the part in an image. Can someone help me with this. The original image is attached below

Expected output image (Edited in MS-Paint)

Thanks for your help in advance!

  1 Comment

If you have the Image Processing Toolbox, I would go through the Demos, specifically the one called "Identifying Round Objects". Another excellent resource is ImageAnalyst's BlobsDemo on the File Exchange ( I would look at both to start with.


No products are associated with this question.

1 Answer

Answer by Image Analyst
on 30 Jan 2013
 Accepted answer

If you look at the circularity, that will tell you what's circular and what's not. Look at my BlobsDemo and see how to measure area and perimeter. Then circularity is just perimeter^2 / (4*pi*area). It's 1 for a circle, and gets bigger the more tortuous the edge shape gets.


on 10 Mar 2013

The link is broken

The link is not broken. I just went there and it works fine for me. Make sure you went to the right person's File Exchange (i.e., mine). Here is the direct link:

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!