Problem with 2D fftshift

6 views (last 30 days)
Latifa Bouguessaa
Latifa Bouguessaa on 6 Nov 2022
Hello, everyone,
I hope you can help me
i have a problem with 2d fftshift.
I have to get the noise power spectrum from 18 Rois. I use fftshift but in the center of the picture are higher frequencies that don't belong. as far as i know there are zero frequencies in the middle. can someone help me with this problem.
My Code:---------------------------------------------------------------------------------------------------
clear all
close all
S = load('matlab.mat');
b= cell2mat(struct2cell(S));
[l m n]=size(b);
mm =mean(b,3);
figure(1)
subplot(1,3,1)
imshow(mm,'DisplayRange',[]);title('Original Image');
for i=1:n
spe1(:,:,i)= fftshift(fftn(b(:,:,i)-mm));
spe(:,:,i)=(abs(spe1(:,:,i)).^2);
end
w = (mean(spe,3));
subplot(1,3,2)
imshow(w,'DisplayRange',[]);
title('DFT');
%Radial average
[XX, YY] = meshgrid( (1:m)-m/2, (1:m)-m/2);
R = sqrt(XX.^2 + YY.^2);
profile = [];
for i = 1:1:(m+1)
mask = (i-1<R & R<i+1);
values = w(mask);
profile(i)= mean( values(:) );
end
%Frequenz
frequency=(1/((m)*0.68));
sumb=0:frequency:(((m))*frequency);
subplot(1,3,3)
plot(sumb, profile, '-')
xlabel('Spatial Frquency mm^-1')
ylabel('Noise power spectrum HU^2 mm^2')

Answers (0)

Community Treasure Hunt

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

Start Hunting!