¿What distance does Matlab use in the function "fft2"?
9 次查看(过去 30 天)
显示 更早的评论
Is it possible to use Chebyshev's distance?
Here you can see the definition of the distance, it is a particular case of the Minkowski distance, when real number p (greater than or equal to one) has infinity.
I try to determine this with empirical way, but i obtain a strange result...
%We generate the sinusoidal grid of 50 cycles
N = 256 ;
x = 1:N ;
y = 1:N ;
[X,Y] = meshgrid(x,y) ;
I=sin(2*pi*(50*X+50*Y*0)/256)
t=figure; imagesc(I); colormap gray; axis image;
title('Sinusoidal grid of 50 cycles')
exportgraphics(t,'sinusoidal_grid_of_50_cycles.jpg')
%Transform apply the fourier transform,
% we are left with the real part and remove
% the core value
A=real(fftshift(fft2(I)));
A(floor(256/2+1),floor(256/2+1))=0;
t=figure; imagesc(A); colormap gray; axis image;
title('FFT2 of Sinusoidal grid of 50 cycles')
exportgraphics(t,'FFT2_of_sinusoidal_grid_of_50_cycles.jpg')
for i=1:256
for j=1:256
if A(i,j) > 0.1
i
j
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%distance between points to (129,129) %
%(129,79) (129,179) %
% 50 pixels for all p>1 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rotation example number 1 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%We generate the sinusoidal grid of 50 cycles
N = 256 ;
x = 1:N ;
y = 1:N ;
[X,Y] = meshgrid(x,y) ;
J = sin(2*pi*(50*X+50*Y)/256)
t=figure; imagesc(J); colormap gray; axis image;
title('Rotation example number 1')
exportgraphics(t,'rotation_example_number_1.jpg')
%J=imrotate(I,45,'bilinear','crop')
h=size(J,1);
w=size(J,2);
J=real(fftshift(fft2(J)));
J(floor(h/2+1),floor(w/2+1))=0;
t=figure; imagesc(J); colormap gray; axis image;
title('FFT2 of Rotation example number 1')
exportgraphics(t,'FFT2_of_rotation_example_number_1.jpg')
for i=1:256
for j=1:256
if J(i,j) > 0.1
i
j
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%distance between points to (129,129) %
%(79,79) (179,179) %
% 70.71 long pixels (euclidean distance) p=2 %
% 100 long pixels (Manhattan distance) p=1 %
% 50 long pixels p->\infty %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rotation example number 2 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%We generate the sinusoidal grid of 50 cycles
N = 256 ;
x = 1:N ;
y = 1:N ;
[X,Y] = meshgrid(x,y) ;
I=sin(2*pi*(50*X+25*Y)/256)
t=figure; imagesc(I); colormap gray; axis image;
title('Rotation example number 2')
exportgraphics(t,'rotation_example_number_2.jpg')
%Transform apply the fourier transform,
% we are left with the real part and remove
% the core value
A=real(fftshift(fft2(I)));
A(floor(256/2+1),floor(256/2+1))=0;
t=figure; imagesc(A); colormap gray; axis image;
title('FFT2 of Rotation example number 2')
exportgraphics(t,'FFT2_of_rotation_example_number_2.jpg')
for i=1:256
for j=1:256
if A(i,j) > 0.1
i
j
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%distance between points to (129,129) %
%(104,79) (154,179) %
% 55.9 long pixels (euclidean distance) p=2 %
% 75 long pixels (Manhattan distance) p=1 %
% 50 long pixels p->\infty %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%sqrt((154-129).^2+(179-129).^2)
%sqrt((104-129).^2+(79-129).^2)
%abs(154-129)+abs(179-129)
%abs(154-129)+abs(179-129)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rotation example number 3 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%We generate the sinusoidal grid of 50 cycles
N = 256 ;
x = 1:N ;
y = 1:N ;
[X,Y] = meshgrid(x,y) ;
% I'm not sure if this function is correct,
I=sin(2*pi*(50*X+8*Y)/256)
t=figure; imagesc(I); colormap gray; axis image;
title('Rotation example number 3')
exportgraphics(t,'rotation_example_number_3.jpg')
%Transform apply the fourier transform,
% we are left with the real part and remove
% the core value
A=real(fftshift(fft2(I)));
A(floor(256/2+1),floor(256/2+1))=0;
t=figure; imagesc(A); colormap gray; axis image;
title('FFT2 of Rotation example number 3');
exportgraphics(t,'FFT2_of_rotation_example_number_3.jpg')
for i=1:256
for j=1:256
if A(i,j) > 0.1
i
j
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%distance between points to (129,129) %
%(121,79) (137,179) %
% 50.63 long pixels (euclidean distance) p=2 %
% 58 long pixels (Manhattan distance) p=1 %
% 50 long pixels p->\infty %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%sqrt((121-129).^2+(79-129).^2)
%sqrt((137-129).^2+(179-129).^2)
%abs(121-129)+abs(79-129)
%abs(137-129)+abs(179-129)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Answer: if there is nothing wrong it seems %
% that the distance used is the %
% Minkowski distance p -> infty %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
回答(1 个)
Matt J
2021-8-7
编辑:Matt J
2021-8-7
fft2 implements the Discrete Fourier Transform, not the continuous one. Therefore, the choice of distance is irrelevant.
2 个评论
Walter Roberson
2021-8-7
Distance does not apply even to continuous Fourier Transform as far as I can see.
Matt J
2021-8-7
编辑:Matt J
2021-8-7
@Walter Roberson The infinite integral required to compute a continuous Fourier Transform will not generally converge with respect to all distance metrics. For instance, sinc(t) is not absolutely integrable, but it is square integrable.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!