Effacer les filtres
Effacer les filtres

Open and procces multiple images

1 vue (au cours des 30 derniers jours)
Pavel Todorov
Pavel Todorov le 14 Juin 2021
Commenté : Pavel Todorov le 15 Juin 2021
Hey everyone, I have a 870 images from 29 different classes and each class has 30 images in sequential number from 1 to 30, following this pattern NameOfTheImage_1-30. What I want to do is to open and then convert all of the images, automatically one by one, into grayscale. Can you help me with that? The codes from here are somehow usefull but not for my case (I think).

Réponse acceptée

Krishna Sutar
Krishna Sutar le 15 Juin 2021
From my understanding you want to open multiple images from multiple classes. Here is the code which might help you:
for class = 1:29
for a = 1:30
filename = ['Parent folder/class' num2str(class,'%d') '/NameofTheImage_' num2str(a,'%d') '.PNG'];
img{class,a} = imread(filename);
% Processing
end
end
  1 commentaire
Pavel Todorov
Pavel Todorov le 15 Juin 2021
Thank you!

Connectez-vous pour commenter.

Plus de réponses (1)

KSSV
KSSV le 15 Juin 2021
Img = dir('*.png') ; % give your extension of images
N = length(Img) ;
for i = 1:N
thisImg = Img(i).name ;
I = imread(thisImg) ;
Ig = rgb2gray(I) ;
% do what you want
end
  1 commentaire
Pavel Todorov
Pavel Todorov le 15 Juin 2021
Thank you!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by