
- Mat _blur;
- cv::GaussianBlur(src,_blur,Size(3,3),0);
- Mat _sharp;
- Mat kernal = Mat::zeros(3,3,CV_32FC1);
- kernal.at<float>(0,1) = -1;
- kernal.at<float>(1,0) = -1;
- kernal.at<float>(1,1) = 5;
- kernal.at<float>(1,2) = -1;
- kernal.at<float>(2,1) = -1;
-
- cv::filter2D(_blur,_sharp,-1,kernal);
- Mat _hsv,_sat;
- cvtColor(_sharp,_hsv,cv::COLOR_BGR2HSV);
- imwrite("d:/hsv.bmp",_hsv);
- for (int h = 0;h < _hsv.rows;h ++)
- {
- uchar *data = _hsv.ptr<uchar>(h);
- for (int w = 0;w < _hsv.cols;w ++)
- {
- int w3 = 3*w;
- data[w3 + 1] = 0.7 * data[w3 + 1];
- }
- }
- cvtColor(_hsv,_sat,cv::COLOR_HSV2BGR);
- int off = 3;
- Mat _trans = _sat.clone();
- for (int h = 0;h < _sat.rows ;h ++)
- {
- for (int w = 0;w < _sat.cols;w ++)
- {
- int nh = h + off;
- int nw = w + off;
- if (nh >= 0 && nh < _sat.rows &&
- nw >= 0 && nw < _sat.cols )
- {
- _trans.at<Vec3b>(h,w)[0] = _sat.at<Vec3b>(h,w)[0];
- _trans.at<Vec3b>(h,w)[1] = _sat.at<Vec3b>(h,w)[1];
- _trans.at<Vec3b>(h,w)[2] = _sat.at<Vec3b>(nh,nw)[2];
- }
- }
- }