How can i create a image array includes files from a specific folder?

how can i create a database from images in a folder? here is my code but it is giving error.
directory = fullfile('./buildings');
images = dir(fullfile(directory,'*.jpg'));
names = {images.name}';
I=zeros(numel(names),144,176,3); %size of the images are constant and 144*176*3
for k=1: numel(names)
I{k} = imread(fullfile(directory,names{k}));
I{k}=tempI;
figure; imshow(I{k});
%operations
end
Error is this:
Cell contents assignment to a non-cell array object.
Error in application2exercise3 (line 9)
I{k} = imread(fullfile(directory,names{k}));
Ty for your help.

 採用された回答

Image Analyst
Image Analyst 2012 年 10 月 18 日

0 投票

What is tempI? It's not defined.

2 件のコメント

koray
koray 2012 年 10 月 18 日
ignore the
I{k}=tempI;
line it is comment outed normally.
Image Analyst
Image Analyst 2012 年 10 月 18 日
Try it like this:
images = dir(fullfile(directory,'*.jpg'));
names = {images.name}';
I=cell(numel(names), 1);
for k=1: numel(names)
I{k} = imread(fullfile(directory,names{k}));
imshow(I{k});
end
The problem was that you first defined I as a 3D numerical array and then was trying to stuff 3D color images into it as if I were a cell, but I was not a cell array.

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

その他の回答 (1 件)

koray
koray 2012 年 10 月 18 日

0 投票

Thank you for your response. It worked!

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by