본문 바로가기
컴퓨터과학

[study] 감마보정 (Gamma Correction, Gamma Encoding)

by 홈카페주인 2023. 5. 1.

20230501 ~ 공부 시작

감마보정은 영어로 Gamma Correction, Gamma Encoding, Gamma Compression 등 여러 용어로 불리지만 이들은 모두 유사한 개념을 나타낸다고 한다.

 

감마보정을 하는 이유는 인간의 눈이 카메라 센서처럼 빛이 2배 들어온다고 해서 정확히 2배라고 인지하는 것이 아니기 때문에 카메라의 raw 파일이 빛의 양을 선형적으로 계산해서 출력할 경우 이것이 인간의 눈으로 관찰한 것과 다르게 보이기 때문에 이를 보정하여 사람의 눈으로 보기에 최적의 화질로 고쳐주는 것이라고 한다.

 

참고 이미지

https://commons.wikimedia.org/wiki/File:Gamma_correction_brabbit.jpg?uselang=ko

 

참고 코드

 

import cv2
import numpy as np


g = float(input("Gamma : "))
img = cv2.imread("input image.png")
out = img.copy()
out = img.astype(np.float)
out = ((out / 255) ** (1 / g)) * 255
out = out.astype(np.uint8)
cv2.imshow("original", img)
cv2.imshow("gamma", out)
cv2.waitKey(0)

 

 

 

참고자료

https://en.wikipedia.org/wiki/Gamma_correction

 

Gamma correction - Wikipedia

From Wikipedia, the free encyclopedia Nonlinear operation The effect of gamma correction on an image: The original image was taken to varying powers, showing that powers larger than 1 make the shadows darker, while powers smaller than 1 make dark regions l

en.wikipedia.org

https://ko.wikipedia.org/wiki/%EA%B0%90%EB%A7%88_%EB%B3%B4%EC%A0%95

 

감마 보정 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 감마 보정(감마 교정)은 비디오 카메라, 컴퓨터 그래픽 등에서 비선형 전달 함수(nonlinear transfer function)를 사용하여 빛의 강도(intensity) 신호를 비선형적으로 변

ko.wikipedia.org

https://marisara.tistory.com/entry/%ED%8C%8C%EC%9D%B4%EC%8D%AC-openCV-2-%EA%B0%90%EB%A7%88-%EB%B3%B4%EC%A0%95Gamma-Correction

 

파이썬 openCV 2. 감마 보정(Gamma Correction)

파이썬 openCV의 두 번째 강의 감마보정(Gamma Correction)입니다. 원래 사람의 눈은 컴퓨터가 처리하는 밝기와 다르게 반응합니다. 그래서 어두운곳은 0, 밝은곳을 255로 아무 보정 없이 매칭하게 되면

marisara.tistory.com

https://pyimagesearch.com/2015/10/05/opencv-gamma-correction/

 

OpenCV Gamma Correction - PyImageSearch

In this tutorial I'll show you how to implement a super fast, easy to use Gamma correction function using Python and OpenCV. Click here to learn more.

pyimagesearch.com

 

728x90

댓글