2012-12-13 24 views
3

如何計算由iPhone Camera.I勒克斯照度或已計算出所有的EXIF數據是因爲:計算照度

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 

我讀http://en.wikipedia.org/wiki/Light_meter也來到知道力士的計算方法(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 

我不明白這是什麼值例如參照。 N是來自Key Value Data的ApertureValue或FNumber,t是曝光時間或快門速度。什麼是C(320-540或250)的價值。 我將不同組合中的每個相似值應用於此公式,但由於我與計算勒克斯值的某個應用程序比較而得到錯誤結果。 另外我需要從照度來計算輻照度。

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); 

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

感謝advance.Any幫助將不勝感激:

除了我已經計算出拍攝圖像的亮度也。

回答

1

你真的需要照度的絕對值嗎?或者你能否擺脫可以相互比較的相對值,例如已知數值恆定的比例因子?

如果前者運氣不佳:exif數據中沒有C,並且使用校準程序檢索它需要擁有已知強度的光源,並且可能在積分球中拍攝照片。

如果後者只是將表達式重寫爲Lux = C *(N * N/St),其中N == FNumber,t == ExposureTime,S == ISOSpeedRatings,則設置C == 1(或任意任意值)

+0

謝謝你的答案。我計算你給出的公式但是它計算的值在1和0.So什麼是確切的方法來計算照度,是否有任何其他方式來計算LUX照度...提前致謝 –

+0

正如我所說,除非你能從規格表中找出儀表常數,唯一的辦法就是校準它。要獲得任何精度,您需要一個積分球(http://en.wikipedia.org/wiki/Integrating_sphere),一個校準的儀表來了解光源的強度,以及在校準攝像機的情況下拍攝一系列圖片。 –

+0

請告訴我可以在iOS中使用的完整過程Sdk.I將非常感謝您的支持。iPhone上有很多應用程序可用於計算Lux中的照度。 –