How to load multiple images and processing them?
Mostrar comentarios más antiguos
Hi!!!
i've been looking for some info about loading "n" images with a script but i havent find anything...
well my idea was create a function with a for loop that changes the index of the image to load, in that way if the firts image its called "1.jpg" the program will load and process the images 'till it reaches a variable called "m" that is the total of images in my directory....
well i've tried like this a lot of times but i cant find the way to make it work. :( so if anyone can help me i will be realy grateful
Respuesta aceptada
Más respuestas (1)
Youssef Khmou
el 6 de Feb. de 2013
Editada: Youssef Khmou
el 6 de Feb. de 2013
Hi, i saw a similar question before, you can find the answer by searching , anyway :
Suppose your images are "image1.jpg", "image2.jpg",...,"imagem.jpg" :
1.You get the size of sample .
2.You initialize a container .
3.You read through a loop.
I=imread('image1.jpg');
[r n p]=size(I); % Your Images are either 2D or 3D
Manifold=zeros(r,n,p,m); % 3D with singleton or 4D
for x=1:m
filename=strcat('image',num2str(x),'.jpg');
Manifold(:,:,:,x)=imread(filename);
end
Now you can blindly check if the images are gray-scale or 3d :
if p==1
Manifold=squeeze(Manifold); % you delete the singleton dimension
end
Just an addition , with singleton 4D Manifold, there is a command with which you can show the whole images in one figure , i just do not remember it .
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!