subset
创建数据存储或文件集的子集
Syntax
Description
Examples
创建子集ImageDatastore
制作图像数据存储对象,然后创建该图像数据存储的子集。
创造an image datastoreimds
for all the image files in a sample folder. Then, display theFiles
property ofimds
。
folders = fullfile(matlabroot,'工具箱','matlab',{“演示”,'imagesci'}); exts = {'.jpg','.png','.tif'}; imds = imageDatastore(folders,“ Labelsource”,'foldernames',“ fileextensions',exts); imds.Files
ans = 8×1 cell array {'...\matlab\toolbox\matlab\demos\cloudCombined.jpg'} {'...\matlab\toolbox\matlab\demos\example.tif' } {'...\matlab\toolbox\matlab\demos\landOcean.jpg' } {'...\matlab\toolbox\matlab\demos\ngc6543a.jpg' } {'...\matlab\toolbox\matlab\demos\street1.jpg' } {'...\matlab\toolbox\matlab\demos\street2.jpg' } {'...\matlab\toolbox\matlab\imagesci\corn.tif' } {'...\matlab\toolbox\matlab\imagesci\peppers.png' }
创造a subset datastoresubimds
包含第一个四files ofimds
and examine theFiles
property ofsubimds
。
indices = 1:4; subimds = subset(imds,indices); subimds.Files
ans = 4×1 cell array {'...\matlab\toolbox\matlab\demos\cloudCombined.jpg'} {'...\matlab\toolbox\matlab\demos\example.tif' } {'...\matlab\toolbox\matlab\demos\landOcean.jpg' } {'...\matlab\toolbox\matlab\demos\ngc6543a.jpg' }
创造Subset Datastore with Randomly Selected Files
Make an image datastore, and then create subset datastore containing only a specified percentage of files, randomly selected from the original datastore.
创造成像
for all the image files in a sample folder and display theFiles
property. This datastore contains 8 files.
folders = fullfile(matlabroot,'工具箱','matlab',{“演示”,'imagesci'}); exts = {'.jpg','.png','.tif'}; imds = imageDatastore(folders,“ Labelsource”,'foldernames',“ fileextensions',exts); imds.Files
ans = 8×1 cell array {'...\matlab\toolbox\matlab\demos\cloudCombined.jpg'} {'...\matlab\toolbox\matlab\demos\example.tif' } {'...\matlab\toolbox\matlab\demos\landOcean.jpg' } {'...\matlab\toolbox\matlab\demos\ngc6543a.jpg' } {'...\matlab\toolbox\matlab\demos\street1.jpg' } {'...\matlab\toolbox\matlab\demos\street2.jpg' } {'...\matlab\toolbox\matlab\imagesci\corn.tif' } {'...\matlab\toolbox\matlab\imagesci\peppers.png' }
创造a set of indices that represents randomly selected subset containing60%
of the files.
nfiles =长度(imds.files);randindices = randperm(nfiles);nsixtypercent =圆形(0.6*nfiles);indices = randindices(1:nsixtypercent)
indices = 8 6 4 5 1
创造a subset datastore提出
usingindices
and examine itsFiles
property.
subimds = subset(imds,indices); subimds.Files
ans = 5×1 cell array {'...\matlab\toolbox\matlab\imagesci\peppers.png' } {'...\matlab\toolbox\matlab\demos\street2.jpg' } {'...\matlab\toolbox\matlab\demos\ngc6543a.jpg' } {'...\matlab\toolbox\matlab\demos\street1.jpg' } {'...\matlab\toolbox\matlab\demos\cloudCombined.jpg'}
Input Arguments
ds
—输入数据存储或文件集
ImageDatastore
|DsFileSet
|文件集
|BlockedFileSet
输入数据存储或文件集, specified asImageDatastore
,DsFileSet
,文件集
,BlockedFileSet
目的。
创建一个n
ImageDatastore
对象,使用成像
。创建一个
DsFileSet
对象,使用matlab.io.datastore.DsFileSet
。创建一个
文件集
对象,使用matlab.io.datastore.fileset
。创建一个
BlockedFileSet
对象,使用matlab.io.datastore.BlockedFileSet
。
indices
—Indices of files to include in subset
指数向量|logical vector
Indices of files to include in subset, specified as a vector of indices or a logical vector.
这指数向量must contain the indices of files to include in the subset
subds
。这logical vector must be of the same length as the number of files in the input
ds
。这subset
method creates a subsetsubds
包含对应于具有逻辑向量元素的文件,该元素的值真的
。
Elements ofindices
must be unique.
Data Types:double
|logical
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB®背景池
或者accelerate code with Parallel Computing Toolbox™ThreadPool
。
Usage notes and limitations:
在基于线程的环境中,您可以使用
subset
仅具有以下数据存储:ImageDatastore
objectsCombinedDatastore
或者变换的达塔斯托尔
您创建的对象ImageDatastore
通过使用对象结合
或者转换
您可以使用
subset
with other datastores if you have Parallel Computing Toolbox™. To do so, run the function using a process-backed parallel pool instead of using背景池
或者ThreadPool
(use eitherProcessPool
或者ClusterPool
).
For more information, seeRun MATLAB Functions in Thread-Based Environment。
See Also
matlab.io.datastore.fileset
|matlab.io.datastore.BlockedFileSet
|DsFileSet
|ImageDatastore
|splitEachLabel
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择一个网站
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:。
您还可以从以下列表中选择一个网站:
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éricaLatina(Español)
- Canada(English)
- United States(English)
欧洲
- Belgium(English)
- 丹麦(English)
- Deutschland(德意志)
- España(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- 意大利(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(德意志)
- Portugal(English)
- Sweden(English)
- 瑞士
- 英国(English)