combine
Combine data from multiple datastores
Description
combines two or more datastores by horizontally concatenating the data returned by the
dsnew
= combine(ds1,ds2,...,dsN
)read
function on the input datastores.
Examples
Combine Datastores
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));
Input Arguments
ds1,ds2,...,dsN
— Datastores to combine
datastore objects
Datastores to combine, specified as two or more comma separated datastore objects. For a complete list of built-in datastores, see Select Datastore for File Format or Application. You also can specify custom datastores.
Output Arguments
dsnew
— New datastore with combined data
CombinedDatastore
object
New datastore with combined data, returned as a CombinedDatastore
object.
The dsnew
object is a new datastore instance that is the
horizontally concatenated result of a read operation on each of the underlying
datastores.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
Usage notes and limitations:
In a thread-based environment, you can use
combine
only with the following datastores:ImageDatastore
objectsCombinedDatastore
orTransformedDatastore
objects you create fromImageDatastore
objects by usingcombine
ortransform
You can use
combine
with other datastores if you have Parallel Computing Toolbox™. To do so, run the function using a process-backed parallel pool instead of usingbackgroundPool
orThreadPool
(use eitherProcessPool
orClusterPool
).
For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)