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

2 次查看(过去 30 天)
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.

采纳的回答

madhan ravi
madhan ravi 2018-11-16
编辑:madhan ravi 2018-11-16
stored_values = cell(1,nfiles); %before loop
stored_values{ii}=Y; %inside loop
celldisp(stored_values) %outside loop
[stored_values{:}] %double values
  6 个评论

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by