7

I have black and white image after binarization. After that I get one object with irregular shape. Link to this image is below. How can I inscribe this object to circle?? or How can I find "center" of this object??

http://s6.ifotos.pl/img/opticdisk_xhnrnwe.png

Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
user1666649
  • 99
  • 1
  • 7

4 Answers4

10

You can find the center of gravity of the pixels using a simple formula which is the sum of the x coordinates divided by the number of points and the sum of the y coordinates divided by the number of points (I mean white points).

Then you can draw a circle centered in the center of gravity with radious half of the maximum distance between points.

Here you have a graphic explanation for this.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
4

This sounds like a smallest circle problem on the set of white pixels. It can be found in linear time in the number of pixels. This is the best you will ever get it your input is just an array of binary pixels.

Ambroz Bizjak
  • 7,809
  • 1
  • 38
  • 49
2

well, you could scan from top down for the top-most white pixel, then from the bottom up for the bottom-most white pixel, same for left and right. that gives you a rectangle. finding the center of the rectangle is easy (e.g. left + ( right - left ) / 2), and that's your circle center. then find the distance to a corner (any will do), and that's your circle radius.

mark
  • 5,269
  • 2
  • 21
  • 34
  • That doesn't product the minimal radius, I think. Consider the result of that algorithm against a filled white circle. – Robᵩ Sep 12 '12 at 19:28
1

I think, that center of the object can be easily found as an arithmetic mean of x and y coordinate. I you want to replace it by a circle, I'd say that the diameter is a double of the mean distance of all points to the center.