-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.py
More file actions
58 lines (45 loc) · 1.04 KB
/
3.py
File metadata and controls
58 lines (45 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from PIL import Image
from numpy import *
from pylab import *
from scipy.ndimage import filters
from scipy import misc
im = array(Image.open('resize_dorm.jpg').convert('L'))
im1 = zeros(im.shape)
im1 = filters.gaussian_filter(im, 4)
im2 = 1.0*im1-im
im3 = clip(im - 1*im2, 0, 255)
figure(figsize=(16, 16))
gray()
subplot(2, 2, 1)
title('original')
imshow(uint8(im))
subplot(2, 2, 2)
title('LPF image')
imshow(uint8(im1))
subplot(2, 2, 3)
title('Unsharp mask')
imshow(uint8(im2+128))
subplot(2, 2, 4)
title('sharpened image')
imshow(uint8(im3))
show()
im = array(Image.open('resize_dorm.jpg'))
im1 = zeros(im.shape)
for i in range(3):
im1[:, :, i] = filters.gaussian_filter(im[:, :, i], 4)
im2 = 1.0*im1-im
im3 = uint8(clip(im - 1*im2, 0, 255))
figure(figsize=(16, 16))
subplot(2, 2, 1)
title('original')
imshow(im)
subplot(2, 2, 2)
title('LPF image')
imshow(uint8(im1))
subplot(2, 2, 3)
title('Unsharp mask')
imshow(uint8(im2))
subplot(2, 2, 4)
title('sharpened image')
imshow(im3)
show()