我在 Python 中使用 OpenCV 和 PIL。我检测到 96 个圆圈及其中心 坐标 和 radio 。我需要每个圆圈的平均 RGB。
每个圆有 6000 个像素,所以我认为一对一迭代效率不高。
如何从每个圆中提取平均 RGB? 如果适合我的用例,我准备使用任何其他库。
最佳答案
终于明白了,这是解决方案:
circle_img = np.zeros((color_img.shape[0],color_img.shape[1]), np.uint8) #Creamos mascara (matriz de ceros) del tamano de la imagen original
cv2.circle(circle_img,(x_center,y_center),radio,(255,255,255),-1) #Pintamos los circulos en la mascara
datos_rgb = cv2.mean(color_img, mask=circle_img)[::-1]
关于python - 圆圈的 RGB 平均值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43086715/