Hi, I'm new in this. I have 4 images named: img1.jpg, img2.jpg, img3.jpg, and img4.jpg. All i have to do is read them one by one in a for loop. How can i do that?

 Réponse acceptée

Paulo Silva
Paulo Silva le 3 Mar 2011

7 votes

c=cell(1,4);
for i=1:4
c{i}=imread(sprintf('img%d.jpg',i));
end

3 commentaires

nitesh patil
nitesh patil le 21 Jan 2014
what if binary images need to be read?
preeti
preeti le 24 Déc 2014
hi if i want to show images also what i hav to add in this code.
put this in the loop
subplot(2,2,i);
imshow(c{i});

Connectez-vous pour commenter.

Plus de réponses (1)

ck
ck le 15 Jan 2020

0 votes

How can I loop through images I read in, when the images have different names and numbers?

Community Treasure Hunt

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

Start Hunting!

Translated by