//图像色彩空间转换
#include <stdio.h>
#include <iostream>
#include <string>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img,img32f,HSV,gray;
img = cv::imread("picture.jpeg");
if (img.empty())
{
cout << "读取图片失败" << endl;
return -1;
}
img.convertTo(img32f, CV_32F, 1.0 / 255);//将8位图像转化为32位图像,采用1/255的转化因子防止越界
cvtColor(img32f, HSV, COLOR_BGR2HSV);
cvtColor(img32f, gray, COLOR_BGR2GRAY);
cv::namedWindow("原图", WINDOW_NORMAL);
cv::imshow("原图",img32f);
cv::namedWindow("HSV图", WINDOW_NORMAL);
cv::imshow("HSV图", HSV);
cv::namedWindow("GRAY图", WINDOW_NORMAL);
cv::imshow("GRAY图", gray);
waitKey(0);
return 0;
}
初识Opencv4.X----图像色彩空间转换
猜你喜欢
转载自blog.csdn.net/qq_46146657/article/details/120166193
今日推荐
周排行