opencv python根据轮廓区域的颜色强度过滤轮廓

时间:2019-02-25 13:10:15

标签: image-processing opencv-python

我想根据灰度图像中轮廓区域的颜色强度从集合中过滤轮廓。因此,对于每帧中所有检测到的轮廓,我想检查轮廓的平均颜色强度是否大于阈值。

def check_countour(cnt, gray_frame, threshold):
    cimg = np.zeros_like(gray_frame)
    cv2.drawContours(cimg, cnt, -1, color=255, thickness=-3)
    pts = np.where(cimg == 255)
    color_intensity = np.mean(gray_frame[pts[0], pts[1]])
    return True if color_intensity > threshold else False

这能正确地给我答案吗?

0 个答案:

没有答案
相关问题