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';

 採用された回答

Bruno Luong
Bruno Luong 2018 年 10 月 20 日

0 投票

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);

7 件のコメント

Balaji M. Sontakke
Balaji M. Sontakke 2018 年 10 月 20 日
thanks for giving an answer, now i get 200 x 1 cell array dimension but when I open cell array the output is 281 X 280 instead of that can i get inner cell value like 1600 X 1 1600 X 1 . . 1600 X 1
Bruno Luong
Bruno Luong 2018 年 10 月 20 日
編集済み: Bruno Luong 2018 年 10 月 20 日
This is how you Read and resize your data.
If you have issue of resize an image read from file, you should ask in a separate question. We don't have your data to answer.
Balaji M. Sontakke
Balaji M. Sontakke 2018 年 10 月 20 日
sir, I have attached my database over here. I resize my image to 40 X
40, is it possible to reshape image into 1600 X 1 and store in cell
array
Bruno Luong
Bruno Luong 2018 年 10 月 20 日
Please type
help RESHAPE
the read and try
Balaji M. Sontakke
Balaji M. Sontakke 2018 年 10 月 20 日
thanks...
Bruno Luong
Bruno Luong 2018 年 10 月 20 日
Alternatively you can also do
v = v(:)
after resizing into 40x40 to make it as a long vertical vector
Balaji M. Sontakke
Balaji M. Sontakke 2018 年 10 月 20 日
Now it works, thanks so much

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by