Main Content

CombinedDatastore

Datastore to combine data read from multiple underlying datastores

Since R2019a

Description

Use a CombinedDatastore object to combine the data read from multiple other datastores.

A CombinedDatastore maintains parity between the underlying datastores, so that data is read from corresponding parts of the underlying datastores. Resetting the CombinedDatastore resets all of the underlying datastores.

Creation

You can create a CombinedDatastore object using the combine function. For example, dsnew = combine(ds1,ds2) creates a datastore that combines the read data from datastores ds1 and ds2.

Properties

expand all

Underlying datastores, specified as a cell array of datastore objects.

Data Types: cell

This property is read-only.

Formats supported for writing, returned as a row vector of strings. This property specifies the possible output formats when using writeall to write output files from the datastore.

Object Functions

combineCombine data from multiple datastores
hasdataDetermine if data is available to read
previewPreview subset of data in datastore
readRead data in datastore
readallRead all data in datastore
writeallWrite datastore to files
resetReset datastore to initial state
transformTransform datastore
numpartitionsNumber of datastore partitions
partitionPartition a datastore
shuffleShuffle all data in datastore
isPartitionableDetermine whether datastore is partitionable
isSubsettableDetermine whether datastore is subsettable
isShuffleableDetermine whether datastore is shuffleable

Examples

collapse all

Create a datastore that maintains parity between the pair of images of the underlying datastores. For instance, create two separate image datastores, and then create a combined datastore that reads corresponding images from the two image datastores.

Create a datastore imds1 representing a collection of three images.

imds1 = imageDatastore({'street1.jpg','street2.jpg','peppers.png'}); 

Create a second datastore imds2 by transforming the images of imds1 to grayscale images.

imds2 = transform(imds1,@(x) im2gray(x));

Create a combined datastore from imds1 and imds2.

imdsCombined = combine(imds1,imds2);

Read the first pair of images from the combined datastore. Each read operation on this combined datastore returns a pair of images represented by a 1-by-2 cell array.

dataOut = read(imdsCombined)
dataOut=1×2 cell array
    {480x640x3 uint8}    {480x640 uint8}

Display the output of the first read from the combined datastore.

imshow(imtile(dataOut));

Figure contains an axes object. The axes object contains an object of type image.

Version History

Introduced in R2019a