How to batch read image names from a folder with rules

Method 1, if the name is irregular, but the format is uniform, you can read the index (as a structure) of the picture in all formats and jpg in the following way, where the name element is the name of the picture. Then you can follow imread to read.
  1. img_dir = dir ('./ data / *. jpg');
  2. for i = 1:3
  3. I = imread(['./data/'  img_dir(i).name]);
  4. end
copy code


Method 2, the names are regular, for example, 0001.jpg 0002.jpg 0003.jpg
can construct names by themselves.
  1. for i =1:3
  2. I = imread(['./data/' num2str(i,'%04d') '.jpg'] );
  3. end
copy code

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326317585&siteId=291194637