Loading multiple images in MATLAB

前端 未结 3 1956
借酒劲吻你
借酒劲吻你 2020-12-02 00:13

Here is the desired workflow:

  • I want to load 100 images into MATLAB workspace
  • Run a bunch of my code on the images
  • Save my output (the output
3条回答
  •  无人及你
    2020-12-02 00:51

    Assuming that your images are named in a sequential way, you could do this:

    N = 100
    IMAGES = cell(1,N);
    FNAMEFMT = 'image_%d.png';
    
    % Load images
    for i=1:N
      IMAGES{i} = imread(sprintf(FNAMEFMT, i));
    end
    
    % Run code
    RESULT = cell(1,N);
    
    for i=1:N
      RESULT{i} = someImageProcessingFunction(IMAGES{i});
    end
    

    The cell array RESULT then contains the output for each image.

    Be aware that depending on the size of your images, prefetching the images might make you run out of memory.

提交回复
热议问题