The skimage.draw module has functions to draw circles, ellipses, lines, etc. However the line width seems to be fixed at 1 pixel. There doesn't appear to be a parameter to set the line width.
Stefan van der Walt suggested that there is hidden functionality in the skimage.measure submodule to draw thicker lines, but I had a look at the documentation and only saw the profile_line
function which does have a linewidth
parameter. I don't know if this what he meant, or how I can use that to draw an ellipse with width=3.
So how can I draw an ellipse with thickness of 3 pixels into a numpy image array (type float)? Preferably using skimage.
I would use draw
to draw a 1-pixel thick line, then use skimage.morphology.dilation
to "thicken" that line:
import numpy as np
import matplotlib.pyplot as plt
from skimage import draw, morphology
image = np.zeros((128, 128))
rr, cc = draw.ellipse_perimeter(64, 64, 20, 10)
image[rr, cc] = 1
dilated = morphology.dilation(image, morphology.disk(radius=1))
fig, (ax0, ax1) = plt.subplots(1, 2)
ax0.imshow(image)
ax1.imshow(dilated)