Sethu
Sethu

Reputation: 52

How could i enhance the brightness of the image only in the regions in which it is dark in opencv(java)

I could increase or decrease the brighness off the entire image by using convertTo function .

But how could i traverse the image pixel by pixel and increase the brighness of the image only if its dark at that particular pixel ?

Upvotes: 1

Views: 171

Answers (1)

MarcoM
MarcoM

Reputation: 1204

Give a look to this tutorial, it could be a good starting point. It explain exactly how to change image brightness accessing each pixel of the image.

Here is how to traverse the image pixel by pixel:

for( int y = 0; y < image.rows; y++ )
   { for( int x = 0; x < image.cols; x++ )
        { for( int c = 0; c < 3; c++ )
             { new_image.at<Vec3b>(y,x)[c] =
                         saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta ); }
   }
   }

Upvotes: 2

Related Questions