I'm new with OpenCV and I'm using it for change the luminosity of an image. In my image, here: https://docs.google.com/file/d/0B9LaMgEERnMxQUNKbndBODJ5TXM/edit, there's a big space reflecting the light of the ambiance just in one part of it. At first, I could change all the luminosity on image. Now, I'm trying to reduce this space, which means in a specific place of the image, using the V of HSV, here is the code for that: enter code here
Mat newImg;
cvtColor(img, newImg, CV_BGR2HSV);
imwrite("C:/Users/amanda.brito/Desktop/test.jpg", newImg);
vector<Mat> hsv_planes;
split(newImg, hsv_planes); //geting the color plans of image
int param = -70; // the value that I'm seting for V
for (int y = 0; y < newImg.rows; y++) {
for (int x = 0; x < newImg.cols; x++) {
Vec3b pixel = hsv_planes[2].at<Vec3b>(y, x);
pixel[0] = 0;
pixel[1] = 0;
pixel[2] = param;
hsv_planes[2].at<Vec3b>(y, x) = pixel;
}
}
merge(hsv_planes, newImg);
Mat imagem;
cvtColor(newImg, imagem, CV_HSV2BGR);
imwrite("C:/Users/amanda.brito/Desktop/final.jpg", imagem);
Well, with this or nothing happen or the the compiler stops the program. I already looked everywhere but without luck. What am I doing wrong?
Since now, thanks for your help.