calculate illuminance from Exif Data

*爱你&永不变心* 提交于 2020-02-27 07:36:37

问题


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.


回答1:


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)




回答2:


This is my suggested code:

(void)imagePickerController:(UIImagePickerController *)anImagePickerController didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
    //NSLog(@"%@",info);

    NSDictionary *temp=[info   objectForKey:@"UIImagePickerControllerMediaMetadata"];
    NSDictionary *temp2=[temp objectForKey:@"{Exif}"];

    float fnumber=[[temp2 objectForKey:@"FNumber"]floatValue];
    float ExposureTime=[[temp2 objectForKey:@"ExposureTime"]floatValue];

    NSArray *iosarray=[temp2 objectForKey:@"ISOSpeedRatings"];

    float ISOSpeedRatings=[[iosarray objectAtIndex:0]floatValue];

    int c=80;//you need to calibrate this value

    float illuminanace=c*(fnumber*fnumber /(ISOSpeedRatings*ExposureTime));

    //NSLog(@"fnumber=%f ",fnumber);
    //NSLog(@"ExposureTime=%f ",ExposureTime);
    //NSLog(@"iosarray=%@",iosarray);
    //NSLog(@"ISOSpeedRatings=%f",ISOSpeedRatings);

    NSLog(@"illiminace =%f lux",illuminanace);
}


来源:https://stackoverflow.com/questions/13866567/calculate-illuminance-from-exif-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!