Datastore for extracting random 2-D or 3-D random patches from images or pixel label images
A randomPatchExtractionDatastore
extracts corresponding
randomly-positioned patches from two image-based datastores. For example, the input datastores
can be two image datastores that contain the network inputs and desired network responses for
training image-to-image regression networks, or ground truth images and pixel label data for
training semantic segmentation networks.
This object requires that you have Deep Learning Toolbox™.
Note
When you use a randomPatchExtractionDatastore
as a source of training
data, the datastore extracts multiple random patches from each image for each epoch, so that
each epoch uses a slightly different data set. The actual number of training patches at each
epoch is the number of training images multiplied by PatchesPerImage
. The image patches are not stored in memory.
patchds = randomPatchExtractionDatastore(
uses name-value pairs to set the ds1
,ds2
,PatchSize
,Name,Value
)PatchesPerImage
, DataAugmentation
, and DispatchInBackground
properties. You can specify multiple
name-value pairs. Enclose each property name in quotes.
For example,
randomPatchExtractionDatastore(imds1,imds2,50,'PatchesPerImage',40)
creates a datastore that randomly generates 40 patches of size 50-by-50 pixels from each
image in image datastores imds1
and imds2
.
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 randomPatchExtractionDatastore according to
indices |
preview | Preview subset of data in datastore |
read | Read data from randomPatchExtractionDatastore |
readall | Read all data in datastore |
readByIndex | Read data specified by index from
randomPatchExtractionDatastore |
reset | Reset datastore to initial state |
shuffle | Shuffle data in datastore |
transform | Transform datastore |
isPartitionable | Determine whether datastore is partitionable |
isShuffleable | Determine whether datastore is shuffleable |
The randomPatchExtractionDatastore
expects that the output from the
read
operation on the input datastores return arrays of the same size.
If the input datastore is an ImageDatastore
, then the values in its
Labels
property are ignored by the
randomPatchExtractionDatastore
.
To visualize 2-D data in a randomPatchExtractionDatastore
, you can
use the preview
function, which returns a subset of
data in a table. Visualize all of the patches in the same figure by using the montage
function. For example, this code displays a preview of image patches
from a randomPatchExtractionDatastore
called
patchds
.
minibatch = preview(patchds); montage(minibatch.InputImage)
imageDatastore
| TransformedDatastore
| pixelLabelDatastore
(Computer Vision Toolbox) | pixelLabelImageDatastore
(Computer Vision Toolbox) | augmentedImageDatastore
(Deep Learning Toolbox) | imageDataAugmenter
(Deep Learning Toolbox) | trainNetwork
(Deep Learning Toolbox)