Azzera filtri
Azzera filtri

How to save the FFt results of an image in an array?

3 visualizzazioni (ultimi 30 giorni)
Hello,
Please can you help me saving the result of the Fast Fourier Transform of an image so I can reuse it to draw the bessel function?
My code below, gives this error :
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in essai (line 13)
stored_values(ii) = Y;
clc;
close all;
imagefiles = dir('*.jpg');
nfiles = length(imagefiles); % Number of image files found
stored_values = zeros(nfiles,4); % Preallocate the array for saving the values
for ii=1:nfiles
currentfilename = imagefiles(ii).name;
I = imread(currentfilename);
myimage = rgb2gray(I); % Convert image to gray
Y = fft2(double(myimage))
stored_values(ii) = Y;
imagesc(abs(fftshift(Y)));
end
And if I change this line
stored_values(ii) = Y;
to this
stored_values(ii,1) = Y;
it gives this error:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in essai (line 13)
stored_values(ii,1) = Y;
Please can anyone correct it for me?
Thank you.

Risposta accettata

madhan ravi
madhan ravi il 16 Nov 2018
Modificato: madhan ravi il 16 Nov 2018
stored_values = cell(1,nfiles); %before loop
stored_values{ii}=Y; %inside loop
celldisp(stored_values) %outside loop
[stored_values{:}] %double values
  6 Commenti

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by