這裏是我嘗試改善圖像顏色的功能。它的作品,但它真的很慢......也許有人有一個更好的主意?Opencv慢代碼:是不是有問題?
static Mat correctColor(Mat AImage) {
Mat copyImage;
AImage.copyTo(copyImage);
Mat imgLab;
cvtColor(copyImage, imgLab, CV_BGR2Lab);
for (int y = 0; y < imgLab.rows; y++) {
for (int x = 0; x < imgLab.cols; x++) {
//get pixel value
imgLab.ptr<uchar > (y)[x * 3] = imgLab.ptr<uchar > (y)[x * 3]*0.3;
}
}
cvtColor(imgLab, copyImage, CV_Lab2BGR);
Mat img(copyImage.rows, copyImage.cols, CV_32FC3);
copyImage.convertTo(img, CV_32FC3, 1/255.);
blur(img, img, Size(255, 255));
Mat img32(copyImage.rows, copyImage.cols, CV_32FC3);
copyImage.convertTo(img32, CV_32FC3, 1/255.);
img.mul(img, 2);
divide(img32, img, img);
img.convertTo(copyImage, CV_8U, 255.0);
return copyImage;
}
這應該更好地發佈到[codereview.se] – CharlesB
thx我不知道這個頁面 – rouge