Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calculate illuminance from Exif Data

How I calculate the lux or illuminance by iPhone Camera.I have calculated all the exif data which is as:

key = FocalLength, value = 3.85
key = MeteringMode, value = 5
key = ShutterSpeedValue, value = 4.591759434012097
key = ExposureProgram, value = 2
key = FocalLenIn35mmFilm, value = 32
key = SceneType, value = 1
key = FNumber, value = 2.4
key = PixelXDimension, value = 480
key = ExposureTime, value = 0.04166666666666666
key = BrightnessValue, value = -0.2005493394308445
key = ApertureValue, value = 2.526068811667588
key = Flash, value = 32
key = ExposureMode, value = 0
key = PixelYDimension, value = 360
key = SensingMethod, value = 2
key = ISOSpeedRatings, value = (
        1250
    )
key = WhiteBalance, value = 0

I read http://en.wikipedia.org/wiki/Light_meter also and came to know that Lux is calculated by (N*N*C)/tS

Where N is the relative aperture (f-number)
t is the exposure time (“shutter speed”) in seconds
S is the ISO arithmetic speed
C is the incident-light meter calibration constant

I do not understand what this value refer to eg. N is ApertureValue or FNumber from Key Value Data and t is exposure time or shutter speed. And What is value of C(320-540 or 250). I applied every similar values in different combination to this formula but got wrong result as I compare with some app that calculate lux values. Also I need to calulate the irradiance from illuminance.

In Addition I have calculated the Luminance of captured image also by:

UIImage* image = [UIImage imageNamed:@"image.png"];
unsigned char* pixels = [image rgbaPixels];
double totalLuminance = 0.0;
for(int p=0;p<image.size.width*image.size.height*4;p+=4) {
  totalLuminance += pixels[p]*0.299 + pixels[p+1]*0.587 + pixels[p+2]*0.114;
}
totalLuminance /= (image.size.width*image.size.height);
totalLuminance /= 255.0;
NSLog(@"Image.png = %f",totalLuminance);

by http://b2cloud.com.au/tutorial/obtaining-luminosity-from-an-ios-camera

Thanks In advance.Any help will be appreciated.

like image 902
Gaurav Garg Avatar asked Nov 04 '22 08:11

Gaurav Garg


1 Answers

Do you really need the absolute value of illuminance? Or can you get away with relative values that can be compared to each other, e.g. values known up to a constant scale factor?

If the former you are out of luck: you don't have C in the exif data, and retrieving it with a calibration procedure requires having a light source of known intensity, and likely taking pictures in an integration sphere.

If the latter, just rewrite the expression as Lux = C * (N*N /St), where N == FNumber, t == ExposureTime, S == ISOSpeedRatings, set C == 1 (or any arbitrary value)

like image 136
Francesco Callari Avatar answered Nov 09 '22 06:11

Francesco Callari