Question

I'm looking for a Java library for circle recognition in a supplied bitmap. My Java knowledge is too basic to implement eg. Hough transform efficiently (Java newbie).

Thanks!

Was it helpful?

Solution

You might want to have a look at the implementation in ImageJ, see here.

OTHER TIPS

Sorry for posting this answer many years after the fact, but that question was asked again in 2012 and then closed for being a duplicate. As I said in my answer to that duplicate, I think the answer given here is overkill for such a simple problem, so is my simpler solution:

  • Find all connected green blobs. This is not completely trivial, but not that hard either.
  • For each blob, find the point with the minimum x-coordinate and the one with the maximum x-coordinate and do the same in y. Then you easily get the dimension of the bounding box for the blob. If the x and y dimensions are different, you don't have a circle. However, you should allow for some small differences since drawing a circle with pixels will result in an imperfect circle.
  • Finally, if you have a circle, the center of the bounding box is (approximately) the circle's center and the radius is half the bounding box width. You can draw such a circle and see how many of the green pixels fit in/out of your circle. Again, you must allow for some imperfections.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top