Вот небольшой пример skimage.draw.circle()
, который на самом деле не рисует круг, но дает вам координаты точек внутри круга, которые можно использовать для индексации массивов Numpy с помощью.
#!/usr/bin/env python3
import numpy as np
from skimage.io import imsave
from skimage.draw import circle
# Make rectangular canvas of mid-grey
w, h = 200, 100
img = np.full((h, w), 128, dtype=np.uint8)
# Get coordinates of points within a central circle
Ycoords, Xcoords = circle(h//2, w//2, 45)
# Make all points in circle=200, i.e. fill circle with 200
img[Ycoords, Xcoords] = 200
# Get mean of points in circle
print(img[Ycoords, Xcoords].mean()) # prints 200.0
# DEBUG: Save image for checking
imsave('result.png',img)
Ключевые слова : Numpy, лыжный маг, scikit-изображение, обработка изображений, Python, круг, рисование, координаты точек внутри круга, среднее значение в маске.