faceData = cell(40,5); % or cell(5,40) for i=1:40 for j=1:5 % ... read v w = uint8(v); faceData{i,j} = w; % or faceData{j,i} = w; end end faceData = reshape(faceData,[],1);
how to store data in cell array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Balaji M. Sontakke
el 20 de Oct. de 2018
Comentada: Balaji M. Sontakke
el 20 de Oct. de 2018
I have 40 folders and each folder having 10 images, I have written one program for reading first five
images from 40 folders and stored in one cell array but I got the dimension i.e. 40 X 1 as given below
40 X 40
40 X 40
.
.
40 X 40
but I required the dimension of cell array i.e. 200 X 1 as given below
1600 X 1
1600 X 1
.
.
1600 X 1
function out=load_database()
% We load the database the first time we run the program.
persistent loaded;
persistent w;
if(isempty(loaded))
v=zeros(10304,400);
for i=1:40
cd(strcat('s',num2str(i)));
for j=1:5
a=imread(strcat(num2str(j),'.bmp'));
%v(:,(i-1)*10+j)=reshape(a,size(a,1)*size(a,2),1);
v = imresize(a,[40,40]);
end
w=uint8(v);
faceData{i}=w;
cd ..
end
end
loaded=1; % Set 'loaded' to aviod loading the database again.
out=faceData';
0 comentarios
Respuesta aceptada
Bruno Luong
el 20 de Oct. de 2018
7 comentarios
Bruno Luong
el 20 de Oct. de 2018
Alternatively you can also do
v = v(:)
after resizing into 40x40 to make it as a long vertical vector
Más respuestas (0)
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!