이영훈
1 +import cv2
2 +import numpy as np
3 +from PIL import Image
4 +from PIL import ImageFilter
5 +
6 +img= cv2.imread('Lenna.png')
7 +cv2.imshow('Original',img)
8 +output = img
9 +
10 +"""
11 +#Blur_gaussian
12 +output = cv2.GaussianBlur(img,(5,5),1)
13 +cv2.imshow('BlurGaussian',output)
14 +cv2.imwrite('BlurGaussian.png',output)
15 +"""
16 +
17 +"""
18 +#Blur
19 +size = 3
20 +kernel_motion_blur = np.zeros((size,size))
21 +kernel_motion_blur[int((size-1)/2),:] = np.ones(size)
22 +kernel_motion_blur = kernel_motion_blur / size
23 +
24 +output = cv2.filter2D(img,-1,kernel_motion_blur)
25 +cv2.imshow('Blur',output)
26 +cv2.imwrite('Blur.png',output)
27 +"""
28 +
29 +#Sharpening
30 +kernel_sharpen_1 = np.array([[-1,-1,-1],[-1,9,-1],[-1,-1,-1]])
31 +#kernel_sharpen_2 = np.array([[1,1,1],[1,-7,1],[1,1,1]])
32 +#kernel_sharpen_3 = np.array([[-1,-1,-1,-1,-1],[-1,2,2,2,-1],[-1,2,8,2,-1],[-1,2,2,2,-1],[-1,-1,-1,-1,-1]])/8.0
33 +
34 +output_1 = cv2.filter2D(output,-1,kernel_sharpen_1)
35 +#output_2 = cv2.filter2D(img,-1,kernel_sharpen_2)
36 +#output_3 = cv2.filter2D(img,-1,kernel_sharpen_3)
37 +
38 +
39 +cv2.imshow('Sharpening',output_1)
40 +#cv2.imshow('Excessive Sharpening',output_2)
41 +#cv2.imshow('Edge Enhancement',output_3)
42 +cv2.imwrite('Sharpening.png',output_1)
43 +
44 +img = cv2.imread('input2.png')
45 +
46 +img_yuv = cv2.cvtColor(output_1, cv2.COLOR_BGR2YUV)
47 +img_yuv[:,:,0] = cv2.equalizeHist(img_yuv[:,:,0])
48 +img_output = cv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)
49 +cv2.imshow('histogram_equalization',img_output)
50 +cv2.imwrite('histogram_equalization.png',img_output)
51 +cv2.waitKey()
52 +
53 +
54 +
No preview for this file type