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:
- Get a list of filenames.
- Determine the processing steps to follow for each file.
- Put everything together in a for loop.
The processing steps for each file typically looked like this:
- Read in the data from the file.
- Process the data.
- Construct the output filename.
- 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 = imread(files(k).name); 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.
- Load the images. You can specify the folder containing your data.
- 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.
- Where do you want to put the output? Here you can say you just want to overwrite the input files. (Be careful!)
- Do you want to use a parallel cluster?
- Do you want to process all the files, or just a selection?
- 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.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.