Compute average FFT power for images (to reflect average visual saliency?)
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all,
I'm peforming FFT on a series of images, and want to compute an average FFT power per image. I found many tutorials on how to do the 2D FFT, but I'm a little confused of how to compute the average FFT power. Perhaps more importantly, could the average FFT power be used as an index of average visual saliency? And could I use it to compare saliency between two images?
What I've tried so far:
% load in image
img =imread('sample.jpg');
% convert into grayscale image
gray_img=rgb2gray(img);
% perform FFT of an image
F = fft2(gray_img);
% get the centered spectrum
Fsh = fftshift(F);
To compute average FFT power, is it simply:
avgFFT_power = mean(mean(abs(Fsh).^2, 1),2);
I'm not very familiar with image processing so I think I'm missig something. I would greatly appreciate it if anyone can guide me in the correct direction. Thank you so much!
0 Commenti
Risposte (1)
Sufiyan
il 1 Mar 2023
Hello,
You can refer to the below code to perform FFT on series of images and to compute an average FFT per image.
% Read in the four images
img1 = imread('img.jpg');
img2 = imread('img.jpg');
img3 = imread('img.jpg');
img4 = imread('img.jpg');
% Store the images in a cell array
imgs = {img1, img2, img3, img4};
% Compute the FFT for each image and store the magnitudes in a cell array
ffts = cell(1, 4);
for i = 1:4
ffts{i} = abs(fft2(imgs{i})).^2; % Square the magnitudes to get power
end
% Compute the average FFT power across all images
avg_fft_power = mean(cat(3, ffts{:}),'all');
disp(['Average FFT power: ', num2str(avg_fft_power)]);
To compute average FFT power over all the frequencies of an image, You can follow the code shown below
% Read in the image
img = imread('img.jpg');
% Compute the FFT and power spectrum
fft_power = abs(fft2(img)).^2;
% Compute the average FFT power across all frequencies in the image
avg_fft_power = mean(fft_power, 'all');
% Display the average FFT power
disp(['Average FFT power: ', num2str(avg_fft_power)]);
0 Commenti
Vedere anche
Categorie
Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!