Hi people,
I am trying to calculate contrast for images. I am referring to paper (http://diuf.unifr.ch/courses03-04/imaging/simoncelli.pdf). This paper suggest that to calculate contrast luminance is first needs to be calculated.
I am calculating lumninance using the formula.
L_w = exp[ 1 / N( sum[ log( delta + L_w ( x, y ) ) ] ) ]
Where:
* L_w - log-average luminance
* N - number of pixels in the image
* delta - a small factor to avoid problems with black pixels
* L_w ( x, y ) - the world space luminance for pixel ( x, y )
where log has base e.
I am using the image from http://www.cacs.louisiana.edu/~cice/lal/. i cant get the luminance values mentioned on the website.
Can someone please tell me where am i going wrong.
You have to offer us some clues as to how you are attempting this calculation. The website you give shows a bunch of JPEG thumbnails. Are you converting those? It seems that the author of this page is converting them without considering gamma, then computing the log of the non-linear gray values, which is basically nonsense. However, in the interest of reproducing their results, you can use:
To get the final log-average luminance, simply apply the exponent function:
% ev 'exp(-2.0835)'
This yeilds:
0.124493721
Not exactly the 0.1212 value they give on the website, but close. Note that I didn't use a delta value in my calculation, but adding one should raise this value rather than lower it. A more intelligent application of log averaging would apply a gamma to get back to a linear color space, e.g.:
Apply the exp() function to this result gives a much smaller result:
0.00687406256
-Greg
···
From: Jay <jpothara@uccs.edu>
Date: June 14, 2005 10:37:17 AM PDT
Hi people,
I am trying to calculate contrast for images. I am referring to paper (http://diuf.unifr.ch/courses03-04/imaging/simoncelli.pdf). This paper suggest that to calculate contrast luminance is first needs to be calculated.
I am calculating lumninance using the formula.
L_w = exp[ 1 / N( sum[ log( delta + L_w ( x, y ) ) ] ) ]
Where:
* L_w - log-average luminance
* N - number of pixels in the image
* delta - a small factor to avoid problems with black pixels
* L_w ( x, y ) - the world space luminance for pixel ( x, y )
where log has base e.
I am using the image from http://www.cacs.louisiana.edu/~cice/lal/. i cant get the luminance values mentioned on the website.
Can someone please tell me where am i going wrong.
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));/