1
$\begingroup$

Is there any method for calculating luminance of an image?

As from wiki got to know Luminance is an amount of energy perceived by the observer and LUX is different from brightness.

But still is there any way to calculate LUX value of an image using any of image processing technique.

$\endgroup$
2
$\begingroup$

https://stackoverflow.com/a/4876528/4523099

Just convert your image to YUV format and calculate the average of luma channel. Color conversion is a typical operation and any decent image processing framework supports it. For example, OpenCV has CvtColor.

However, to get an actual Lux value, you will need to calibrate your camera and tell whether it has an auto-setting aperture (see the link above for more details).

$\endgroup$
  • $\begingroup$ thank you very much i have approched the code for above like this %reading an image IMG = imread('C:\Users\Public\Pictures\Sample Pictures\Koala.jpg'); %converting to YUV format rgbImage= rgb2ycbcr(IMG); % Extract the individual red, green, and blue color channels. redChannel = rgbImage(:, :, 1); greenChannel = rgbImage(:, :, 2); blueChannel = rgbImage(:, :, 3); % Get means redMean = mean2(redChannel); greenMean = mean2(greenChannel); blueMean = mean2(blueChannel); Y = 0.299*redMean + 0.587*greenMean + 0.144*blueMean but the LUX value i am getting is 124.86 which is very much.. $\endgroup$ – user3805574 Mar 24 '15 at 15:00
  • $\begingroup$ Welcome... You converted to YUV 2 times , once by matlab and once by your self. Delete rgbImage= rgb2ycbcr(IMG); and depend on your code then calculate the average as mentioned in the post $\endgroup$ – Humam Helfawi Mar 24 '15 at 15:19
  • $\begingroup$ Extract the luma channel, sum all pixels of the extracted luma channel, divide the sum by the total number of pixels - for this i removed rgbImage= rgb2ycbcr(IMG); added code as. Y = 0.299*redMean + 0.587*greenMean + 0.144*blueMean [x y z] = size(rgbImage); % total number of pixels total_pixel = x*y; lux = Y/total_pixel; after running i am getting lux as lux = 5.9311e-05. which is very low please correct me where i am wrong. $\endgroup$ – user3805574 Mar 24 '15 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.