RGB average of circles

2019-08-03 04:42发布

I'm using OpenCV and PIL in Python. I have 96 circles detected with their center coordinates and radios. I need the average RGB from each circles.

Each circle has 6000 pixels, so I thinks iterate one to one it is not efficient.

How can I extract the average RGB from each circle? I am ready to use any other library if it suits my use-case.

2条回答
叼着烟拽天下
2楼-- · 2019-08-03 05:11

Finally I get it, this is the solution:

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]
查看更多
等我变得足够好
3楼-- · 2019-08-03 05:17

You can use openCV library

All of these steps is supported by openCV.

查看更多
登录 后发表回答