Improve circle rasterizing

This commit is contained in:
Lukas Klass 2020-09-26 17:11:52 +02:00
parent ca87a5202d
commit 1ffb7a7ade
1 changed files with 2 additions and 2 deletions

View File

@ -50,9 +50,9 @@ def rasterizeCircle(grid: np.ndarray, radius: float, xc: float, yc: float):
r2 = radius ** 2 # square of the radius
# Create meshgrid for the x and y range of the circle
dx, dy = np.meshgrid(range(- radius_pix if xc_pix - radius_pix >= 0 else - xc_pix,
dx, dy = np.meshgrid(range(- radius_pix if xc_pix >= radius_pix else - xc_pix,
radius_pix + 1 if grid.shape[1] > (xc_pix + radius_pix + 1) else grid.shape[1] - xc_pix),
range(- radius_pix if yc_pix - radius_pix >= 0 else - yc_pix,
range(- radius_pix if yc_pix >= radius_pix else - yc_pix,
radius_pix + 1 if grid.shape[0] > (yc_pix + radius_pix + 1) else grid.shape[0] - yc_pix))
dx2 = (dx + x_shift) ** 2 # Square of the x-component of the current pixels radius
dx_side2 = (dx + x_shift + ((dx < 0) - 0.5)) ** 2 # Square of the x-component of the neighbouring pixels radius