How to read multiple jpg images in a loop?
44 ビュー (過去 30 日間)
古いコメントを表示
hello, i am a novice user in matlab my question is: i have stored some 100s of images in some folder and i want to read it one-by-one.how can i do this?
17 件のコメント
Anil Varma
2019 年 12 月 13 日
showing error
Error using randi
First input must be a positive scalar integer value IMAX, or two integer values [IMIN IMAX] with IMIN
less than or equal to IMAX.
Error in test (line 9)
idx=randi(n);
採用された回答
その他の回答 (5 件)
Karthik Karri
2014 年 3 月 6 日
You can rename all images like..im1,im2,im3.....im100. To read 100 images one by one, run a loop 100 times with i as variable from 1 to 100 and in imread, m=imread(['folder_path\im' num2str(i) '.jpg']). I hope I answered your question.
chaitra naveen
2017 年 3 月 20 日
can you please help me out to read 100's of images from folder to matlab and resize them to 100x100.
1 件のコメント
Image Analyst
2017 年 5 月 4 日
Use imresize in a loop like the loops given in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Muhammad Sohail
2017 年 11 月 27 日
filelist = dir('Training data');
for i=1 : length(filelist)
for i=1 : length(filelist)
filename = filelist(i);
if ~strcmp(filename.name , '.') && ~strcmp(filename.name , '..')
filename.name
end
end
Haseeb Hassan
2019 年 6 月 30 日
for i=1:16; % we have 16 images we have in or folder
clc;clear;
images ='C:\Users\Haseeb\Desktop\input\for_loop_input';
jpgfiles=dir(fullfile(images,'\*.jpg*'));
n=numel(jpgfiles(i));
im=jpgfiles(i).name
im1=imread(fullfile(images,im));
imshow(im1);
end
Here is the simple and short code, which will acces your images from your folder in a sequence.
1 件のコメント
shital shinde
2020 年 2 月 21 日
Actually it gives error as
Array indices must be positive integers or logical values.
n=numel(jpgfiles(i)); // for this line.
will you tell me why ?
Xylo
2014 年 3 月 6 日
You can do this easily..... before doing this program, you have to keep all of your image in a folder and rename them by any common char+number concatenation form (like a1.jpg, a2.jpg,a3.jpg....). after that you just use strcat() function for reading the path name, and then read the images.
for i=1:10 %suppose there are 10 image
file_name=dir(strcat('J:\multimedia\photo\')); % the path tht u hv imges
im=imread(strcat('J:\multimedia\photo\',file_name(i).name));
imtool(im);
end
8 件のコメント
Walter Roberson
2016 年 11 月 29 日
Isha Pandya, please show your current code and describe what difficulty you are observing.
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!