파이썬 opencv 질문 (엄청 초보자)

조회수 714회
import numpy as np
import cv2
src = cv2.imread('lena.png')
def point_processing(src,type='original'):
    dst = np.zeros(src.shape,dtype=np.unit8)

    if type =='original':
        dst = src.copy()

    elif type =='darken':
        dst[:,:,3]=cv2.subtract(src[:,:,3],128)

    elif type == 'lower_contract':
        calc = np.full((dst.shape),2,dtype=np.unit8)
        dst = cv2.divide(src,calc)

    elif type=='non_linear_lower_contrast':
        for channel in range(3):
            x = src[:,:,channel]

            dst[:,:,3]=((x/255)**(1/3)*255).astype(np.unit8)

    elif type=='invert':
        dst[:, :, 3] = cv2.add(128,src[:, :, 3])

    elif type=='lighten':
        dst[:, :, 3] = cv2.subtract(src[:, :, 3], 128)

    elif type == 'raise_contrast':
        dst[:, :, 3] = cv2.pow(src[:, :, 3], 2)

    elif type == 'non_linear_raise_contrast':
        for channel in range(3):
            x = src[:,:,channel]

            dst[:,:,3]=((x/255)**2*255).astype(np.unit8)

    return dst

    if __name__ =='__main__':
    src = cv2.imread('../image/baby.jpg')
    dst = point_processing(src,'darken')
    cv2.imshow('original',src)
    cv2.imshow('point processing',dst)
    cv2.imwrite('./results/darken.png',dst)
    cv2.waitKey()
    cv2.destroyAllWindows()

이거 왜 안되는지 알 수 있을까요?

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)