# Circle with wide line shows segmenting

When i use the opencv circle function with a wide line width (e.g. 22 pix) and huge radius, i face the problem that the circle shows segmentation (see image with almost straight line/path. The bright, thin circles are the boarder circles and have line-width 1 for reference how the path should look).
With decreasing line-width, the segmentation starts to disappear.

Is there any way to get smooth circles with these parameters?

Alternatively i thought in drawing two small line-width circles and floodfill the space in between to get the same result as using one thick-lined circle.
However for my realtime application i wonder what is the fastest way.

Never tried to draw such circles, but you can draw them manually even without flood fill. Here’s a quick description of the method. Remember the formula of the circle:

``````x²+y²=r²
``````

Considering the center coordinates `(xc,yc)`:

``````(x-xc)²+(y-yc)²=r²
``````

If you draw line by line:

``````x1 = xc +/- sqrt(r1² - (y-yc)²) //two solutions
x2 = xc +/- sqrt(r2² - (y-yc)²)
``````

r1 and r2 are the inner/outer radii of the circle.
Now set the pixels between x1 and x2 to the desired color e.g.:

``````p=img.ptr(y)
for(x=x1;x<x2;x++)p[x]=c; //pay attention which one is smaller: x1 or x2
``````

Check if x1 and x2 are inside the image.
You have to treat separately if abs(y-yc)>r1 and abs(y-yc)>r2.

Thank you for the very detailed description of the “manual” way.
By now i got the floodfill method implemented successfully.
I’m doing hard to estimate what will be the fastest method on my Jetson Nano running openCV with CUDA support enabled.

these drawing methods aren’t supposed to fail like that.

if this is an actual bug in OpenCV, you should report it on OpenCV’s github.

make sure to provide source that reproduces the issue.