x + y + z = 1
백색 기준으로 같은거리면 보색.
RGB 컬러모델
감산 모델 (CMY)
CMYK
HSV : 색상 + 채도 + 명도 (직관적!)
YUV : 컬러TV ↔ 흑백TV 호환성!
CIE Lab* : 인지된 색차가 맵 상의 거리에 비례하도록
CMS :
for(int i=0; i<height; i++)
for(int j=0; j<width; j++)
for (int c=0; c<3; c++)
Out[i][j][c] = In[i][j][c]/2;
# Out[i][j][c] = In[i][j][c] + In2[i][j][c] 처럼 다른 영상 값으로도 변경 가능.
import cv2 as cv
import numpy as np
img = cv.imread("Mandrill.bmp", cv.IMREAD_COLOR)
cv.imshow("image", img)
H, W, C = img.shape[:] #C는 채널로 3이 들어감. 0=blue, 1=green, 2=red
img2 = np.zeros((H, W, C), img.dtype) #백지 상태
img3 = np.zeros((H, W, C), img.dtype)
img4 = np.zeros((H, W, C), img.dtype)
h, w, c = img.shape
for y in range(h):
for x in range(w):
for c in range(3):
if(c==0) : #c가 0일때 blue 이므로, blue 값만 추출
img2[y, x, c] = img[y, x, c]
if(c==1) :#c가 1일때 green 이므로, green 값만 추출
img3[y, x, c] = img[y, x, c]
if(c==2) :#c가 2일때 red 이므로, red 값만 추출
img4[y, x, c] = img[y, x, c]
cv.imshow("1911695_B", img2)
cv.imshow("1911695_G", img3)
cv.imshow("1911695_R", img4)
cv.waitKey(0)
import cv2 as cv
import numpy as np
img = cv.imread("rice.bmp", cv.IMREAD_GRAYSCALE)
H, W= img.shape[:]
img_inverse = np.zeros((H, W), img.dtype)
for y in range(H):
for x in range(W):
img_inverse[y,x] = 255 - img[y,x]
cv.imshow("image",img)
cv.imshow("image_inverse", img_inverse)
cv.waitKey(0)