主要内容

semanticSegmentationMetrics

Semantic segmentation quality metrics

Description

AsemanticSegmentationMetricsobject encapsulates semantic segmentation quality metrics for a set of images.

Creation

创建一个semanticSegmentationMetricsobject using theevaluateSemanticSegmentationfunction.

Properties

expand all

此属性仅阅读。

混淆矩阵, specified as a table withCrows and columns, whereCis the number of classes in the semantic segmentation. Each table element (i,j)是已知属于类的像素的数量ibut predicted to belong to classj

此属性仅阅读。

归一化混淆矩阵,指定为具有Crows and columns, whereCis the number of classes in the semantic segmentation. Each table element (i,j)是已知属于类的像素的数量ibut predicted to belong to classj, divided by the total number of pixels predicted in classj。元素在[0,1]范围内。

此属性仅阅读。

Semantic segmentation metrics aggregated over the data set, specified as a table with one row.数据集对象最多有五列,对应于由“指标”使用的名称值对evaluateSemanticSegmentation:

  • GlobalAccuracy- 正确分类像素与总像素的比率,无论类别如何。

  • 卑鄙的准确性- 每个类中正确分类的像素与总像素的比率,在所有类上平均。值等于ClassMetrics.Accuracy

  • MeanIoU— Average intersection over union (IoU) of all classes. The value is equal to the mean ofClassMetrics.IoU

  • WeightedIoU- 所有课程的平均值,由类中的像素数量加权。

  • MeanBFScore- 所有图像的平均边界F1(BF)得分。值等于ImageMetrics。BFScore。创建一个指标,当您创建一个指标semanticSegmentationMetricsobject by using a confusion matrix as the input toevaluateSemanticSegmentation

此属性仅阅读。

每个类的语义分割指标,指定为一个表格C行,哪里Cis the number of classes in the semantic segmentation.ClassMetricshas up to three columns, corresponding to the metrics that were specified by the“指标”使用的名称值对evaluateSemanticSegmentation:

  • 准确性— Ratio of correctly classified pixels in each class to the total number of pixels belonging to that class according to the ground truth. Accuracy can be expressed as:

    准确性=(TP + TN) /(TP + TN + FP + FN)

    Positive Negative
    Positive TP:真正的积极 FN: False Negative
    Negative FP:误报 TN:真正的负面

    TP:真正的阳性和FN是虚假负面的数量。

  • iou— Ratio of correctly classified pixels to the total number of pixels that are assigned that class by the ground truth and the predictor. IoU can be expressed as:

    iou= tp /(tp + fp + fn)

    该图像描述了真实的阳性(TP),误报(FP)和假阴性(FN)。

  • MeanBFScore- 每个班级的边界F1得分,平均在所有图像上。创建一个指标,当您创建一个指标semanticSegmentationMetricsobject by using a confusion matrix as the input toevaluateSemanticSegmentation

此属性仅阅读。

Semantic segmentation metrics for each image in the data set, specified as a table withN行,哪里N是数据集中的图像数量。ImageMetrics最多有五列,对应于由“指标”使用的名称值对evaluateSemanticSegmentation:

  • GlobalAccuracy- 正确分类像素与总像素的比率,无论类别如何。

  • 卑鄙的准确性— Ratio of correctly classified pixels to total pixels, averaged over all classes in the image.

  • MeanIoU— Average IoU of all classes in the image.

  • WeightedIoU— Average IoU of all classes in the image, weighted by the number of pixels in each class.

  • MeanBFScore— Average BF score of each class in the image. This metric is not available when you create asemanticSegmentationMetricsobject by using a confusion matrix as the input toevaluateSemanticSegmentation

每个图像度量均返回一个向量,其中一个图像中的每个图像中的一个元素。行的顺序与输入定义的图像的顺序匹配Pixellabeldatastore代表数据集的对象。

Examples

collapse all

The三角形图data set has 100 test images with ground truth labels. Define the location of the data set.

dataSetDir = fullfile(toolboxdir('vision'),'visiondata',“三角形图”);

Define the location of the test images.

testImagesDir = fullfile(dataSetDir,“证词”);

定义地面真相标签的位置。

testLabelsDir = fullfile(datasetDir,'testLabels');

创建一个n imageDatastore holding the test images.

imds = imageDatastore(testImagesDir);

定义类名称及其关联的标签ID。

classNames = [“三角形”,“背景”]; labelIDs = [255 0];

创建一个pixelLabelDatastore holding the ground truth pixel labels for the test images.

pxdsTruth = pixelLabelDatastore(testLabelsDir,classNames,labelIDs);

Load a semantic segmentation network that has been trained on the training images of三角形图

net = load('triangleSegmentationNetwork'); net = net.net;

在测试图像上运行网络。预测标签被写入临时目录中的磁盘,并以Pixellabeldatastastore返回。

pxdsResults = semanticseg(imds,net,"WriteLocation",tempdir);
Running semantic segmentation network ------------------------------------- * Processed 100 images.

评估针对地面真理的预测结果。

metrics = evaluateSemanticSegmentation(pxdsResults,pxdsTruth);
Evaluating semantic segmentation results ---------------------------------------- * Selected metrics: global accuracy,班级准确性,iou,加权iou,bf得分。*处理了100张图像。*完成...完成。* Data set metrics: GlobalAccuracy MeanAccuracy MeanIoU WeightedIoU MeanBFScore ______________ ____________ _______ ___________ ___________ 0.90624 0.95085 0.61588 0.87529 0.40652

显示semanticSegmentationMetrics目的。

metrics
指标=具有属性的smanticanticsementicationmetrics:ConfusionMatrix:[2x2表]归一化confusionMatrix:[2x2表] dataSetmetrics:[1x5表] classmetrics:[2x3 Table] ImageMetrics:[100x5表]:[100x5表]

Display the classification accuracy, the intersection over union, and the boundary F-1 score for each class. These values are stored in theClassMetricsproperty.

metrics.ClassMetrics
ans=2×3桌准确性iouMeanBFScore ________ _______ ___________ triangle 1 0.33005 0.028664 background 0.9017 0.9017 0.78438

Display the normalized confusion matrix that is stored in theNormalizedConfusionMatrixproperty.

指标。注册matrix
ans=2×2 tabletriangle background ________ __________ triangle 4730 0 background 9601 88069
Introduced in R2017b