将RGB颜色空间转换到Lab,修改一幅图像的颜色;
/*
* color_transfer.cpp
*
* Created on: May 21, 2018
* Author: cui
*/
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
using namespace std;
int main( int argc, char *argv[] )
{
Mat src, tar;
src = imread( argv[1] );
if( src.empty() ){
cout << "Couldn't load image" << endl;
return -1;
}
tar = imread( argv[2] );
if( tar.empty() ){
cout << "Couldn't load image" << endl;
return -1;
}
//变换到Lab和CV_32FC1
Mat src_lab, tar_lab;
cvtColor( src, src_lab, COLOR_BGR2Lab );
cvtColor( tar, tar_lab, COLOR_BGR2Lab );
src_lab.convertTo( src_lab, CV_32FC1);
tar_la