MATLAB 中图像的正向和逆向傅里叶变换


在数学中,傅里叶变换是一种用于将函数或信号从时域转换为频域的数学工具。它广泛应用于信号处理、通信、图像处理和分析等领域。

在使用 MATLAB 查找图像的正向和逆向傅里叶变换之前,让我们先简要概述一下傅里叶变换及其逆变换。

正向傅里叶变换

傅里叶变换或正向傅里叶变换是一种数学运算,用于将信号从时域转换为频域。

因此,正向傅里叶变换以其频率成分来表示信号。当我们对信号执行正向傅里叶变换时,它会生成一个复值函数,该函数表示输入信号在不同频率下的幅度和相位。

在数学上,时域信号“x(t)”的傅里叶变换定义为:

X(ω)=x(t)ejωtdt

其中,X(ω) 是 x(t) 的傅里叶变换。

现在,让我们讨论逆傅里叶变换。

逆傅里叶变换

逆傅里叶变换是正向傅里叶变换的反向操作。它被定义为一种数学运算,将频域信号转换为时域信号。

在信号处理中,它主要用于从变换后的信号重建原始信号。

在数学上,频域信号的逆傅里叶变换可以定义为:

x(t)=12πX(ω)ejωtdω

这里,x(t) 是从其傅里叶变换版本重建的信号。

这就是关于正向傅里叶变换和逆正向傅里叶变换的所有内容。现在让我们讨论如何使用 MATLAB 查找图像的正向和逆向傅里叶变换。

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

使用 MATLAB 进行图像的正向傅里叶变换

在 MATLAB 中,我们可以使用“fft2”函数来执行图像的正向傅里叶变换。下面解释了使用 MATLAB 查找图像的正向傅里叶变换的分步过程

步骤 (1) – 读取原始输入图像,并在需要时将其转换为灰度图像。

步骤 (2) – 使用“fft2”函数执行图像的傅里叶变换。

步骤 (3) – 使用“fftshift”函数将傅里叶变换从角点移到中心。

步骤 (4) – 取移位傅里叶变换的绝对值以计算其幅度谱。

步骤 (5) – 显示傅里叶变换的幅度谱。

示例

现在,让我们考虑一个 MATLAB 中的示例程序,以便更好地理解这个概念。

% MATLAB code to find forward Fourier transform of an image % Read the original input image img = imread('https://tutorialspoint.com/assets/questions/media/14304-1687425236.jpg'); % Convert the input image to grayscale gray_img = rgb2gray(img); % Calculate Fourier Transform of the image FT = fftshift(fft2(gray_img)); % Calculate the magnitude spectrum of Fourier transform mag_spect = abs(FT); % Take the log of magnitude spectrum mag_spect_log = log(1 + mag_spect); % Adding 1 to avoid log(0) % Display the magnitude spectrum of the Fourier transform figure; subplot(1, 2, 1); imshow(mag_spect, []); title('Magnitude Spectrum of FT'); subplot(1, 2, 2); imshow(mag_spect_log, []); title('Log Magnitude Spectrum of FT'); colormap(gca, 'jet'); colorbar;

输出

这就是我们如何在 MATLAB 中查找图像的正向傅里叶变换的方法。现在,让我们学习如何查找图像的逆傅里叶变换。

使用 MATLAB 进行图像的逆傅里叶变换

MATLAB 提供了一个内置函数“ifft2”来查找函数或信号的逆傅里叶变换。

在这里,我们解释了使用 MATLAB 查找图像的逆傅里叶变换的分步过程

步骤 (1) – 读取傅里叶变换后的图像。

步骤 (2) – 应用“ifft2”函数查找逆傅里叶变换后的图像。

步骤 (3) – 取逆傅里叶变换后图像的绝对值的 log 值。

步骤 (4) – 显示逆傅里叶变换后的图像。

示例

以下示例程序演示了这些步骤的实际实现,以使用 MATLAB 查找图像的逆傅里叶变换。

% MATLAB code to perform Inverse Fourier Transform of an image % Read the original input image img = imread('https://tutorialspoint.com/assets/questions/media/14304-1687425236.jpg'); % Convert the input image to grayscale gray_img = rgb2gray(img); % Calculate Fourier Transform of the image FT = fftshift(fft2(gray_img)); % Find inverse Fourier Transform of the Fourier transformed image inverse_FT_img = ifft2(ifftshift(FT)); % FT is the Fourier transformed image % Take the log of the absolute value of the inverse transformed image inverse_FT_img_log = log(abs(inverse_FT_img)); % Display the original, log-transformed, and inverse transformed images subplot(2, 2, 1); imshow(gray_img); title('Original Image'); subplot(2, 2, 2); imshow(inverse_FT_img_log, []); title('Log Inverse Transformed Image'); subplot(2, 2, 3); imshow(abs(inverse_FT_img), []); title('Inverse Transformed Image');

输出

这就是我们如何在 MATLAB 中通过遵循简单的步骤查找图像的逆傅里叶变换的方法。

结论

在本教程中,我们解释了傅里叶变换 (FT) 和逆傅里叶变换 (IFT) 的概念。我们还通过示例程序解释了如何在 MATLAB 中查找正向傅里叶变换和逆傅里叶变换。您可以使用自己的图像尝试以上代码来查找它们的 FT 和 IFT。

更新于: 2023-09-07

495 次查看

开启您的 职业生涯

通过完成课程获得认证

开始学习
广告