Main Content

combine

Combine data from multiple datastores

Description

example

dsnew= combine(ds1,ds2,...,dsN)combines two or more datastores by horizontally concatenating the data returned by thereadfunction on the input datastores.

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.

Input Arguments

collapse all

Datastores to combine, specified as two or more comma separated datastore objects. For a complete list of built-in datastores, seeSelect Datastore for File Format or Application. You also can specify custom datastores.

Output Arguments

collapse all

New datastore with combined data, returned as aCombinedDatastoreobject.

Thedsnewobject is a new datastore instance that is the horizontally concatenated result of a read operation on each of the underlying datastores.

Extended Capabilities

Introduced in R2019a