2D FFT interpolation - Keeping the amplitude

37 visualizaciones (últimos 30 días)
canadarunner
canadarunner el 7 de Ag. de 2023
Comentada: canadarunner el 7 de Ag. de 2023
% input
matrix = [1.41 + 0.31i,-0.480 + 1.47i,-1.67 + 2.23i,-2.38 + 2.02i,-2.07 + 1.47i,-1.11 + 0.34i,-0.0900 - 0.65i,0.700 - 0.79i,1.14 - 0.36i;...
0.180 - 0.10i,-1.22 + 0.51i,-1.66 + 0.86i,-0.590 + 0.070i,0.410 + 0.070i,0.0300 + 0.99i,-0.300 + 0.67i,0.430 + 0.23i,0.640 + 0.09i;...
2.11 - 1.18i,0.350 - 1.01i,-0.850 - 0.84i,-0.200 - 1.74i,1.29 - 1.62i,1.59 - 0.16i,1.40 - 0.16i,1.65 - 0.36i,1.53 + 0.13i;...
0.990 - 2.39i,1.40 - 1.85i,4.22 - 0.01i,6.95 + 1.01i,6.11 + 0.90i,3.04 + 0.17i,1.06 - 0.34i,0.640 - 0.98i,0.900 - 0.71i;...
1.07 - 2.58i,1.73 - 0.80i,8.23 + 3.39i,16.28 + 7.73i,15.16 + 8.35i,6.40 + 4.22i,0.350 + 0.79i,-0.610 - 0.46i,-0.200 - 0.27i;...
1.73 - 1.20i,-0.200 + 0.94i,0.170 + 3.56i,3.85 + 5.13i,4.89 + 5.21i,2.14 + 2.96i,0.0300 + 0.12i,0.190 - 0.71i,0.470 + 0.19i;...
2.48 - 0.46i,1.02 + 1.28i,-1.16 + 2.32i,-1.67 + 1.71i,-0.890 + 0.55i,-0.100 + 0.21i,0.270 - 0.34i,0.710 - 0.57i,0.930 - 0.17i;...
2.01 + 3.41i,2.02 + 2.68i,-0.130 + 2.40i,-1.26 + 1.97i,-1.21 + 2.15i,0.0600 + 1.64i,1.06 + 0.88i,0.620 + 0.58i,-0.0500 + 0.31i;...
-0.230 + 7.51i,0.400 + 2.68i,-0.760 + 1.70i,-1.46 + 1.57i,-2.02 + 1.70i,-1.42 + 1.35i,0.00 + 1.16i,-0.330 + 0.86i,-1.19 + 0.56i];
% 2d FFT interpolation
interpol_size = 100;
k = fft2(matrix);
k = fftshift(k);
k_scale = padarray(k,[interpol_size,interpol_size]/2,'both');
k_scale = ifftshift(k_scale);
k_interpol = ifft2(k_scale);
% plot
tiledlayout(1,2)
nexttile
imagesc(abs(matrix))
colorbar
cb = colorbar;
cb.Label.String = "power (10*log10(abs(x))) [dB]";
title('original')
axis square
nexttile
imagesc(10*log10(abs(k_interpol)))
colorbar
cb = colorbar;
cb.Label.String = "power (10*log10(abs(x))) [dB]";
title('2Dfft interpolated')
axis square
I tried to interpolate the original data with a 2d fft, but afterwards unfortunately I don't get the same amplitude values. Altough I expect the values to be equal or bigger than the original based on the sampling theory.
I checked https://ch.mathworks.com/matlabcentral/answers/1900240-effect-of-zero-padding-on-fft-amplitude?s_tid=sug_su , but unfortunately I don't get it do extrapolate the information there into the multidimensional space (in my case 2d).
I know that interpft should work, but this works just in 1d.

Respuesta aceptada

Paul
Paul el 7 de Ag. de 2023
Hi canadarunner,
The plot on the left is amplitude and the plot on the right is in dB. Changing the left plot to dB brings the plots closer.
In the same units, would you expect the values in the plot on the left to be larger?
Scaling the interpolated values by the numel(k_interpol)/numel(matrix) would then bring the two plots into alignment. I don't think that's a coincidence, but would have to give more thought to justify doing so.
% input
matrix = [1.41 + 0.31i,-0.480 + 1.47i,-1.67 + 2.23i,-2.38 + 2.02i,-2.07 + 1.47i,-1.11 + 0.34i,-0.0900 - 0.65i,0.700 - 0.79i,1.14 - 0.36i;...
0.180 - 0.10i,-1.22 + 0.51i,-1.66 + 0.86i,-0.590 + 0.070i,0.410 + 0.070i,0.0300 + 0.99i,-0.300 + 0.67i,0.430 + 0.23i,0.640 + 0.09i;...
2.11 - 1.18i,0.350 - 1.01i,-0.850 - 0.84i,-0.200 - 1.74i,1.29 - 1.62i,1.59 - 0.16i,1.40 - 0.16i,1.65 - 0.36i,1.53 + 0.13i;...
0.990 - 2.39i,1.40 - 1.85i,4.22 - 0.01i,6.95 + 1.01i,6.11 + 0.90i,3.04 + 0.17i,1.06 - 0.34i,0.640 - 0.98i,0.900 - 0.71i;...
1.07 - 2.58i,1.73 - 0.80i,8.23 + 3.39i,16.28 + 7.73i,15.16 + 8.35i,6.40 + 4.22i,0.350 + 0.79i,-0.610 - 0.46i,-0.200 - 0.27i;...
1.73 - 1.20i,-0.200 + 0.94i,0.170 + 3.56i,3.85 + 5.13i,4.89 + 5.21i,2.14 + 2.96i,0.0300 + 0.12i,0.190 - 0.71i,0.470 + 0.19i;...
2.48 - 0.46i,1.02 + 1.28i,-1.16 + 2.32i,-1.67 + 1.71i,-0.890 + 0.55i,-0.100 + 0.21i,0.270 - 0.34i,0.710 - 0.57i,0.930 - 0.17i;...
2.01 + 3.41i,2.02 + 2.68i,-0.130 + 2.40i,-1.26 + 1.97i,-1.21 + 2.15i,0.0600 + 1.64i,1.06 + 0.88i,0.620 + 0.58i,-0.0500 + 0.31i;...
-0.230 + 7.51i,0.400 + 2.68i,-0.760 + 1.70i,-1.46 + 1.57i,-2.02 + 1.70i,-1.42 + 1.35i,0.00 + 1.16i,-0.330 + 0.86i,-1.19 + 0.56i];
% 2d FFT interpolation
interpol_size = 100;
k = fft2(matrix);
k = fftshift(k);
k_scale = padarray(k,[interpol_size,interpol_size]/2,'both');
k_scale = ifftshift(k_scale);
k_interpol = ifft2(k_scale);
% plot
tiledlayout(1,2)
nexttile
%imagesc(abs(matrix))
imagesc(10*log10(abs(matrix)))
colorbar
cb = colorbar;
cb.Label.String = "power (10*log10(abs(x))) [dB]";
title('original')
axis square
nexttile
imagesc(10*log10(abs(k_interpol)))
colorbar
cb = colorbar;
cb.Label.String = "power (10*log10(abs(x))) [dB]";
title('2Dfft interpolated')
axis square
  1 comentario
canadarunner
canadarunner el 7 de Ag. de 2023
@Paul - ahh I had the power plot in my original code right, but thank you very much for the scaling! Absolutely what I needed. So my final solution is:
% input
matrix = [1.41 + 0.31i,-0.480 + 1.47i,-1.67 + 2.23i,-2.38 + 2.02i,-2.07 + 1.47i,-1.11 + 0.34i,-0.0900 - 0.65i,0.700 - 0.79i,1.14 - 0.36i;...
0.180 - 0.10i,-1.22 + 0.51i,-1.66 + 0.86i,-0.590 + 0.070i,0.410 + 0.070i,0.0300 + 0.99i,-0.300 + 0.67i,0.430 + 0.23i,0.640 + 0.09i;...
2.11 - 1.18i,0.350 - 1.01i,-0.850 - 0.84i,-0.200 - 1.74i,1.29 - 1.62i,1.59 - 0.16i,1.40 - 0.16i,1.65 - 0.36i,1.53 + 0.13i;...
0.990 - 2.39i,1.40 - 1.85i,4.22 - 0.01i,6.95 + 1.01i,6.11 + 0.90i,3.04 + 0.17i,1.06 - 0.34i,0.640 - 0.98i,0.900 - 0.71i;...
1.07 - 2.58i,1.73 - 0.80i,8.23 + 3.39i,16.28 + 7.73i,15.16 + 8.35i,6.40 + 4.22i,0.350 + 0.79i,-0.610 - 0.46i,-0.200 - 0.27i;...
1.73 - 1.20i,-0.200 + 0.94i,0.170 + 3.56i,3.85 + 5.13i,4.89 + 5.21i,2.14 + 2.96i,0.0300 + 0.12i,0.190 - 0.71i,0.470 + 0.19i;...
2.48 - 0.46i,1.02 + 1.28i,-1.16 + 2.32i,-1.67 + 1.71i,-0.890 + 0.55i,-0.100 + 0.21i,0.270 - 0.34i,0.710 - 0.57i,0.930 - 0.17i;...
2.01 + 3.41i,2.02 + 2.68i,-0.130 + 2.40i,-1.26 + 1.97i,-1.21 + 2.15i,0.0600 + 1.64i,1.06 + 0.88i,0.620 + 0.58i,-0.0500 + 0.31i;...
-0.230 + 7.51i,0.400 + 2.68i,-0.760 + 1.70i,-1.46 + 1.57i,-2.02 + 1.70i,-1.42 + 1.35i,0.00 + 1.16i,-0.330 + 0.86i,-1.19 + 0.56i];
% 2d FFT interpolation
interpol_size = 100;
k = fft2(matrix);
k = fftshift(k);
k_scale = padarray(k,[interpol_size,interpol_size]/2,'both');
k_scale = ifftshift(k_scale);
k_interpol = ifft2(k_scale);
k_interpol = k_interpol*numel(k_interpol)/numel(matrix);
% plot
tiledlayout(1,2)
nexttile
%imagesc(abs(matrix))
imagesc(10*log10(abs(matrix)))
colorbar
cb = colorbar;
cb.Label.String = "power (10*log10(abs(x))) [dB]";
title('original')
axis square
nexttile
imagesc(10*log10(abs(k_interpol)))
colorbar
cb = colorbar;
cb.Label.String = "power (10*log10(abs(x))) [dB]";
title('2Dfft interpolated')
axis square
clim([min(10*log10(abs(matrix(:)))),max(10*log10(abs(matrix(:))))])

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by