circle
#
Automatic search of the spinning disk’s circle
- find(image: ndarray, center_search_ratio: float = 0.05, radius_ratio_min: float = 0.5, radius_ratio_max: float = 0.4, min_scaled_edge: int = 512) tuple[int, int, int] [source]#
Finds the outside circle in the image.
Returns center coordinates
x
andy
as well as radiusr
of the circle, all in pixels.The radius is searched between
radius_ratio_min
andradius_ratio_max
relative to the shorter edge of the input image. The circle center is searched in a region of relative edge lengthcenter_search_ratio
relative to the image width or height.To speed up the search, we use a pyramid of progressively down-scaled images. We stop down-scaling once the shorter edge (of width or height) get below
min_scaled_edge
.
- draw(canvas: ndarray, x: float, y: float, r: float) ndarray [source]#
Draws the circle at
(x, y)
with radiusr
onto the imagecanvas
.This is meant for visual inspection.
- write(file: Path, x: float, y: float, r: float)[source]#
Writes circle position
(x, y)
and radiusr
to givenfile
.
- read(file: Path) tuple[int, int, int] [source]#
Reads circle position from given file.
Returns center coordinates
x
andy
as well as radiusr
of the circle, all in pixels.
- edge_density(x0: float, y0: float, r: float, image: ndarray) float [source]#
Measures the “color density” along the edge of a given circle.
This function helps in finding the circle by estimating how much contrast is visible along the edge for any given guess as to where and how large the circle might be. The circle is centered at
(x0, y0
) and has radiusr
.