首页 > 解决方案 > 图像的二维傅里叶变换的 Matlab 错误

问题描述

我编写了一个实现 fft2 命令的程序,以获取图像的傅立叶变换以及其他更改,并且我不断收到以下输出错误: fft2 中的错误(第 17 行) F=fft2(imdata); 下面是我的这个程序的代码。我还以另一种方式编写了程序,并且对相同的功能有相同的错误。

close all; clc
imdata = imread('BluOrn Star.jpg');
figure(1);
imshow(imdata); 
originalRGBImage = imdata; % Save original image for later display in figure (7)
title('Original Image');
imdata = rgb2gray(imdata);
figure(2); 
imshow(imdata); 
title('Gray Image');
%Get Fourier Transform of an image
F = fft2(imdata);
% Fourier transform of an image
S = abs(F);
figure(3);
imshow(S,[]);
title('Fourier transform of an image');
%get the centered spectrum
Fsh = fftshift(F);
figure(4);imshow(abs(Fsh),[]);
title('Centered fourier transform of Image')
%apply log transform
S2 = log(1+abs(Fsh));
figure(5);imshow(S2,[]);
title('log transformed Image')
%reconstruct the Image
F = ifftshift(Fsh);
f = ifft2(F);
figure(6);imshow(f,[]),
title('reconstructed Image')
h7 = figure(7);
imshow(originalRGBImage);

错误代码:

Attempt to execute SCRIPT fft2 as a function:
/MATLAB Drive/fft2.m
Error in FFT2Image (line 13)
F = fft2(imdata); 
>> 

标签: matlab2dfft

解决方案


推荐阅读