??? Undefined function or method 'fftshow' for input arguments of type 'double'.

7 次查看(过去 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

回答(6 个)

Wayne King
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.

Walter Roberson
Walter Roberson 2012-6-14
  3 个评论
Steven Lord
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
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:

yanqi liu
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
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
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

Raghunathan P
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;

类别

Help CenterFile Exchange 中查找有关 Time-Frequency Analysis 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by