Ask Your Question
2

How to determine an image with strong or weak illumination in OpenCV?

asked 2013-11-21 03:46:03 -0500

Kyo gravatar image

updated 2013-11-21 21:13:15 -0500

Hi..

I would like to develop an object tracking like a paper below:

[1] Li, J., Zhang, J., Zhou, Z., Guo, W., Wang, B., & Zhao, Q. (2011, October). Object tracking using improved Camshift with SURF method. In Open-Source Software for Scientific Computation (OSSC), 2011 International Workshop on (pp. 136-141). IEEE.

in this paper, the new algorithm being able to adjust the thresholds of S and V adaptively against the environment changes. Specifically, when under a strong illumination, the algorithm ignores those pixels with high S values, and when under weak illumination it ignores those with low S.[p:138]

Anybody knows how to determine an image is under strong or weak illumination in OpenCV? What value should I get to represent an image is under strong illumination or weak illumination?

Thanks in advance

edit retag flag offensive close merge delete

Comments

I haven't read the paper, but as you explain it, they just convert the image to HSV and ignore pixels with high and low values in the S plane. You can convert the image to HSV with the cvtColor function (see http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cvt#cvtcolor).

Guanta gravatar imageGuanta ( 2013-11-21 05:36:00 -0500 )edit

How can you do this solution in Java?

rafael.rodriguez342 gravatar imagerafael.rodriguez342 ( 2017-02-03 14:59:42 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-11-22 04:24:27 -0500

updated 2013-11-22 05:01:27 -0500

I developed a function that retrieves a measure of brightness in an image, using the RGB color channels to get a measure of image luminance (which I got here )

    void _getBrightness(const Mat& frame, double& brightness)
        {
            Mat temp, color[3], lum;
            temp = frame;

            split(temp, color);

            color[0] = color[0] * 0.299;
            color[1] = color[1] * 0.587;
            color[2] = color[2] * 0.114;


            lum = color[0] + color [1] + color[2];

            Scalar summ = sum(lum);


            brightness = summ[0]/((pow(2,8)-1)*frame.rows * frame.cols) * 2; //-- percentage conversion factor
         }

The last operation is a conversion factor to percentage. pow(2,8) means the Mat is 8-bit, if your working with 32 bit the conversion factor has to be ((pow(2,32)-1)*frame.rows * frame.cols) * 2

edit flag offensive delete link more

Comments

3

wait, 2^8 is 2 xor 8 in c++, not pow(2,8) , what you probably wanted

for an even faster version:

255 = 1<<8 - 1;

berak gravatar imageberak ( 2013-11-22 04:45:35 -0500 )edit

Weird, since the values really go from 0 to 100, consistently with the brightness in the image, thanks for the advice though! Updated the answer

Pedro Batista gravatar imagePedro Batista ( 2013-11-22 04:58:31 -0500 )edit

thanks for the answer.. :D

Kyo gravatar imageKyo ( 2014-01-27 04:10:29 -0500 )edit

It seems that your algorithm results in a value range of [0,2], due to the *2 multiplier that you have in the end. Am I missing something?

FR gravatar imageFR ( 2015-03-10 19:37:37 -0500 )edit

How can you do this in Java?

rafael.rodriguez342 gravatar imagerafael.rodriguez342 ( 2017-02-03 14:58:45 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2013-11-21 03:46:03 -0500

Seen: 9,012 times

Last updated: Nov 22 '13