Как убрать блики с фотографии?
Вот код, который я использую для получения изображения Я хочу:
Mat &image = *(Mat *) matAddrRgba;
Rect bounding_rect;
Mat thr(image.rows, image.cols, CV_8UC1);
cvtColor(image, thr, CV_BGR2GRAY); //Convert to gray
threshold(thr, thr, 150, 255, THRESH_BINARY + THRESH_OTSU); //Threshold the gray
vector contours; // Vector for storing contour
vector hierarchy;
findContours(thr, contours, hierarchy, CV_RETR_CCOMP,
CV_CHAIN_APPROX_SIMPLE); // Find the contours in the image
sort(contours.begin(), contours.end(),
compareContourAreas); //Store the index of largest contour
bounding_rect = boundingRect(contours[0]);
rectangle(image, bounding_rect, Scalar(250, 250, 250), 5);
Вот фотография блика, о котором я говорю:

Я нашел то, что можно использовать inRange, найти подходящий скаляр для цвет и рисуем краской, чтобы убрать свет. Вот фрагмент кода, но он всегда вылетает, говоря, что нужно 8-битное изображение с каналами.
Mat &image = *(Mat *) matAddrRgba;
Mat hsv, newImage, inpaintMask;
cv::Mat lower_red_hue_range;
inpaintMask = Mat::zeros(image.size(), CV_8U);
cvtColor(image, hsv, COLOR_BGR2HSV);
cv::inRange(hsv, cv::Scalar(0, 0, 215, 0), cv::Scalar(180, 255, 255, 0),
lower_red_hue_range);
image = lower_red_hue_range;
inpaint(image, lower_red_hue_range, newImage, 3, INPAINT_TELEA);
Подробнее здесь: https://stackoverflow.com/questions/434 ... oto-opencv
Мобильная версия