ImageClassifier

根据模型文件执行输入图像的分类。

描述

此应用程序基于由 TrainImagesClassifier 申请。输出图像的像素将包含由分类器决定的类别标签(最大类别标签=65535)。输入像素可以根据 ComputeImagesStatistics 申请。可以提供可选的输入掩码,在这种情况下,只有对应掩码值大于0的输入图像像素将被分类。默认情况下,输出图像中的其余像素将被赋予标签0。

这个应用程序有几个输出图像,并支持“多写”。不是独立地计算和写入每个图像,而是以同步的方式为每个输出写入流图像块。输出图像将逐条计算,使用可用的RAM计算条带大小,并且可以使用流扩展文件名(类型、模式和值)指定用户定义的流模式。请注意,可以使用多写扩展文件名选项禁用多写,在这种情况下,将逐个写入输出图像。请注意,MPI编写器不支持多重写入。

参数

Input Image -in image Mandatory
The input image to classify.

Input Mask -mask image
The mask restricts the classification of the input image to the area where mask pixel values are greater than 0.

Model file -model filename [dtype] Mandatory
A model file (produced by TrainImagesClassifier application, maximal class label = 65535).

Statistics file -imstat filename [dtype]
An XML file containing mean and standard deviation to center and reduce samples before classification (produced by ComputeImagesStatistics application).

Label mask value -nodatalabel int Default value: 0
By default, hidden pixels will have the assigned label 0 in the output image. It is possible to define the label mask by another value, but be careful not to use a label from another class (max. 65535).

Output Image -out image [dtype] Mandatory
Output image containing class labels

Confidence map -confmap image [dtype]
Confidence map of the produced classification. The confidence index depends on the model:

  • LibSVM:两个最高概率之间的差异(需要一个带有概率估计的模型,以便可以为每个样本计算类别概率)
  • 助推:票数之和
  • DecisionTree:(不支持)
  • KNearestNeighbors:具有相同标签的邻居数量
  • 神经网络:两种最高反应之间的差异
  • Normal Bayes:(不支持)
  • RandomForest:信心(多数派的得票率)。利润率(两个多数派选票的归一化差异)目前不可用。
  • 支持向量机:距离到边距(仅适用于两类模型)

Probability map -probamap image [dtype]
Probability of each class for each pixel. This is an image having a number of bands equal to the number of classes in the model. This is only implemented for the Shark Random Forest classifier at this point.

Available RAM (MB) -ram int Default value: 256
Available memory for processing (in MB).

Number of classes in the model -nbclasses int Default value: 20
The number of classes is required by the output of the probability map in order to set the number of output bands.

实例

从命令行执行以下操作:

otbcli_ImageClassifier -in QB_1_ortho.tif -imstat EstimateImageStatisticsQB1.xml -model clsvmModelQB1.svm -out clLabeledImageQB1.tif

来自Python的评论:

import otbApplication

app = otbApplication.Registry.CreateApplication("ImageClassifier")

app.SetParameterString("in", "QB_1_ortho.tif")
app.SetParameterString("imstat", "EstimateImageStatisticsQB1.xml")
app.SetParameterString("model", "clsvmModelQB1.svm")
app.SetParameterString("out", "clLabeledImageQB1.tif")

app.ExecuteAndWriteOutput()

局限性

输入图像必须与用于生成统计文件和支持向量机模型文件的图像具有相同的类型、顺序和波段数。如果TrainImages分类器在培训期间使用了统计文件,则必须使用相同的统计文件进行分类。如果使用输入蒙版,则其大小必须与输入图像大小匹配。