最近用到RGB图像需要往HSI上转化,就参照公式和奈奈酱前辈的写了点代码,
#include "stdafx.h"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "opencv2/highgui/highgui.hpp"
#include<math.h>
using namespace std;
using namespace cv;
int main ()
{
Mat BGRImage,BImage,GImage,RImage,HImage,SImage,IImage,dstImage;
BGRImage=imread("1.jpg");
imshow("原图",BGRImage);
Mat HSIImage = Mat(Size(BGRImage.cols, BGRImage.rows), CV_8UC3);
// 分离R G B 分量
vector<Mat>channels;
split(BGRImage,channels);
BImage = channels.at(0);