当前位置:   article > 正文

opencv python rgb转yuv_OpenCV之色彩空间与色彩空间转换

python cv2 rgb转yuv

python代码:

  1. import cv2 as cv
  2. src = cv.imread("test.jpg")
  3. cv.namedWindow("rgb", cv.WINDOW_AUTOSIZE)
  4. cv.imshow("rgb", src)
  5. # RGB to HSV
  6. hsv = cv.cvtColor(src, cv.COLOR_BGR2HSV)
  7. cv.imshow("hsv", hsv)
  8. # RGB to YUV
  9. yuv = cv.cvtColor(src, cv.COLOR_BGR2YUV)
  10. cv.imshow("yuv", yuv)
  11. # RGB to YUV
  12. ycrcb = cv.cvtColor(src, cv.COLOR_BGR2YCrCb)
  13. cv.imshow("ycrcb", ycrcb)
  14. src2 = cv.imread("test.png");
  15. cv.imshow("src2", src2)
  16. hsv = cv.cvtColor(src2, cv.COLOR_BGR2HSV)
  17. mask = cv.inRange(hsv, (35, 43, 46), (99, 255, 255))
  18. cv.imshow("mask", mask)
  19. cv.waitKey(0)
  20. cv.destroyAllWindows()

4a102ea292e0deb973eb467d752b65d4.png

C++代码:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/670265
推荐阅读
相关标签
  

闽ICP备14008679号