Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Fourier Transform | Image Processing with OpenCV
Applied Computer Vision
セクション 2.  2
single

single

bookFourier Transform

メニューを表示するにはスワイプしてください

Note
Definition

The Fourier transform (FT) is a fundamental mathematical tool used in image processing to analyze the frequency components of an image.

It allows us to transform an image from the spatial domain (where pixel values are represented directly) to the frequency domain (where we analyze patterns and structures based on their frequency). This is useful for tasks like image filtering, edge detection, and noise reduction.

First, we need to convert the image to grayscale:

gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
Note
Note

We used COLOR_BGR2GRAY because images are primarily read in BGR format, which is the reverse of RGB.

To compute the 2D Fourier transform:

dft = np.fft.fft2(image)
dft_shift = np.fft.fftshift(dft)

Here, fft2() converts the image from the spatial domain to the frequency domain, and fftshift() moves low-frequency components to the center.

To visualize the magnitude spectrum:

magnitude_spectrum = 20 * np.log(np.abs(dft_shift))

Since Fourier transform outputs complex numbers, we take the absolute values (np.abs()) for a meaningful visualization.

The np.log function enhances visibility, as raw magnitude values vary greatly in scale.

タスク

スワイプしてコーディングを開始

You are given an image:

  • Convert image to grayscale and store in gray_image variable;
  • Apply Fourier transform to the gray_image and stote in dft variable;
  • Make zero frequency shift to center and store the result in dft_shift variable;
  • Calculate a magnitude spectrum and store in magnitude_spectrum variable.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 2.  2
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt