readall
Read all data in datastore
Description
Examples
Read All Data in ImageDatastore
Create anImageDatastore
object containing four images.
imds = imageDatastore({'street1.jpg','street2.jpg','peppers.png','corn.tif'});
Read all the data in the datastore.
T = readall(imds);
Examine the output.
imout = imtile(T); imshow(imout)
Read All Data in TabularTextDatastore in Parallel
Create a datastore from the sample fileairlinesmall.csv
, which contains tabular data.
ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','NA');
Specify the variables of interest using theSelectedVariableNames
property.
ds.SelectedVariableNames = {'DepTime','ArrTime','ActualElapsedTime'};
Read all the data in the datastore in parallel.
T = readall(ds,'UseParallel',true);
readall
returns all the data in a table.
View information about the table. Only the selected variables are included in the output.
T.Properties
ans = TableProperties属性:描述: '' UserData: [] DimensionNames: {'Row' 'Variables'} VariableNames: {'DepTime' 'ArrTime' 'ActualElapsedTime'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowNames: {} CustomProperties: No custom properties are set. Use addprop and rmprop to modify CustomProperties.
Read All Data in CombinedDatastore
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 representing the two underlying datastores.
Create an image datastoreimds1
representing a collection of three images.
imds1 = imageDatastore({'street1.jpg','street2.jpg','peppers.png'});
Create a second datastoreimds2
by transforming the images ofimds1
to grayscale and then downsizing the images.
imds2 = transform(imds1,@(x) imresize(im2gray(x),0.5));
Create a combined datastore fromimds1
andimds2
.
imdsCombined = combine(imds1,imds2);
Read all of the data from the combined datastore. The output is a 3-by-2 cell array. The two columns represent all of the read data from the two underlying datastoresimds1
andimds2
, respectively.
dataOut = readall(imdsCombined)
dataOut=3×2 cell array{480x640x3 uint8} {240x320 uint8} {480x640x3 uint8} {240x320 uint8} {384x512x3 uint8} {192x256 uint8}
Input Arguments
ds
—Input datastore
datastore
Input datastore. You can use these datastores as input to thereadall
method.
MATLAB®datastores — Datastores created using MATLAB
datastore
functions. For example, create a datastore for a collection of images usingImageDatastore
. For a complete list of datastores, seeSelect Datastore for File Format or Application.Combined and transformed datastores — Datastores created using the
combine
andtransform
functions.Custom datastores — Datastores created using the custom datastore framework. SeeDevelop Custom Datastore.
tf
—Read in parallel
false (default)|true
Read in parallel, specified astrue
orfalse
. If you specifytrue
,readall
reads all data from the datastore in parallel (requires Parallel Computing Toolbox). Parallel reading may result in improved performance when reading data, especially with remote data.
Datastore processing can be improved with the
UseParallel
property and the Parallel Computing Toolbox.readall
reads supported datastores faster on the local machine by using low overhead computing environments such as thread-based parallel pools. For more information on thread-based parallel pools seeparpool
(Parallel Computing Toolbox).As a result of MATLAB's built-in multithreading, certain datastores (for example,
imageDatastore
) perform faster on the local machine when not using parallelism based on MATLAB workers. For more information seeMATLAB Multicore.
Example:readall(ds,'UseParallel',true)
Output Arguments
data
— All data in the datastore
table | cell array
All data in the datastore, returned as a table or a cell array depending on the type ofds
.
Type of Datastore | Data type ofdata |
Description |
---|---|---|
TabularTextDatastore andSpreadsheetDatastore |
Table | TheSelectedVariableNames property determines the table variables. |
ImageDatastore |
Cell array | Each element in the cell array contains the image data for one image. Thereadall function supports all image types supported by theimread function. For more information on the supported image types, seeimread . |
KeyValueDatastore |
Table | The table variable names areKey andValue . |
FileDatastore |
Cell array | Each element in the cell array contains the data read from one file using the custom read function specified by theReadFcn property. |
TransformedDatastore |
Varies | The output is the same as the output returned by the underlying datastore specified by theUnderlyingDatastores property. For example, if the underlying datastore is an image datastore, thendata is returned as a cell array where each element in the cell array contains the image data for one image. |
CombinedDatastore |
Cell array | Each column of the cell array contains the result from calling If the number of subsets of data in the underlying datastores differs, then |
Extended Capabilities
Automatic Parallel Support
Accelerate code by automatically running computation in parallel using Parallel Computing Toolbox™.
Usage notes and limitations:
To run in parallel, set the
'UseParallel'
option totrue
.
For more information, seeRun MATLAB Functions with Automatic Parallel Support(Parallel Computing Toolbox).
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
readall
only with the following datastores:ImageDatastore
objectsCombinedDatastore
orTransformedDatastore
objects you create fromImageDatastore
objects by usingcombine
ortransform
You can use
readall
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
).readall
does not support the following image formats in a thread-based environment:Hierarchical Data Format (HDF)
SVS
TIFF
For more information, seeRun MATLAB Functions in Thread-Based Environment.
Version History
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de 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)