https://www.youtube.com/watch?v=95DNdbxaIXE
Camera Response Function
카메라가 실제 장면의 빛의 강도(Brightness)를 디지털 이미지 픽셀 값으로 변환하는 방식을 설명하는 함수.

p(λ)p(λ) : Photon flux, λλ 는 wavelength.
II : Electron flux from photodiode (Luminance라고 생각해도 된다.)
여기서 BB 는 brightness 임.
B=It(πd24)=Itπr2=Ie
where
- t : exposure time or integration time
- d : aperature diameter. 카메라에선 r보다 d를 많이 애기함.
- e : exposure, e=t(πd2r)
M is measured brightness 임 (image file에 기재되는 pixel intensity라고 생각해도 된다.).
M=f(B)=f(Ie)
“카메라에 입력밝기(brightness) B”에 대한 ”카메라에서 출력밝기(measured brightness) M”의 응답곡선(아래 그림 참조)을
characteristic curve (특성곡선)이라고 부름 (film camera 당시의 용어).
필름 카메라에서 characteristic function 또는 H&D curve (Hurter & Driffield curve) 라는 용어로
필름의 노출 값(빛의 세기)과 필름에 기록되는 밀도(농도) 값 간의 관계를 나타내는 그래프를 지칭함.
일반적으로 S자 모양의 곡선
Digital Camera의 경우 Camera Response Function이라는 용어가 보다 많이 사용됨.

- display device 등에서도 존재하며, gamma collection 등과 연관됨 (입력전압에 대한 출력밝기 등등)
- display device에서도 characteristic curve, characteristic equation 등으로 많이 쓰이며, Camera의 경우엔 camera response function 을 보다 많이 사용함.
CRF가 linear하지 않고 비선형인 이유는 제한된 Dynamic Range에서 보다 효과적으로 brightness를 encoding하기 위해서임.
- 효과적으로 brightness를 encoding 한다는 뜻은, 디지털 이미지의 비트 사용을 최적화하기 위해서임.
- 실제 세계의 brightness의 범위는 매우 넓음: 제한된 pixel depth에 비해.
- CRF 릉 통해 보다 작은 depth로 이를 압축하여 encoding.
- 인간의 눈이 낮은 B에서의 작은 변화에 민감한 것처럼,
- Camera 역시 낮은 B 영역대에서 작은 변화에 크게 M이 변환되도록 구현된다.
Radiometric Calibration
카메라나 다른 센서가 기록한 이미지나 데이터가 실제 물리적인 값들과 정확히 일치하도록 조정하는 과정
흔히, CRF를 찾는 것을 의미함.
보통 Macbeth chart와 같이
- 알려진 “reflectance (반사율)”의 여러 patch들로 구성된 차트를 촬영하고
- 이에 대한 응답곡선을 직선이나 특정 곡선에 fitting시켜서 구함.

opencv등의 라이브러리를 이용하여 relative brightness에 대한 pixel intensity로 구하기도 한다.
- 엄밀한 radiometric calibration과는 차이가 있으나
High Dynamic Range Image 를 얻을 때 요구되는 CRF를 구할 때는 주로 이 방법이 사용됨. - HDR을 구할 때 와 마찬가지로 동일대상에 대해 exposure가 다르게 여러 image를 얻고 이를 바탕으로 얻어낼 수 있음
다음의 코드는 아래의 exposure가 다른 영상들을 통해 crf를 얻어내는 코드임 (동시에 gamma도 얻음):

https://www.packtpub.com/en-us/product/opencv-3-computer-vision-with-python-cookbook-9781788474443
OpenCV 3 Computer Vision with Python Cookbook | Data | eBook
Leverage the power of OpenCV 3 and Python to build computer vision applications. Instant delivery. Top rated Computer Vision products.
www.packtpub.com
Python Source Code.
from PIL import Image from PIL.ExifTags import TAGS import matplotlib.pyplot as plt from scipy import optimize TAGS_RESERVED = {v:k for k,v in TAGS.items()} EXPOSURE_TIME_TAG = TAGS_RESERVED.get('ExposureTime') def get_exposure_time(img_path): with Image.open(img_path) as img: exif_data = img._getexif() exposure = exif_data.get(EXPOSURE_TIME_TAG,-1.) return exposure def gamma_function(x, gamma, scale): return scale* (x)**gamma def plot_crf(crf): colors = ['b','g', 'r'] labels = ['blue','green', 'red'] gammas = [] scales = [] # print(crf.shape) tmp = np.squeeze(crf) # print(tmp.shape) crf = np.transpose(tmp,(1,0)) # print(crf.shape) plt.figure(figsize=(10,6)) for i in range(3): plt.plot( crf[i], range(256), color=colors[i], label=labels[i], ) max_b = np.max(crf) norm_crf = crf/max_b popt, _ = optimize.curve_fit(gamma_function, norm_crf[i], np.linspace(0,255,256), ) gamma, scale = popt gammas.append(gamma) scales.append(scale) m_gamma = np.array(gammas).mean() m_scale = np.array(scales).mean() print(m_gamma, m_scale) plt.plot(crf[0], gamma_function(norm_crf[i], m_gamma, m_scale), '--', label='fitted gamma', ) plt.ylabel('pixel value') plt.xlabel('relative luminance') plt.title('camera response funciton') plt.legend() plt.grid(True) plt.show() def main(): img_names = ['33','100','179','892','1560','2933'] exposures = [] imgs = [] for img in img_names: img_path = f'./{img}.jpg' exposure = get_exposure_time(img_path) if exposure > 0: exposures.append(exposure) imgs.append(cv2.imread(img_path, cv2.IMREAD_COLOR)) exposures = np.array(exposures).astype(np.float32) calibrate = cv2.createCalibrateDebevec() response = calibrate.process(imgs, exposures) plot_crf(response) if __name__ == "__main__": main()
결과는 다음과 같음.

High Dynamic Range
2024.09.03 - [Programming/DIP] - [CV] High Dynamic Range
[CV] High Dynamic Range
High Dynamic Range(HDR)는 image나 video에서 Dynamic Range를 넓혀서, 밝은 부분과 어두운 부분의 contrast를 더 넓은 범위로 표현할 수 있게 해주는 기술임. https://www.youtube.com/watch?v=95DNdbxaIXE읽어볼 자료 ht
dsaint31.tistory.com
같이보면 좋은 자료
2024.09.01 - [Programming/DIP] - [CV] Dynamic Range란?
[CV] Dynamic Range란?
카메라와 디스플레이의 Dynamic RangeDynamic Range: Dynamic Range는 카메라와 디스플레이 장치에서 최소 밝기와 최대 밝기 사이의 범위를 의미. 이는 장치의 밝기 디테일 처리 능력을 결정하는 중요한
dsaint31.tistory.com
'Programming > DIP' 카테고리의 다른 글
[CV] Brightness vs. Intensity (0) | 2024.09.05 |
---|---|
[CV] High Dynamic Range (1) | 2024.09.03 |
[CV] Dynamic Range 란? (2) | 2024.09.01 |
[CV] 공간해상도로 본 광센서와 디스플레이 디바이스 발전사 (2) | 2024.09.01 |
[CV] DIP, Image Analysis, and Computer Vision (4) | 2024.09.01 |