OpenCV之色彩空间与色彩空间转换

python代码:

import cv2 as cv

src = cv.imread("test.jpg")
cv.namedWindow("rgb", cv.WINDOW_AUTOSIZE)
cv.imshow("rgb", src)

# RGB to HSV
hsv = cv.cvtColor(src, cv.COLOR_BGR2HSV)
cv.imshow("hsv", hsv)

# RGB to YUV
yuv = cv.cvtColor(src, cv.COLOR_BGR2YUV)
cv.imshow("yuv", yuv)

# RGB to YUV
ycrcb = cv.cvtColor(src, cv.COLOR_BGR2YCrCb)
cv.imshow("ycrcb", ycrcb)

src2 = cv.imread("test.png");
cv.imshow("src2", src2)
hsv = cv.cvtColor(src2, cv.COLOR_BGR2HSV)
mask = cv.inRange(hsv, (35, 43, 46), (99, 255, 255))
cv.imshow("mask", mask)

cv.waitKey(0)
cv.destroyAllWindows()

OpenCV之色彩空间与色彩空间转换_第1张图片

C++代码:

#include 
#include 

using namespace cv;
using namespace std;

int main(int argc, const

你可能感兴趣的:(OpenCV进阶系列,opencv,色彩空间与色彩空间转换)