??? Undefined function or method 'fftshow' for input arguments of type 'double'.
19 次查看(过去 30 天)
显示 更早的评论
Error ??? Undefined function or method 'fftshow' for input arguments of type 'double'.
when trying to display the image
c=imread('cameraman.tif');
cf=fftshift(fft2(c));
fftshow(cf,'abs')
or fftshow(cf,'log');
both are showing the same error how to overcome this
0 个评论
回答(6 个)
Wayne King
2012-5-22
What is fftshow.m ? That is not a MathWorks' function or method. If you have downloaded this MATLAB program from somewhere and saved it in a folder, then make sure you add that folder to the MATLAB search path with addpath or use pathtool.
0 个评论
Walter Roberson
2012-6-14
3 个评论
Steven Lord
2021-11-23
The code to call ifft is just ifft(). You need to fill in the input arguments to ifft inside those parentheses.
If you're asking to see the source code that implements ifft we do not distribute the source code for it. If you really want to see it start here.
Kumar Vaibhav
2016-8-11
The error is due to fftshow function, which is not inbuilt function of MATLAB. You can find fftshow function in the link given below:
2 个评论
yanqi liu
2021-2-20
sir, may be use the follow code
clc; clear all; close all;
c=imread('cameraman.tif');
cf=fftshift(fft2(c));
figure;
fftshow(cf,'abs')
figure;
fftshow(cf,'log');
function fftshow(f,type)
% from:https://ww2.mathworks.cn/matlabcentral/fileexchange/30947-gaussian-bandpass-filter-for-image-processing
% Usage: FFTSHOW(F,TYPE)
%
% Displays the fft matrix F using imshow, where TYPE must be one of
% 'abs' or 'log'. If TYPE='abs', then then abs(f) is displayed; if
% TYPE='log' then log(1+abs(f)) is displayed. If TYPE is omitted, then
% 'log' is chosen as a default.
%
% Example:
% c=imread('cameraman.tif');
% cf=fftshift(fft2(c));
% fftshow(cf,'abs')
%
if nargin<2,
type='log';
end
if (type=='log')
fl = log(1+abs(f));
fm = max(fl(:));
imshow(im2uint8(fl/fm))
elseif (type=='abs')
fa=abs(f);
fm=max(fa(:));
imshow(fa/fm)
else
error('TYPE must be abs or log.');
end
end
2 个评论
Reham bun
2021-2-20
编辑:Reham bun
2021-2-20
Sorry, i want to implement Gaussian low pass filter for this image, I used this code (ifftshow) for the inverted fftshow but it didn't work with me because the file is not found.
Here's my code
a=imread('Fig0441(a).tif')
whos a
g=fspecial('gaussian',688,10);
max(g(:));
g1=mat2gray(g);
max(g1(:));
f=fftshift(fft2(a));
i=f.*g1;
fftshow(i)
f1=ifft2(i);
yanqi liu
2021-2-20
sir, please copy to one m file, like follows
clc; clear all; close all;
a=imread('Fig0441(a).tif');
% whos a
g=fspecial('gaussian',688,10);
if ndims(a) > 2
a = rgb2gray(a);
end
if ~isequal(size(a), size(g))
a = imresize(a, size(g), 'bilinear');
end
max(g(:));
g1=mat2gray(g);
max(g1(:));
f=fftshift(fft2(a));
i=f.*g1;
fftshow(i)
f1=ifft2(i);
figure; imshow(f1, []);
function fftshow(f,type)
% from:https://ww2.mathworks.cn/matlabcentral/fileexchange/30947-gaussian-bandpass-filter-for-image-processing
% Usage: FFTSHOW(F,TYPE)
%
% Displays the fft matrix F using imshow, where TYPE must be one of
% 'abs' or 'log'. If TYPE='abs', then then abs(f) is displayed; if
% TYPE='log' then log(1+abs(f)) is displayed. If TYPE is omitted, then
% 'log' is chosen as a default.
%
% Example:
% c=imread('cameraman.tif');
% cf=fftshift(fft2(c));
% fftshow(cf,'abs')
%
if nargin<2,
type='log';
end
if (type=='log')
fl = log(1+abs(f));
fm = max(fl(:));
imshow(im2uint8(fl/fm))
elseif (type=='abs')
fa=abs(f);
fm=max(fa(:));
imshow(fa/fm)
else
error('TYPE must be abs or log.');
end
end
0 个评论
Raghunathan P
2021-4-7
It is another library instead you can use this code:
c=imread('cameraman.tif');
cf=fftshift(fft2(c));
fl = log(1+abs(cf)); % Your DFT matrix of image 'cf' wil come HERE
fm = max(fl(:));
imshow(im2uint8(fl/fm))
or for advanced
function fftshow(f,type)
% Usage: FFTSHOW(F,TYPE)
%
% Displays the fft matrix F using imshow, where TYPE must be one of
% 'abs' or 'log'. If TYPE='abs', then then abs(f) is displayed; if
% TYPE='log' then log(1+abs(f)) is displayed. If TYPE is omitted, then
% 'log' is chosen as a default.
%
% Example:
% c=imread('cameraman.tif');
% cf=fftshift(fft2(c));
% fftshow(cf,'abs')
if nargin<2,
type='log';
end
if (type=='log')
fl = log(1+abs(f)); % Your matrix 'cf' wil come HERE instead of 'f'
fm = max(fl(:));
imshow(im2uint8(fl/fm))
elseif (type=='abs')
fa=abs(f);
fm=max(fa(:));
imshow(fa/fm)
else
error('TYPE must be abs or log.');
end;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!