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

前端 未结 2 928
旧时难觅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:10

    If you have the R2014b release of MATLAB with the Computer Vision System Toolbox, you can do this in one line using the imageSet object.

    images = imageSet('C:\Users\adminp\Desktop\dinosaurs\');
    

    will create an object containing the paths to all the images in the dinosaurs directory. It will exclude any non-image files automaticaly.

    Then you can process your images as follows

    for i = 1:images.Count
      im = read(images, i);
      % process the image
    end
    

提交回复
热议问题