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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With