augmentedImageDatastore
Transform batches to augment image data
Description
An augmented image datastore transforms batches of training, validation, test, and prediction data, with optional preprocessing such as resizing, rotation, and reflection. Resize images to make them compatible with the input size of your deep learning network. Augment training image data with randomized preprocessing operations to help prevent the network from overfitting and memorizing the exact details of the training images.
To train a network using augmented images, supply the
augmentedImageDatastore
to the trainnet
function. For more information, see Preprocess Images for Deep Learning.
When you use an augmented image datastore as a source of training images, the datastore randomly perturbs the training data for each epoch, so that each epoch uses a slightly different data set. The actual number of training images at each epoch does not change. The transformed images are not stored in memory.
An
imageInputLayer
normalizes images using the mean of the augmented images, not the mean of the original data set. This mean is calculated once for the first augmented epoch. All other epochs use the same mean, so that the average image does not change during training.Use an augmented image datastore for efficient preprocessing of images for deep learning, including image resizing. Do not use the
ReadFcn
option ofImageDatastore
objects.ImageDatastore
allows batch reading of JPG or PNG image files using prefetching. If you set theReadFcn
option to a custom function, thenImageDatastore
does not prefetch and is usually significantly slower.
By default, an augmentedImageDatastore
only resizes images to fit
the output size. You can configure options for additional image transformations using an
imageDataAugmenter
.
Creation
Syntax
Description
auimds = augmentedImageDatastore(outputSize,
creates an augmented image datastore for classification problems using images
from image datastore imds
)imds
, and sets the
property.OutputSize
auimds = augmentedImageDatastore(outputSize,
creates an augmented image datastore for predicting responses of image data in
array X
)X
.
auimds = augmentedImageDatastore(outputSize,
creates an augmented image datastore for classification and regression problems.
The table, tbl
)tbl
, contains predictors and responses.
auimds = augmentedImageDatastore(outputSize,
creates an augmented image datastore for classification and regression problems.
The table, tbl
,responseNames
)tbl
, contains predictors and responses. The
responseNames
argument specifies the response variables
in tbl
.
auimds = augmentedImageDatastore(___,Name,Value)
creates an augmented image datastore, using name-value pairs to set the
, ColorPreprocessing
, DataAugmentation
, and OutputSizeMode
properties. You can specify
multiple name-value pairs. Enclose each property name in quotes.DispatchInBackground
For example,
augmentedImageDatastore([28,28],myTable,'OutputSizeMode','centercrop')
creates an augmented image datastore that crops images from the center.
Input Arguments
Properties
Object Functions
combine | Combine data from multiple datastores |
hasdata | Determine if data is available to read |
numpartitions | Number of datastore partitions |
partition | Partition a datastore |
partitionByIndex | Partition augmentedImageDatastore according to
indices |
preview | Preview subset of data in datastore |
read | Read data from augmentedImageDatastore |
readall | Read all data in datastore |
readByIndex | Read data specified by index from
augmentedImageDatastore |
reset | Reset datastore to initial state |
shuffle | Shuffle data in augmentedImageDatastore |
subset | Create subset of datastore or FileSet |
transform | Transform datastore |
isPartitionable | Determine whether datastore is partitionable |
isShuffleable | Determine whether datastore is shuffleable |
Examples
Tips
You can visualize many transformed images in the same figure by using the
imtile
function. For example, this code displays one mini-batch of transformed images from an augmented image datastore calledauimds
.minibatch = read(auimds); imshow(imtile(minibatch.input))
By default, resizing is the only image preprocessing operation performed on images. Enable additional preprocessing operations by using the
name-value pair argument with anDataAugmentation
imageDataAugmenter
object. Each time images are read from the augmented image datastore, a different random combination of preprocessing operations are applied to each image.
Version History
Introduced in R2018a