I have an image of a circle, I want to find the circle but not using hough circles.
I found a way, linked here.
But I can't find the transition coordinates from white to black as I don't know the x and y coordinates in the circle. What other methods are there, or how can I make that approach work?
This is my test image:
One possible approach is to first
threshold
the image to get rid of some of the noise around the circle. Then you can extract the edge of the circle usingCanny
edge detection. Finally,findNonZero
to get a list of pixel coordinates.I first did a quick prototype with Python:
And then ported it to C++, adding some extra code to save all the intermediate images and plot the found pixels.
Output of
threshold
:Output of
Canny
:Re-plotted pixels:
Another approach (that is useful for more than just circles) would be to find the image contours and do image moment analysis on the circle to find it's centre of mass:
I recommend learning them if you'e going to move forward with image processing. They're pretty helpful approaches that transform images into more useful structures.