당신은 테스트 픽셀 마스크 투자 수익 (ROI) 이미지를 사용하지만 실제 이미지에 작성할 수
cv::Mat plotImage;
int radius = 15;
float threshold = 1.8;
plotImage = cv::imread("C:/temp/debug.jpg", cv::IMREAD_COLOR);
cv::Point leftEye(person.GetLeftEyePoint().X, person.GetLeftEyePoint().Y);
cv::Point rightEye(person.GetRightEyePoint().X, person.GetRightEyePoint().Y);
//get the Rect containing the circle
cv::Rect r(leftEye.x-radius, leftEye.y-radius, radius*2, radius*2);
//obtain the image ROI
cv::Mat roi(plotImage, r);
//make a black mask, same size
cv::Mat mask(roi.size(), roi.type(), cv::Scalar::all(0));
//with a white filled circle in it
cv::circle(mask, cv::Point(radius, radius), radius, cv::Scalar::all(255), -1);
//combine roi & mask
cv::Mat croppedEye = roi&mask;
//conduct red eye detection/removal on croppedEye
int count = 0;
for(int y=0;y<croppedEye.rows;y++)
{
for(int x=0;x<croppedEye.cols;x++)
{
double b = croppedEye.at<cv::Vec3b>(y, x)[0];
double g = croppedEye.at<cv::Vec3b>(y, x)[1];
double r = croppedEye.at<cv::Vec3b>(y, x)[2];
double redIntensity = r/((g + b)/2);
//currently causes issues with non-red-eye images
if (redIntensity >= threshold)
{
double newRedValue = (g + b)/2;
cv::Vec3b pixelColor(newRedValue,g,b);
//
// here's the trick now, just write back to the original image ;)
//
roi.at<cv::Vec3b>(cv::Point(x,y)) = pixelColor;
count++;
}
}
}
cv::imwrite("C:\\temp\\test.jpg", plotImage);
도니는 다르게 . ;) croppedEye 이미지 (마스크를 사용하여 피부 부분을 제거)를 확인하지만 * write_to/correct * cloneRoi (또는 roi even, 다시 작성할 필요는 없습니다)를 사용하면 copyTo()에 대해? – berak
헤이 @ 버락! Nono, 당신은 나를 너무 많이 도와 줬어! 나는 네가 지금하고있는 말을 얻는다 !! 이것은 내가 현재 가지고있는 것입니다 (코드를 빠르게 변경했습니다) : http://i.imgur.com/4CmL2KJ.jpg 나는 그가 사소한 사고를 당했다고 생각합니다 ... 하. 눈을 잘못 들었을 가능성이 있음을 지금 확인하십시오. – LKB
네, 나는 잘못된 눈을 사용하고있었습니다. :) – LKB