¿What distance does Matlab use in the function "fft2"?
이전 댓글 표시
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
Rena Berman
2021년 9월 23일
(Answers Dev) Restored edit
답변 (1개)
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.
@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.
카테고리
도움말 센터 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!