Image Batch Processor
Apply function to multiple images
Description
The Image Batch Processor app enables you to process multiple images using the same function. Using this app, you can:
Load images from a folder or from an
imageDatastore
object in the workspace.Process images using an existing MATLAB® function, or create a custom batch processing function using a code template.
View intermediate and final processed images.
Export processed images to an output folder or the workspace.
Generate a function to process additional images outside the app.
If you have Parallel Computing Toolbox™ you can process the images on a local parallel pool.
To get started, see Process Folder of Images Using Image Batch Processor App.
More
Specify Batch Processing Function
You can specify the batch processing function as one of these options:
Existing MATLAB function — Specify an existing built-in or user-created function on the MATLAB search path. Type the function name in the Function Name box, or select it from the list. Alternatively, click Open to navigate to the function file you want to use.
Create new function — Create a custom batch processing function using a code template. Click Create in the app toolstrip to open the template.
A batch processing function can accept one or two input arguments.
Image — The first input must be the image array
im
.Information structure — The optional second argument is a structure,
info
, that contains information about the input image file. Theinfo
argument is useful if your batch processing function internally calls one or more functions that require a filename as input, such asimread
orrawinfo
. For details, see Access File Information.
Open the Image Batch Processor App
MATLAB Toolstrip: On the Apps tab, under Image Processing and Computer Vision, click the Image Batch Processor app icon.
MATLAB command prompt: Enter
imageBatchProcessor
.
Examples
Programmatic Use
imageBatchProcessor
imageBatchProcessor
opens the Image Batch
Processor app, which enables you to process a folder of images.
imageBatchProcessor(folderLocation
)
folderLocation
)imageBatchProcessor(
opens the app and loads the batch of images stored in the folder
folderLocation
)folderLocation
. (since R2023a)
imageBatchProcessor(imds
)
imds
)imageBatchProcessor(
opens the app and loads the images in the
imds
)imageDatastore
object
imds
. (since R2023a)
imageBatchProcessor close
imageBatchProcessor close
closes all open
instances of the Image Batch Processor app.
More About
Access File Information
Access file information within your batch processing function by
including the optional info
input argument. To
pass the info
input argument to your batch
processing function, select Include Image Info
in the app toolstrip before you process any images. If the batch
processing function expects the info
argument,
you must select the Include Image Info check
box or the app returns an error.
The app automatically creates info
by using the
datastore read
object
function, regardless of whether you load the images into the app
from a folder or an imageDatastore
object. The
info
structure contains these fields:
Filename
— The image source filename, including the path string, name of the file, and file extension.FileSize
— Total file size, in bytes.Label
— Image label name, if present. Otherwise, theLabel
field contains an empty string.
In the batch processing function code template, access the file
information in info
using dot notation. For
example, use this code to access the input image
filename.
filename = info.Filename
imread
to read
the colormap from an indexed image file, or read metadata using
functions such as imfinfo
,
rawinfo
, or dicominfo
.Version History
Introduced in R2015aR2023a: Support for image datastores and other enhancements
The Image Batch Processor app includes several new capabilities:
Image datastore support — Load a batch of images by importing an
imageDatastore
object from the MATLAB workspace.Support for additional file formats — load images from RAW file formats and EXR images.
Additional command Line syntaxes — Open the Image Batch Processor and load images using two new syntaxes.
This syntax opens the app and loads the batch of images stored in the folder
folderLocation
.This syntax opens the app and loads the images in theimageBatchProcessor(folderLocation)
imageDatastore
objectimds
.imageBatchProcessor(imds)
You can now optionally pass a second input argument,
info
, to your batch processing function. Theinfo
argument contains information about the image source, including the image filename. For an example that uses theinfo
argument, see Process Images Using Image Batch Processor App with File Metadata.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)