Fast Java library for circle recognition [closed]

左心房为你撑大大i 提交于 2019-11-29 12:04:21

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

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!