Skip to content
Advertisement

Given a image, a pixel point and a radious in pixels. How do I find the pixel coordenate of the circle border it creates

Given an image matrix, I want to find the pixel points coordinates of all points/pixels in the border of a given circle with center (x,y), where x and y are integers and radius r, where r is also an integer. Considering the border is 1 pixel thick. Ony this outer edge is what I need to find. I’m having trouble because I only have integers to work with. I tried Manhattan distance but it gives me a square rotated in 45 degrees. I don’t really know how to move forward

Advertisement

Answer

I saw your last question, and seems you need expanding circle.

Note that simple drawing of circumference pixels might produce small empty spaces. Example for drawing circles of radius 1,2,…,n:

enter image description here

But you can complete integer circle drawing algorithms like Bresenham’s one.

Increase r value one-by-one. Generate sequence of pixel coordinates with Bresenham’s algorithm in the first octant. Draw pixel if it is not filled yet (from another cell center), and check if lower pixel is filled – if not, draw it to remove empty space. Do the same for 7 symmetric pixels and their neighbors (bottom for the second octant and so on)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement