tags:

views:

325

answers:

4

Hello

I have an array of points. I want to know if this array of point represents a circle, a square or a triangle.

Where should i begin? (i use C#)

Thanks Jon

A: 

I'm going to take a wild stab and say if you have 3 points the shape represents a triangle, 4 points is some kind of quadrilateral, any more than that is a circle.

Perhaps there's more information to your problem you could provide.

eduffy
oh yes. I have more 500 points and need to figure out if i have lines or a circle.
A: 

imagine it is each of these one-by-one and try to fit each of these shapes on the data.. for a square, you could find the four extreme points, and try charting out a square that goes through all of them..
Once you have got a shape in place.. you could measure the distance between each of the points and the part of the shape that is nearest to it.. then square these distances and add them up.. the shape which has the smallest sum-of-squares is probably your best bet

adi92
A: 

Use the Hough Transform.

teabot
+2  A: 

Depending on your problem, a good approach for this problem may be to use the Hough transform and all its derived algorithm

It consists in a transformation of the image space to an other space where the coordinate represents the objects parameters (angle and initial point for a line, coordinates of the center and radius for a circle)

The algorithm transforms each point of your array of points in points in the other space. Then you have to search in the new space if some points are prevailing. From these points, you will get the parameters of your object.

Of course, you need to do it once to recognize the lines (so you will know how many lines are in your bitmap and where they are) and to it to recognize the circles (it is not exactly the same algorithm)

You may have a look to this lecture (for Hough Circle Transform), but you could easily find the algorithm for line

EDIT: you can also have a look to these answers

Shape recognition algorithm(s)

Detecting an object on the image based on geometrical form

ThibThib
ok, i want to try. do you know a C#implementation ?
No,sorryBut as far as I remember, the algorithm was quite simple (but it still requires some work):a) you transform your image in a new image with the mathematical transform (just need to apply the formulae)b) you need to look for the most significant points (i.e. the points with a value greater than a given threshold)c) you apply the inverse transform (again with the formulae) and you have the coordinate of your lines/circlesd) from the number of lines, you can know if it's a triangle or a square (supposing that you have only 1 object to recognize)
ThibThib
Will it work if the circle is not perfect ?
yesThat's the good thing with the Hough transform.For example, if the circle is not perfect (if it's fuzzy, for example), you will not have one point of the new image (in the transformed space) with a very high value, but you will have a few points, all neighbors, with a high valueTell me if I am not clear (but it's quite well explained the lecture [here](http://www.cis.rit.edu/class/simg782/lectures/lecture%5F10/lec782%5F05%5F10.pdf) )
ThibThib