Hello, I'm learning how to use the features that OpenCV offers for image processing, and the following question came up:
How do I edit only a predetermined area of an image?
To make it easier for me to understand, I'm going to use the cv::cvtColor()
function and change a color image (RGB) to Gray Scale, but I'd like the proposed solution to work with any other function. What I've already been able to do:
Upload and View a disk image:
cv::Mat img = cv::imread("/home/anderson/Pictures/Outras/house.jpeg");
if (img.empty()) {
std::cout << "Falha ao carregar o arquivo do disco!" << std::endl;
}
cv::namedWindow("RGB");
cv::imshow("RGB", img);
Selectanareaandturntograyscale:
cv::MatimgMod(img,cv::Rect(100,100,150,150));cv::MatimgModOut;cv::cvtColor(imgMod,imgModOut,CV_BGR2GRAY);cv::namedWindow("Gray");
cv::imshow("Gray", imgModOut);
So long, but how do I combine the gray cutout with the original image and create a new partially gray (trimmed area) image?