Python Computer Vision Tutorials — Image Fourier Transform / part 2.1 (Fourier Transform in Python)

wsh
3 min readFeb 28, 2019

CONTENTS LIST

CONTENTS LIST

Introduction

In the previous post, I showed you what is Fourier Transform of an image and what we can do with it. It is a fundamental technique in computer vision.
In this post, I’m going to show you how to actually apply Fourier Transform with cv2 or numpy.

After that, I show you which module is suitable for this purpose.

Image Fourier Transform with cv2

We first load an image and pick up one color channel, on which we apply Fourier Transform. The transform is done simply with cv2.dft() function. Here, “dft” means “discrete fourier transform”, since an image is a collection discrete values, not continuous ones.

img = cv2.imread('terrorist.jpg') # load an image
img = img[:,:,2] # blue channel
plt.imshow(img, cmap='gray')
This is a gray scale image, which has shape (778, 1183)
f = cv2.dft(np.float32(img)…

--

--

Responses (1)