# New image batch processor app in R2015a

Nine years ago I wrote a blog post showing how to do batch processing of image files. That is, I showed how to use MATLAB to perform the same operation on a bunch of image files in a particular folder.

The basic procedure is:

1. Get a list of filenames.
2. Determine the processing steps to follow for each file.
3. Put everything together in a for loop.

The processing steps for each file typically looked like this:

1. Read in the data from the file.
2. Process the data.
3. Construct the output filename.
4. Write out the processed data.

I showed a sample processing loop that cropped and resized a bunch of images the same way:

files = dir('*.JPG');
for k = 1:numel(files)
rgb = rgb(1:1800, 520:2000, :);
rgb = imresize(rgb, 0.2, 'bicubic');
imwrite(rgb, ['cropped\' files(k).name]);
end

You can still do it exactly this way today, of course, in 2015. But you really might want to use the new Image Batch Processor App instead:

This is a very nice app that was just added to the Image Processing Toolbox in R2015a (released earlier this year, in March). If you look at the tool strip from left to right, you can see the entire workflow laid out for you.

1. Load the images. You can specify the folder containing your data.
2. What function do you want to run on each image? You can specify an existing function, or you can let the app make a shell function for you, and then you can fill in the details.
3. Where do you want to put the output? Here you can say you just want to overwrite the input files. (Be careful!)
4. Do you want to use a parallel cluster?
5. Do you want to process all the files, or just a selection?
6. Do you want to generate some code so you can automate the entire process?

I encourage you to give it a try. The toolbox documentation gives you more details for getting started.

Published with MATLAB® R2015a

|

### コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。