[Math] How to find/predict the center of a circle while only seeing the outer edge

circlesimage processingtrigonometry

Question

  • What formula would allow me to predict the center of this circle?
  • In addition, what attributes of this image must be detected in order
    to predict the center? I figured understanding the math first will help me determine what parts of the image are relevant, then I can worry about trying to detect those features.

Background

I need to programmatically find the center of a circle while I'm only able to see the outer edge of the circle. I am using matlab for my prototype of this.

This was a class project. We finished the project using matlabs imfindcircles(), but it is to slow. It takes about 2-3 seconds to process a single image. I want to improve my programs speed and hopefully learn some math in the process. The initial assignment was to create a rifle that blind people could use.

Below is a test image I am trying to process:

Ignore the black around the outer edge. I have my camera behind a scope, that is why you can only see a small magnified circle in the middle. The black half circles are actually a target, so there are multiple rings nested inside each other.

Image to process

Also, I initially posted this question on stackoverflow as a programming issue. Feel free to read it for more information about the code behind my imfindcircles() solution and my attempted alternative. However, there are quite a few votes to close it. I'm guessing that is because it is really more of a math problem than a programming problem.

My Solution

I have written a short tutorial about how I solved the problem and posted all my code to github. See the tutorial and code. The tutorial was written in the projects README.md file so it should appear when you view the github page and scroll down a bit. I used the math @vadim123 suggested.

Best Answer

The hard part is finding three points on the circle using the messy data you're given. Assuming you have done this, $A,B,C$, in that order, then:

  1. Let $L_1$ be the line that passes through the midpoint of segment $AB$, and is perpendicular to $AB$.

  2. Let $L_2$ be the line that passes through the midpoint of segment $BC$, and is perpendicular to $BC$.

Then the intersection of $L_1$ and $L_2$ is the center of the circle.

If $A,B,C$ are far away that will make the error smaller. Hence I advocate doing this process several times for different choices of $A,B,C$, to get several "centers" and averaging.

Related Question