How do you set the V value of HSV mat in Opencv Java?

673 Views Asked by At

I want to remove the shadows from the input image. Based from what I found, I need to set the V value of HSV to 200. But this code is not working for me in opencv android studio. Please help me understand what I'm doing wrong here.

 public Mat fixIntensity(Mat inputImage) {
        Mat hsvImg;
        Imgproc.cvtColor(inputImage, hsvImg, Imgproc.COLOR_RGB2HSV);
        Mat channel[3];

        Core.split(hsvImg, channel);
        channel[2] = Mat(hsvImg.rows, hsvImg.cols, CV_8UC1, 200);//Set V
        //Merge channels
        Core.merge(channel, 3, hsvImg);
        Mat rgbImg;
        Imgproc.cvtColor(hsvImg, rgbImg, CV_HSV2BGR);

        return rgbImg;
}
0

There are 0 best solutions below