Ask Your Question

How to detect crescent shape?

asked 2013-05-28 08:39:05 -0500

Jean-François Côté gravatar image

updated 2013-05-29 14:05:08 -0500


How can I detect a crescent shape? I have a binary image where the crescent is in white and the rest is black. There could be some noise and other shape in the image too. I tried with Hough circle but since it's not a complete circle, it detect other circle from the noise instead of the one in the crescent.

I was thinking about using shape comparison with contour but since a crescent is a complex polygon, I'm not sure it will work.

Here is an example: image description

Any ideas on how to approach this problem?


I know how to dilate and erode the image above to get a cleaner image. What I'm interested in is how to detect that it's a crescent.

edit retag flag offensive close merge delete


a general observation, not an answer per se. First (and obviously) mask out the noise and "other" shapes as best you can. Assuming the input data is strictly a "crescent" - that is two circles of differing diameter, joined at two common points - you could find the common points of intersection, then treat the two 'edges' as simple 2-d polynomial curves. Do multiple linear regression on each curve until they " fit " ... if your curves are generic enough, a simple data set would be your baseline to compare against. HTH - HP

Howard gravatar imageHoward ( 2013-05-28 16:51:01 -0500 )edit

Hi Howard. Thanks for the observation. Could you write an answer and go deeper into the explanation about the detection of the 2 edges and how to do a 2D polynomial curve?

Jean-François Côté gravatar imageJean-François Côté ( 2013-05-29 14:10:14 -0500 )edit

2 answers

Sort by » oldest newest most voted

answered 2013-05-29 16:04:04 -0500

Howard gravatar image

updated 2013-05-29 16:06:04 -0500

Hi Jean-Francois. You're welcome - well, again this isn't an answser, but my comment wouldn't fit in a comment :-| Curve fitting is a big subject area which you'd need to research a bit more on your own. Here's some ways to head out: almost any 2 dimensional curve can be generated using polynomial equations. Take for example a basic parabola, y = x^2. Each x value generates a y. This process can be reversed. Any set of points, if they are not too chaotic or random, can be used to 'connect the dots' making a curve. If you fit your image data points (you know now the y, but need to figure out the x ), you can figure out :)) what figure it is. So how to get the image points? If, as Sammy suggests, you get the crescent to stand out enough, you can use the black/white transistion pixels, either to make a filled form (meaning you don't care about whats 'inside' the crescent), or, create a shadow line drawing. (There's also a set of opencv routines that do this, but I don't recall their name - maybe someone can chime in here.) It's like a hit or miss, like the mine sweeper game ... your points will be on one or the other side of the "edge" of the crescent, then you use those points to 'regress' and refine the actual location of the edges. Once you have an x,y matrix of points, you can figure out the polynomial equation. If the curve edge of the crescents are smooth and circle like, then you only need the polynomial for a partial circle, used twice - one for the inner (partial) circle, and one for the outer. The only difference is the radii of the two. - H

edit flag offensive delete link more


thanks, very interesting. I will play with that and let you know.

Jean-François Côté gravatar imageJean-François Côté ( 2013-05-30 07:18:27 -0500 )edit

I have used RANSAC for line fitting with some good results. Thanks for the help!

Jean-François Côté gravatar imageJean-François Côté ( 2013-06-10 08:48:24 -0500 )edit

answered 2013-05-29 00:48:12 -0500

sammy gravatar image

Apply some morphologic operations. Eroding first will remove the spurious pixels, then dilating will fill the cracks in the crescent. Try different kernel sizes.

edit flag offensive delete link more


Hi! Thanks for the answer but like I said in my EDIT, I already know how to manipulate my image to get an almost clear crescent. My problem is how to identify this shape as a crescent.

Jean-François Côté gravatar imageJean-François Côté ( 2013-05-29 14:07:24 -0500 )edit

Question Tools


Asked: 2013-05-28 08:39:05 -0500

Seen: 3,780 times

Last updated: May 29 '13