300x250
일반적인 Image Color의 반전
import cv2 src_bgr = cv2.imread("src.jpg", cv2.IMREAD_COLOR) # invert color (색반전) invert_img = cv2.bitwise_not(src_bgr) cv2.imshow("original image", src_bgr) cv2.imshow("inverted image", invert_img) |
이미지의 밝기만 반전 - 색상은 유지 (Invert only lmage lightness)
기본적인 색상은 유지하며, 밝기만 반전하는 코드
import cv2 src_bgr = cv2.imread("src.jpg", cv2.IMREAD_COLOR) // convert bgr to hls hls 모드로 변경 hls = cv2.cvtColor(src_bgr, cv2.COLOR_BGR2HLS) h, l, s = cv2.split(hls) // invert lightness - 밝기 반전 invert_lightness = cv2.bitwise_not(l) invert_hls = cv2.merge([h, invert_lightness, s]) invert_img = cv2.cvtColor(invert_hls, cv2.COLOR_HLS2BGR) cv2.imshow("inverted lightness", invert_img) cv2.waitKey(0) cv2.destoryAllWindows() |
300x250
'Image Processing' 카테고리의 다른 글
Image Brightness and Contrast 변경 (0) | 2020.10.14 |
---|---|
image gamma 값 조정 (gamma correction) (0) | 2020.10.14 |
Image Blur/Smoothing/Gaussian Blur/Median Blur/Bilateral Filter/Motion Blur (0) | 2020.10.13 |
Histogram Equalization (히스토그램 평활화)/CLAHE (0) | 2020.10.12 |
PyCharm + OpenCV 환경 구성 (설치) (1) | 2019.06.26 |