partitionByIndex
Partition augmentedImageDatastore according to
indices
Description
Examples
Load the sample data, which consists of synthetic images of handwritten digits. XTrain is a 28-by-28-by-1-by-5000 array, where:
28 is the height and width of the images.
1 is the number of channels.
5000 is the number of synthetic images of handwritten digits.
load DigitsDataTrain whos XTrain
Name Size Bytes Class Attributes XTrain 28x28x1x5000 31360000 double
Create an imageDataAugmenter object that specifies preprocessing options for image augmentation, such as resizing, rotation, translation, and reflection. Randomly translate the images up to three pixels horizontally and vertically, and rotate the images with an angle up to 20 degrees.
imageAugmenter = imageDataAugmenter( ... RandRotation=[-20,20], ... RandXTranslation=[-3 3], ... RandYTranslation=[-3 3]);
Create an augmentedImageDatastore using the image data augmented. When you read from the datastore, for example during network training using the trainnet function, the datastore performs image augmentation and resizes the images. The datastore augments the images without saving any images to memory.
imageSize = [64 64 1]; augimds = augmentedImageDatastore(imageSize,XTrain,DataAugmentation=imageAugmenter);
Create a random permutation of the integers one to the total number of images in the datastore.
numObservations = augimds.NumObservations;
Shuffle the images to create a new datastore containing the same images in a random order.
augimds = shuffle(augimds);
Partition the datastore. The partitionByIndex function returns a datastore containing 80% of the images.
trainAugimds = partitionByIndex(augimds,1:round(0.8*numObservations))
trainAugimds =
augmentedImageDatastore with properties:
NumObservations: 4000
MiniBatchSize: 128
DataAugmentation: [1×1 imageDataAugmenter]
ColorPreprocessing: 'none'
OutputSize: [64 64]
OutputSizeMode: 'resize'
DispatchInBackground: 0
Partition the datastore using elements of the remaining indices. The partitionByIndex function returns a datastore containing the remaining 20% of the images.
valAugimds = partitionByIndex(augimds,round(0.8*numObservations)+1:numObservations)
valAugimds =
augmentedImageDatastore with properties:
NumObservations: 1000
MiniBatchSize: 128
DataAugmentation: [1×1 imageDataAugmenter]
ColorPreprocessing: 'none'
OutputSize: [64 64]
OutputSizeMode: 'resize'
DispatchInBackground: 0
Input Arguments
Augmented image datastore, specified as an augmentedImageDatastore object.
Indices of observations, specified as a vector of positive integers.
Output Arguments
Output datastore, returned as an
augmentedImageDatastore object containing a subset of
files from auimds.
Version History
Introduced in R2018a
See Also
read | readall | readByIndex
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)