python环境使用YCbCr掩码方式实现肤色检测

2024-10-24 09:03:30

1、利用YCbCr色度空间的特点,使用CbCr两种色度进行控制得到一个掩码矩阵,然后让源图和Mask进行与运算,从而得到我们想要的效果。还是来一张源图以及头文件import 艘早祓胂cv2 as cvimport numpy as npimage = cv.imread('c:\\handtest.jpg', cv.IMREAD_COLOR)cv.imshow("image", image)

python环境使用YCbCr掩码方式实现肤色检测

3、(Y, Cr, Cb) = cv.split(YCrCb)cv.imshow("Y", Y)cv.imshow("Cr", Cr)cv.imshow("Cb", Cb)

python环境使用YCbCr掩码方式实现肤色检测python环境使用YCbCr掩码方式实现肤色检测python环境使用YCbCr掩码方式实现肤色检测

6、bitwise_andImage = cv.bitwise_and(image, image, mask=maskNew)原图和二值掩码与运算!cv.imshow("bitwise_andImage", bitwise_andImage )cv.waitKey(0)cv.destroyAllWindows()其结果和阈值法差不多

python环境使用YCbCr掩码方式实现肤色检测
猜你喜欢