威望0
积分7976
贡献0
在线时间763 小时
UID1
注册时间2021-4-14
最后登录2024-11-24
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7976
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-24
- 在线时间
- 763 小时
|
#include<opencv2/opencv.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
Mat img;
img = imread("11.png");
if (img.empty())
{
cout << "could not load image!" << endl;
}
Mat img_bgr,img_hsv, img_hls;
cvtColor(img, img_hsv, COLOR_BGR2HSV);
cvtColor(img, img_hls, COLOR_BGR2HLS);
img_bgr = img.clone();
vector<Mat> hsvSplit;
vector<Mat> hlsSplit;
vector<Mat> bgrSplit;
split(img_hsv, hsvSplit);
split(img_hls, hlsSplit);
split(img_bgr, bgrSplit);
Mat hsv_h = hsvSplit[0];
Mat hsv_s = hsvSplit[1];
Mat hsv_v = hsvSplit[2];
Mat hls_h = hlsSplit[0];
Mat hls_l = hlsSplit[1];
Mat hls_s = hlsSplit[2];
Mat bgr_b = bgrSplit[0];
Mat bgr_g = bgrSplit[1];
Mat bgr_r = bgrSplit[2];
imshow("hsv_h", hsv_h);
imshow("hsv_s", hsv_s);
imshow("hsv_v", hsv_v);
imshow("hls_h", hls_h);
imshow("hls_l", hls_l);
imshow("hls_s", hls_s);
imshow("bgr_b", bgr_b);
imshow("bgr_g", bgr_g);
imshow("bgr_r", bgr_r);
waitKey(0);
return 1;
}
|
|