Professional Documents
Culture Documents
p02 m0517004 Ahmad Sabilil Maromi
p02 m0517004 Ahmad Sabilil Maromi
p02 m0517004 Ahmad Sabilil Maromi
In [23]:
In [3]:
img = data.camera()
io.imshow(img, cmap='gray')
Out[3]:
<matplotlib.image.AxesImage at 0x7fb836341748>
In [7]:
sobel_kernel = np.array([
[-1,0,1],
[-2,0,2],
[-1,0,1]
])
<matplotlib.image.AxesImage at 0x7fb834a174a8>
In [10]:
size = 15
mean_kernel = np.ones((size,size)) / (size*size)
img_mean = conv2d(img, mean_kernel, mode='same')
img_mean = np.clip(img_mean, 0, 255)
io.imshow(img_mean, cmap='gray')
Out[10]:
<matplotlib.image.AxesImage at 0x7fb83479d278>
In [20]:
laplacian_kernel = np.array([
[0, 1, 0],
[1,-4, 1],
[0, 1, 0]
])*-1
io.imshow(enhanced_img, cmap='gray')
Out[20]:
<matplotlib.image.AxesImage at 0x7fb834195fd0>
In [22]:
h, w = img.shape
w_noise = np.random.random((h, w))
b_noise = np.random.random((h, w))
io.imshow(noisy_img, cmap='gray')
Out[22]:
<matplotlib.image.AxesImage at 0x7fb83404d9e8>
In [26]:
<matplotlib.image.AxesImage at 0x7fb82fdb2c50>