How to load multiple images and processing them?
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Youssef Khmou
2013년 2월 6일
편집: Youssef Khmou
2013년 2월 6일
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 .
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!