Main Content

CombinedDatastore

Datastore to combine data read from multiple underlying datastores

Since R2019a

Description

Use aCombinedDatastoreobject to combine the data read from multiple other datastores.

ACombinedDatastoremaintains parity between the underlying datastores, so that data is read from corresponding parts of the underlying datastores. Resetting theCombinedDatastoreresets all of the underlying datastores.

Creation

You can create aCombinedDatastoreobject using thecombinefunction. For example,dsnew = combine(ds1,ds2)creates a datastore that combines the read data from datastoresds1andds2.

Properties

expand all

底层数据存储, 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 usingwriteallto write output files from the datastore.

Object Functions

combine Combine data from multiple datastores
hasdata Determine if data is available to read
preview Preview subset of data in datastore
read Read data in datastore
readall Read all data in datastore
writeall Write datastore to files
reset Reset datastore to initial state
transform Transform datastore
numpartitions Number of datastore partitions
partition Partition a datastore
shuffle Shuffle all data in datastore
isPartitionable Determine whether datastore is partitionable
isSubsettable Determine whether datastore is subsettable
isShuffleable Determine 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 datastoreimds1representing a collection of three images.

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

Create a second datastoreimds2by transforming the images ofimds1to grayscale images.

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

Create a combined datastore fromimds1andimds2.

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 a1-by-2cell 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