Image in Frequency Domain


By Prof. Seungchul Lee
http://iai.postech.ac.kr/
Industrial AI Lab at POSTECH

Source

  • An Introduction to Digital Image Processing with MATLAB
  • by Alasdair McAndrew at Victoria University of Technology

Table of Contents

0. Filter on Images

0.1. Linear System: Convolution

  • Computational photography at Gatech
In [1]:
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
import cv2
from skimage.util import random_noise

%matplotlib inline
In [ ]:
from google.colab import drive
drive.mount('/content/drive')
In [2]:
# noise image

img = cv2.imread('/content/drive/MyDrive/Colab Notebooks/data_files/lena_sigma25.png', 0)

print(img.shape)

plt.figure(figsize = (10,6))

plt.imshow(img, cmap = 'gray')
plt.axis('off')
plt.show()
(512, 512)
In [3]:
M = np.ones([3,3])/9
print(M)
[[0.11111111 0.11111111 0.11111111]
 [0.11111111 0.11111111 0.11111111]
 [0.11111111 0.11111111 0.11111111]]
In [4]:
# smoothing or noise reduction

img_conv = signal.convolve2d(img, M, 'valid')

plt.figure(figsize = (10,6))

plt.subplot(1,2,1)
plt.imshow(img, cmap = 'gray')
plt.title('Noisy Image')
plt.axis('off')

plt.subplot(1,2,2)
plt.imshow(img_conv, cmap = 'gray')
plt.title('Smoothed Image')
plt.axis('off')

plt.show()
In [5]:
# original image

img = cv2.imread('/content/drive/MyDrive/Colab Notebooks/data_files/lena.png', 0)

plt.figure(figsize = (10,6))

plt.imshow(img, cmap = 'gray')
plt.axis('off')
plt.show()