Main Content

PixellabelTrainingData

创建从地面真相的语义细分的培训数据

Description

例子

[[IMD,,,,PXD] = pixelLabelTrainingData(格特鲁斯creates image datastoreIMD和像素标签数据存储PXDfrom the specified ground truth. You can combine the returned datastores into aPixellabelimagedatastoreand use thetrainNetwork(深度学习工具箱)function to train deep learning segmentation networks. You can also use these datastores with the评估电子细分功能以评估深度学习或经典分割方法的结果。

This function supports parallel computing using multiple MATLAB®工作人员。使用计算机视觉工具箱Preferences对话框。

[[IMD,,,,PXD] = pixelLabelTrainingData(格特鲁斯,,,,姓名,,,,Valuereturns image and pixel label datastores with additional options specified by one or more name-value pair arguments.

  • If thegroundTruth对象在格特鲁斯were created using a video file, a custom data source, or animageDatastore使用不同的自定义读取功能,您可以指定名称值对参数的任何组合。

  • If thegroundTruth对象were created from an image collection or image sequence data source, then you can specify only the采样反应器名称值对参数

Examples

collapse all

加载agroundTruth目的named格特鲁斯。The ground truth contains pixel labels for triangles and background, annotated on a video with 100 frames.

visiondataPath = fullfile(matlabroot,'toolbox',,,,'想象',,,,'VisionData');addpath(fullfile(VisionDatapath,'triangleImages');addpath(fullfile(VisionDatapath,'triangleImages',,,,“测试标签”);loadedData = load(fullfile(visiondataPath,'triangleImages',,,,'triangleGroundTruth.mat');格特鲁斯= loadedData.gTruth;

在当前目录中创建一个文件夹。

foldername = fullfile(tempdir,“ videoframes”);mkdir(foldername)

创建一个imageDatastoreand apixelLabelDatastore来自视频文件和相应的像素标签。将每个第五张图像写入磁盘。

[[IMD,,,,PXDTruth] = pixelLabelTrainingData(gTruth,...“采样捕获器”,,,,5,,,,“写入”,文件夹名称);
Write images extracted for training to folder: /tmp/videoFrames Writing 20 images extracted from triangleVideo.avi...Completed.

Confirm that the temporary folder contains every fifth image.

imds.files
ans =20×1 cell{'/tmp/videoframes/trianglevideo01.png'} {'/tmp/videoframes/trianglevideo06.png'} {'/tmp/videoframes/trianglevideo11.png'}/tmp/videoframes/trianglevideo21.png'} {'/tmp/videoframes/trianglevideo26.png'} {'/tmp/videoframes/trianglevideo31.png'}/videoframes/trianglevideo41.png'} {'/tmp/videoframes/trianglevideo46.png'} {'/tmp/videoframes/trianglevideo51.png'}/trianglevideo61.png'} {'/tmp/videoframes/trianglevideo66.png'} {'/tmp/videofrianglevideo71.png'}。

Remove the video and images from the path.

rmpath(fullfile(VisionDatapath,'triangleImages');rmpath(fullfile(VisionDatapath,'triangleImages',,,,“测试标签”);

Input Arguments

collapse all

地面真相数据,指定为标量groundTruth对象或一个数组groundTruth对象。什么时候格特鲁斯is an array ofgroundTruth对象,,,,thelabeldefinitionsproperty of each object must contain the same pixel label names.

If you use custom data sources in格特鲁斯with parallel computing enabled, then the reader function is expected to work with a pool of MATLAB workers to read images from the data source in parallel.

名称值参数

Specify optional pairs of arguments asname1 = value1,...,namen = valuen,,,,where姓名是参数名称和Valueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

在R2021a之前,请使用逗号分隔每个名称和值,并附上姓名用引号。

Example:“采样捕获器”,,,,5

次采样图像的因素in the ground truth data source, specified an integer or a vector of integers. For a sampling factor ofn,,,,the returned training data includes everyn地面真相数据源中的图像。该功能忽略了用空标签数据忽略地面真相图像

Use sampled data to reduce repeated data, such as a sequence of images with the same scene and labels. It can also help in reducing training time.

Value Sampling Factor
整数 手动设置采样因子,以应用于所有数据。
整数向量 当您输入地面真相对象的向量时,该函数使用相应向量元素指定的采样因子。

图像文件格式,指定为逗号分隔对'ImageFormat'以及字符串标量或字符向量。文件格式必须由金宝appimwrite。This argument applies only forgroundTruth使用视频文件或自定义数据源创建的对象。

文件夹名称将提取的图像写入,指定为字符串标量或字符向量。指定的文件夹必须存在并且具有写入权限。

该论点仅适用于:

The function ignores this argument when:

  • 输入groundTruth目的was created from an image sequence data source.

  • The array of inputgroundTruth对象all contain image datastores using the same customread功能。

  • 任何输入groundTruth对象containing datastores, use the defaultreadfunctions.

图像文件格式,指定为字符串标量或字符向量。文件格式必须由金宝appimwrite

该论点仅适用于:

The function ignores this argument when:

  • 输入groundTruth目的was created from an image sequence data source.

  • The array of inputgroundTruth对象all contain image datastores using the same customread功能。

  • 任何输入groundTruth对象containing datastores, use the defaultreadfunctions.

Prefix for output image file names, specified as a string scalar or character vector. The image files are named as:

  _ 

The default value uses the name of the data source that the images were extracted from,strcat(sourceName,'_')用于视频和自定义数据源,或'datastore'对于图像数据存储。

该论点仅适用于:

The function ignores this argument when:

  • 输入groundTruth目的was created from an image sequence data source.

  • The array of inputgroundTruth对象all contain image datastores using the same customread功能。

  • 任何输入groundTruth对象containing datastores, use the defaultreadfunctions.

Display training progress on the MATLAB command line, specified as the comma-separated pair consisting of'Verbose'andtrueor错误的。This argument applies only forgroundTruth使用视频文件或自定义数据源创建的对象。

输出参数

collapse all

从地面tru中提取的图像集合th,格特鲁斯,返回n成像目的。Each image inIMD具有至少一类像素标签的注释。IMD忽略没有注释的图像。

Collection of pixel-labeled data extracted from the ground truth,格特鲁斯,返回PixelLabelDatastore目的。The object contains a categorical matrix of pixel labels for each image contained in the image datastore,IMD。Labels that do not correspond to pixel labels are ignored.

版本历史记录

在R2018A中引入