0

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.

Hime
  • 369
  • 3
  • 15
  • Your code works fine in my PC. Is it working or you are not getting the result as expected ? – Haris Jan 25 '13 at 13:34
  • Hi Haris, so, here this code is not working, during the execution some error happen and the application closes. And changing some parts, it's compiled, but the image stay the same. – Hime Jan 25 '13 at 14:08
  • Try this code http://pastebin.com/j4nbYjq8 And your hsv image look like this http://imgur.com/6yFcoox and final result look like this http://i.imgur.com/Rrshstp.jpg – Haris Jan 25 '13 at 14:13
  • Could you show me the image after this treatment? – Hime Jan 25 '13 at 14:13
  • Here is the result for your image HSV http://i.imgur.com/LDsF7k2.jpg and Final result http://i.imgur.com/bnv2fGM.jpg – Haris Jan 25 '13 at 14:24
  • Hi Haris. Thanks a lot for your help. I discover that my problem was the size of image. For some reason, the memory was not holding on. Now, my doubt is these stripes on image. Is it possible to remove them? I was thinking in use erode/dilate to do that. – Hime Jan 25 '13 at 15:28
  • Is there any reason for using param = -70 ? – Haris Jan 26 '13 at 07:02
  • This param value changes the image as I want, darkening it: more negative: darker. Does it influence in other things? – Hime Jan 28 '13 at 11:53

0 Answers0