[opencv 자습노트] 06: 고스 모호

991 단어 필기
가고스 소음, 고스 모호
import cv2 as cv
import numpy as np

#  ,   
def decorate_time(func):
    def wrapper(src):
        t1=cv.getTickCount()
        func(src)
        t2=cv.getTickCount()
        print('time used %f'%((t2-t1)/cv.getTickFrequency()))
    return wrapper


def clamp(pv):
    if pv>255:
        return 255
    elif pv<0:
        return 0
    else:
        return pv

@decorate_time
def gussian_noise(image):
    h,w,ch=image.shape
    for row in range(h):
        for col in range(w):
            for c in range(ch):
                image[row,col,c]=clamp(image[row,col,c]+np.random.normal(0,20))
    cv.imshow('gussian_noise',image)


src=cv.imread("D:/Study/opencv/code/1.jpg")
cv.imshow('src',src)

gussian_noise(src)
#dst=cv.GaussianBlur(src,(0,0),15)  #     
dst=cv.GaussianBlur(src,(5,5),0)#  ksize    sigmaX,  sigmaX    ksize,      0
cv.imshow('Gussian Blur',dst)
cv.waitKey(0)
cv.destroyAllWindows()

좋은 웹페이지 즐겨찾기