Opencv映射到HSV颜色空间

实在是太忙了,留着备用



#include<opencv2/opencv.hpp>
using namespace cv;
int main() {

	Mat 图片= imread("1.png");
//	VideoCapture cap(0);
	//while (waitKey(30) != 27) {
	//	cap >> 图片;
		Mat hsvImg;
		cvtColor(图片, hsvImg, COLOR_BGR2HSV);
		// 查找指定范围内的颜色  
		int colorIdx = 0;
		Mat imgThresholded;
		//蓝色
		inRange(hsvImg, Scalar(100, 43, 46), Scalar(124, 255, 255), imgThresholded);
		// 转换成二值图  
		threshold(imgThresholded, imgThresholded, 1, 255, THRESH_BINARY);
		imshow("原图", 图片);
		imshow("保留指定颜色图", imgThresholded);
		waitKey(-1);
	//}
}


猜你喜欢

转载自blog.csdn.net/zmdsjtu/article/details/78456478