0

I'm implementing a virtual world for an autonomous machine. The machine has to be able to detect the center coordinates of different colored ellipses in the screen. The image is given to the machine in an width x height array, with ints for the colors (for example white = 0, red = 8, blue = 9 etc).

Example of an input image

Also if the ellipses are behind eachother you do not have to calculate the excact middle point. I was thinking of some sort of sweepline algorithm? Which will keep the first time it sees a color and when it exits it gets the average between those two? and then do it horizontally and vertically. Then you have the middle coordinates. Would this be efficient? Any other ideas? Thanks in advance

Enforcerke
  • 257
  • 1
  • 3
  • 10
  • Yes they have foci, but they can also have a center or centroid. It's midway between the foci. – JerryM Nov 14 '16 at 17:43
  • I think you mean an [ellipse](https://en.wikipedia.org/wiki/Ellipse), rather than an [oval](https://en.wikipedia.org/wiki/Oval). – Jim Mischel Nov 14 '16 at 17:43
  • Your algorithm will have a problem if two or more shapes are of the same color. And as you have already noted, it won't find the precise center if an ellipse is partially covered. It should be fairly fast however. – JerryM Nov 14 '16 at 17:57
  • @JerryM the colors will always be different. and yes as center i mean for x-coordiante the middle between the leftmost and rightmost pixel, and for y-coordinate the middle between the topmost and bottommost pixel. I've seen someone trying to implement te same using openCV or something – Enforcerke Nov 14 '16 at 18:04
  • @JimMischel And indeed i meen an ellipse, sorry – Enforcerke Nov 14 '16 at 18:04
  • @Enforcerke Your algorithm is simple and seems pretty efficient but it won't work if a (left | right | top | bottom)-most ellipse point is hidden by another ellipse. – Patrice Gahide Nov 14 '16 at 18:13
  • @PatriceGahide yes but that's no problem, the machine will go towards the closest ellipse, and then the others might be visible – Enforcerke Nov 14 '16 at 18:26
  • take a look at this: [Algorithms: Ellipse matching](http://stackoverflow.com/a/36054594/2521214) especially the geometry part. So just segmentate image to find ellipse region, then compute semiaxis points ... detect if valid or not should be perpendicular (or ignore if not for overlapped ellipses) and compute center points ... Handle square aspect ratio bbox as circle ... – Spektre Nov 15 '16 at 07:18

0 Answers0