2d fft for many images

5 views (last 30 days)
omar Alharbi
omar Alharbi on 15 May 2021
Commented: omar Alharbi on 16 May 2021
If I would like to compute and plot the 2D frequency spectrum for multiple images (50 frames), can I do that for each individual image and the avrege them?
here is the code:
min=zeros;
for K = 1 :1500:75000
this_file = strcat('C:\Users\Admin\Desktop\Tutorial\frame',num2str(K),'.tif');
im_input= rgb2gray(imread(this_file));
z_min=10*log10(abs(fftshift(fft2(im_input))));
min=min+z_min;
end
PSD_min= (min)/ 50;
______________
1- is this a right way compute the spectrum?
2- If I would like to remove the DC component, I tried
z_min=10*log10(abs(fftshift(fft2(im_input-mean2((im_input))... do you recommend other way?
Thanks
  2 Comments
Jonas
Jonas on 15 May 2021
it looks like the correct way to conpute the 2d spectrum, also the removal of the dc component ist correct. the questions if it is ok to add up the spectra depends on your goal, like already wrote you will get an anverage spectrum, this would make for me only sense, if the images are similar, otherwise you add up information that do not necessarily belong to each other / are related to each other.
you could also consider to add up the complex spectra (without the abs() ) and afterwards you can use abs on the summed spectrum and average it
Image Analyst
Image Analyst on 15 May 2021
Edited: Image Analyst on 15 May 2021
@Jonas Looks like a fine "Answer" to me so it should be down below in the "Answer" section.

Sign in to comment.

Accepted Answer

Jonas
Jonas on 15 May 2021
Edited: Jonas on 15 May 2021
it looks like the correct way to conpute the 2d spectrum, also the removal of the dc component is correct. the questions if it is ok to add up the spectra depends on your goal, like you already wrote you will get an anverage spectrum, this would make for me only sense, if the images are similar, otherwise you add up information that do not necessarily belong to each other / are related to each other. you could also consider to add up the complex spectra (without the abs() ) and afterwards you can use abs on the summed spectrum and average it
  1 Comment
omar Alharbi
omar Alharbi on 16 May 2021
Thanks for your feedback. Yse the images are similar.
I appreciate your comments

Sign in to comment.

More Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 15 May 2021
To remove the DC from your calculated values, you can use:
DC=mean2(im_input);
IM2=im_input-DC;

Community Treasure Hunt

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

Start Hunting!