How to read mutliple images in a for loop in MATLAB?

前端 未结 2 922
旧时难觅i
旧时难觅i 2021-01-22 10:31

I have segmented results in a folder. Those need to be read in a for loop and processed further in the loop. I tried reading as below:

for i=1:10 
file_name=dir(         


        
2条回答
  •  自闭症患者
    2021-01-22 11:17

    I guess your problem is that:

    file_name(1).name = .     % Stands for current directory
    file_name(2).name = ..    % Stands for parent directory
    file_name(3).name = your_file_name.jpg
    

    Now, do:

    images = dir('*JPG')
    for i=1:numel(images) 
    file_name=dir(strcat('C:\Users\adminp\Desktop\dinosaurs\')); 
      im=imread(strcat('C:\Users\adminp\Desktop\dinosaurs\',images(i).name));
      %processing of read image
    end    
    

提交回复
热议问题