[Radiance-general] Average luminance calculation

Jay jpothara at uccs.edu
Tue Jun 14 21:48:29 CEST 2005


Hi Greg,
I am using OpenCV to do the image manipulation. I am using c to do the 
calculation. following is the code that i had written.
I know its of topic -use of opencv. but i couldnt find any other useful 
information/help thats why i posted my query on the mailing list.
I am basically caluclating the log of pixel values. and hten dividing it 
by no of pixels in an image. and finally taking exponent of that.
Thanks for the prompt reply.
Jay
/////////////////////////////////////////////////////////CODE 
SNIPPET-OPENCV,C///////////////////////////////////////
/for( y = 1; y <height ; y++ )
        {
            for( x = 1; x < width; x++ )
            {
               uchar temp_blue =(uchar)(src->imageData + 
src->widthStep*y)[x*3];
               uchar temp_green = (uchar)(src->imageData + 
src->widthStep*y)[x*3+1];
               uchar temp_red  = (uchar)(src->imageData + 
src->widthStep*y)[x*3+2];
              
               temp = (0.27*temp_red) + (0.67*temp_green) + 
(0.06*temp_blue);
               temp1 = log10(temp);
               temp2 = log(temp);
              
               luminance_10 = temp1 + luminance_10;
               luminance_e = temp2 + luminance_e;            
            }
        }
      
        int pixel = src->width * src->height;
        printf("Width-%d,Height-%d\n",width,height);
        double luminance10_per_pixel = (luminance_10/pixel);
        double luminanceE_per_pixel = (luminance_e/pixel);
        // double image_key = pow (pixel,luminance);
        printf("NO of pixels ->%d\n\n",pixel);
        //luminance values for log10
        printf("----luminance values for log10------\n");
        //printf("Luminance  ->%f\n",luminance);
        //printf("luminance/pixel ->%f\n",value);
        printf("exp(luminance10)/pixel->%f\n",exp(luminance_10)/pixel);
        
printf("exp(luminance10/pixel)->%f\n\n\n",exp(luminance10_per_pixel));
        //luminance values for loge
        printf("----luminance values for loge------\n");
        printf("exp(luminanceE)/pixel->%f\n",exp(luminance_e)/pixel);
        printf("exp(luminanceE/pixel)->%f\n",exp(luminanceE_per_pixel));/



More information about the Radiance-general mailing list