Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
Nour Sd
Nour Sd am 16 Nov. 2018
Kommentiert: madhan ravi am 16 Nov. 2018
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.

Akzeptierte Antwort

madhan ravi
madhan ravi am 16 Nov. 2018
Bearbeitet: madhan ravi am 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 Kommentare
Nour Sd
Nour Sd am 16 Nov. 2018
Okay, thank you a lot! :)
madhan ravi
madhan ravi am 16 Nov. 2018
You are welcome :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by