MultiImageSamplingRate¶
计算一组输入图像的采样率。
描述¶
该应用程序计算一组输入图像的采样率。在调用该应用程序之前,必须使用该应用程序分析每对图像和训练向量 PolygonClassStatistics 。然后使用统计文件来计算每个图像中每个类别的采样率。实现了几种类型的采样。每一种策略都是单一图像策略和多图像模式的结合。单一映像策略包括:
- 最小(默认):在每个类别中选择相同数量的样本,以便对最小的样本进行完全采样。
- 常量:在每个类别中选择相同数量的样本N(其中N小于或等于最小类别的大小)。
- By Class:手动设置每个类所需的数量,输入CSV文件(第一列为类名称,第二列为所需的样本数)。
多图像模式(MIM)分为成比例、相等和自定义。自定义模式允许用户选择样本在图像中的分布。不同的行为如下所述。Ti(C)和Ni(C)分别表示c类图像i中的总样本数和所需样本数。让我们称L为图像总数。
策略=全部
- 所有模式的行为都相同:采集所有样本
Strategy=Constant:让我们称M为每个类所需的全局样本数。对于每个图像i和每个类c:
- 如果mim=成比例,则Ni(C)=M*Ti(C)/sum_k(Tk(C))
- 如果MIM=等于,则Ni(C)=M/L
- 如果mim=CUSTOM,则Ni(C)=Mi,其中Mi是图像i的定制请求样本数
Strategy=byClass:让我们调用M(C)类的全局样本数)。对于每个图像i和每个类c:
- 如果mim=成比例,则Ni(C)=M(C)*Ti(C)/sum_k(Tk(C))
- 如果MIM=等于,则Ni(C)=M(C)/L
- 如果MIM=CUSTOM,则Ni(C)=Mi(C),其中Mi(C)是图像i和类别c的定制请求样本数
Strategy=Percent:对于每个图像i和每个类c:
- 如果mim=成比例,则Ni(C)=p*Ti(C),其中p是样本的全局百分比
- 如果mim=等于,则Ni(C)=p*sum_k(Tk(C)]/L,其中p是样本的全局百分比
- 如果MIM=CUSTOM,则Ni(C)=p(I)*Ti(C),其中p(I)是图像I.c的样本百分比
Strategy=Total:对于每个图像i和每个类c:
- 如果MIM=成比例,则Ni(C)=总 * (sum_k(Ti(k))/sum_kl(Tl(k))) * (ti(C)/sum_k(Ti(K),其中Total是指定的样本总数。
- 如果mim=等于,则Ni(C)=(总数/L)*(Ti(C)/sum_k(Ti(K),其中TOTAL是指定的样本总数。
- 如果MIM=CUSTOM,则Ni(C)=TOTAL(I)*(Ti(C)/sum_k(Ti(K),其中TOTAL(I)是为图像I指定的样本总数。
策略=最小类
- 如果mim=成比例,则最小类大小(全局计算)用于策略常量+成比例。
- 如果MIM=EQUAL,则最小类大小(全局计算)用于策略常量+EQUAL。
- 如果MIM=CUSTOM,则计算最小类并将其分别用于每个图像。
参数¶
Input statistics -il filename1 filename2...
Mandatory
List of statistics files for each input image.
Output sampling rates -out filename [dtype]
Mandatory
Output filename storing sampling rates (CSV format with class name, required samples, total samples, and rate). The given filename will be used with a suffix to indicate the corresponding input index (for instance: rates.csv will give rates_1.csv, rates_2.csv, ...).
Sampling strategy -strategy [byclass|constant|smallest|percent|total|all]
Default value: smallest
- Set samples count for each class
Set samples count for each class - Set the same samples counts for all classes
Set the same samples counts for all classes - Set same number of samples for all classes, with the smallest class fully sampled
Set same number of samples for all classes, with the smallest class fully sampled - Use a percentage of the samples available for each class
Use a percentage of the samples available for each class - Set the total number of samples to generate, and use class proportions.
Set the total number of samples to generate, and use class proportions. - Use all samples
Use all samples
设置每个类别的样本计数选项¶
Number of samples by class -strategy.byclass.in filename1 filename2...
Mandatory
Number of samples by class (CSV format with class name in 1st column and required samples in the 2nd).In the case of the custom multi-image mode, several inputs may be given for each image.
为所有类设置相同的样本数选项¶
Number of samples for all classes -strategy.constant.nb string
Mandatory
Number of samples for all classes.In the case of the custom multi-image mode, several values can be given for each image.
使用每个类别选项可用的样本的百分比¶
The percentage(s) to use -strategy.percent.p string
Mandatory
The percentage(s) to use In the case of the custom multi-image mode, several values can be given for each image.
设置要生成的样本总数,并使用类别比例。选项¶
The number of samples to generate -strategy.total.v string
Mandatory
The number of samples to generateIn the case of the custom multi-image mode, several values can be given for each image.
Multi-Image Mode -mim [proportional|equal|custom]
Default value: proportional
- Proportional
Split the required number of samples proportionally - equal
Equal split of the required number of samples - Custom
Split the number of samples based on the user's choice.
实例¶
从命令行执行以下操作:
otbcli_MultiImageSamplingRate -il stats_1.xml stats_2.xml -out rates.csv -strategy smallest -mim proportional
来自Python的评论:
import otbApplication
app = otbApplication.Registry.CreateApplication("MultiImageSamplingRate")
app.SetParameterString("out", "rates.csv")
app.SetParameterString("strategy","smallest")
app.SetParameterString("mim","proportional")
app.ExecuteAndWriteOutput()