How to calculate amplitude of each frequency?

조회 수: 7 (최근 30일)
Desiree
Desiree 2019년 8월 21일
편집: Desiree 2019년 8월 28일
I have an image and I have a code which gives the 2d fft of each color of the image. Now I need to calculate the amplitude of each frequency but I don’t know how to do it. Help is appreciated. Here’s my code so far:
im=imread('image ')/255.;
im1=im;
im=im(:,:,1);
imagefft2=fft2(im);
a=im_fft2;
a(angle(imagefft2)<pi/2)=1;
figure();
im1(:,:,1)=abs(ifft2(a));
imshow(im,[]);

채택된 답변

AdamG2013468
AdamG2013468 2019년 8월 21일
For a 1-D fft, the process is as follows:
fs = %arbitrary sample frequency
N = length(signal);
fbins = [(0:1/N:1-1/N)*fs]; %frequency bin vector for plotting (x axis)
calval = N/2; %for two-sided ffts, calval should just be N for one-sided
[fftdat] = fft(signal);
fftmag = abs(fftdat)/calval;
%to visualize that expected magnitude is correct
figure
hold on
plot(fbins, fftmag)
See if you have any luck with a similar approach for your 2-D fft.
  댓글 수: 5
AdamG2013468
AdamG2013468 2019년 8월 21일
편집: AdamG2013468 2019년 8월 21일
One way,
for i = 1:length(fftmag)
if fftmag(i) < 1/8
fftmag(i) = 0
end
end
Desiree
Desiree 2019년 8월 21일
I’m really sorry, but still I cannot understand the relationship between your first answer for 1d fft and my question. In my case I don’t have a function, but an image. It has nothing similar to what I have

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by