20.2. 使用OTB 应用程序#

OTB 应用程序旨在为用户提供许多实现的流程。这些应用程序可以直接通过多接口(命令行、图形界面、Python语言等)使用。 目前,有100多个按不同类别组织的应用程序。

20.2.1. 接口#

原则#

每个OTB 应用程序都包含一个流程,为其参数化和执行提供一组功能。 OTB 应用程序中使用的所有参数都经过标准化和类型化(图像、载体、文件夹、integer、floating等)。 这种形式主义使得任何OTB 应用程序都可以通过各种接口操作。

参数#

OTB 应用程序参数由键(参数的名称)和值标识。有多种类型的参数可用。 如 表 20.1 所示。显示了参数可以采用的不同类型的值。

表 20.1 参数值的类型#

Type

Designation

<int32>

32 bits signed integer (from ÿ2,147,483,648 to 2,147,483,647)

<float>

Simple precision floating point (32 bits)

<string>

String

<string list>

List of strings

<boolean>

Boolean

表 20.2 所示,总结了参数类型及其值类型。

表 20.2 类型的参数#

Type

Value

Description

Integer

<int32>

32 bits signed integer. Example: maximum iterations number.

Real

<float>

Single pecision floating point. Example:distance in cartographic units.

String

<string>

String. Example: field name.

Strings list

<string list>

Multiple strings.

Input file

<string>

A file of any kind, as input to an algorithm. For example: a classification rule contained in a text file.

Input files list

<string list>

Multiple input files.

Output file

<string>

A file of any kind, at the output of an algorithm. For example: a text file containing statistics.

Folder

<string>

A folder accessible on the file system of the machine.

Choice

<int32>,<float> or <string>

An entry among the elements of a list of values. For example: in the list {manual; Automatic}, a possible choice is “automatic”

Input image

<string>

An input image, in a format supported by GDAL

List of input images

<string list>

Multiple input images

Input vector data

<string>

An input vector data, in a format supported by GDAL

List of input vector data

<string list>

Multiple vector data

Output image [Pixel type]

<string> [<string>]

This parameter includes a string for the path to the output file and a pixel type for setting the pixel encoding of the output image. We will return to this parameter in section 5.2.2 of this chapter.

Output vector data

<string>

An output vector data, in a format supported by GDAL/OGR.

Radius

<int32>

The radius of a pixel neighborhood, in pixels percolumn and per line. For example: a square structuring element with a radius of 2 × 3 pixels defines a centered neighborhood of 5 × 7 pixels.

Parameters group

Multiple parameters

Complex input image

<string>

A complex input image (with a real part and an imaginary part), in a format supported by GDAL. For example: Synthetic Aperture Radar (SAR) imagery

Complex output image

<string>

Complex output image (e.g. SAR image)

RAM

<int32>

Amount of RAM that can be used by the algorithms (in megabytes)

InputProcessXML

<string>

Extensible Markup Language (XML) file to load the parameters of an execution of the application

OutputProcessXML

<string>

XML file to save the parameters of an execution of the application

在OTB 应用程序中,任何参数都可能是强制性的。 在这种情况下,如果未输入参数的值,则算法将不会执行,并且错误将报告丢失的参数。 某些参数扫描具有预定义的默认值。 还可以为数字值(整数和真实数字)输入最小值和最大值。

描述#

OTB 应用程序还集成了所实现的处理及其参数的文档。还输入应用程序作者和实现算法的限制。 一个或多个标签可以与应用程序关联,例如:

  • 图像分析;

  • 校准;

  • 变更检测;

  • 坐标;

  • 降维;

  • 特征提取;

  • 图像滤波;

  • 几何学;

  • 高光谱;

  • 学习;

  • 图像处理;

  • 图像元数据;

  • 图像多分辨率;

  • 泛锐化;

  • 光栅;

– SAR;

  • 立体声;

  • 细分;

  • 矢量数据操作。

20.2.2. 命令行界面#

该界面在UNIX(Linux、Mac OS X)上称为“终端”, 在Windows(cmd)中称为“DOS命令提示符”,使其可以通过图形界面调用程序并输出。 一开始对用户不太友好,该界面有很多优点,包括执行批处理的可能性,或自动化多个应用程序的序列。 命令行上使用OTB 应用程序的可执行文件集以“otbcli”为开头。

要在命令行中使用OTB 应用程序,首先可以从应用程序获取帮助。 让我们以 Convert 应用程序为例,它将一张图像转换为另一张图像。 在命令提示符(在Windows上)或终端(Linux或Mac OS X)中, 我们输入以下命令以获取帮助:

otbcli_Convert

与:

otbcli_Convert -help

此命令返回应用程序的描述、预期作为输入的参数以及命令行示例:

This is the Convert application, version 5.11.0
Convert an image to a different format, eventually rescaling the data
and/or changing the pixel type.
Complete documentation: http://www.orfeo-toolbox.org/Applications/Convert.html
Parameters:
 -progress <boolean> Report progress
MISSING -in <string> Input image (mandatory)
 -type <string> Rescale type
[none/linear/log2] (mandatory, default value is none)
 -type.linear.gamma <float> Gamma correction factor
(optional, on by default, default value is 1)
 -mask <string> Input mask (optional, off by
default)
 -hcp.high <float> High Cut Quantile (optional,
off by default, default value is 2)
 -hcp.low <float> Low Cut Quantile (optional,
off by default, default value is 2)
MISSING -out <string> [pixel] Output Image
[pixel=uint8/uint16/int16/uint32/int32/float/double] (default value is
float) (mandatory)
 -ram <int32> Available RAM (Mb) (optional,
off by default, default value is 128)
 -inxml <string> Load otb application from xml
file (optional, off by default)
Examples:
otbcli_Convert -in QB_Toulouse_Ortho_XS.tif -out
otbConvertWithScalingOutput.png uint8 -typ

从命令行 otbSYS_Convert 获得的 Convert 应用程序参数概述,如 表 20.3 所示。

表 20.3 转换应用程序参数#

Name

Type

Value

Mandatory

Default value

Progress

Boolean4

<boolean>

In

Input image

<string5 >

Yes

Type

Choice

<string>

“None”

type.linear.gamma

Floating point number

<float>

1

Mask

Input image

<string>

hcp.high

Floating point number

<float>

2

hcp.low

Floating point number

<float>

2

Out

Output image

<string>[<string>]

Yes

pixel=float

Ram

Integer

<int32>

128

Xml

InputProcessXML

<string>

“out”参数用于指示输出图像的路径。可选地,可以对 outputpixel 施加编码。 此编码可以按照文件的路径定义,并用空白分隔。正如应用程序所说,编码是一种选择。 如 表 20.4 所示。

表 20.4 可能的编码选择#

Name

Designation

uint8

8 bits unsigned integer.Values range: [0; 255]

int16

16 bits signed integer.Values range: [¨C32 768; 32 767]

uint16

16 bits unsigned integer.Values range: [0; 65 535]

int32

32 bits signed integer.Values range: [¨C2 147 483 648; 2 147 483 647]

uint32

32 bits unsigned integer. Values range: [0; 4 294 967 295]

Float

Single precision floating point (32 bits)

Double

Double precision floating point (64 bits)

备注:

  • 一些图像格式不允许所有编码(例如,一些JPEG2000驱动程序不支持浮点编码)。

  • 当像素的值范围不对应于编码时,输出图像上可能发生信息丢失。

在下面的示例中,指定了路径(“outputImage.tif”)和输出图像的编码(“uint8”)。 输出图像将为TIFF格式(扩展名 .tif ),其像素的编码将为8带符号位(值在0到255之间)。

otbcli_Convert -in inputImage.tif -out outputImage.tif uint8

20.2.3. 图形用户界面#

每个OTB 应用程序还可以通过图形用户界面(图形用户界面)使用。 该图形用户界面可以通过与按钮、可编辑字段和各种其他对话框交互来选择应用程序的参数。 允许我们通过图形界面使用OTB 应用程序的一组可执行文件以“otbgui”为开头。 当使用这些可执行文件时,会自动生成一个窗口并适应OTB 应用程序的内容。 在第一个选项卡中,可以访问应用程序的参数如 图 20.6 。 以下面板允许您关注应用程序的进度(“日志”和“进度”选项卡)。 界面的最后一个选项卡提供了应用程序及其参数的描述。

image163_x92

图 20.6 Convert应用程序的图形用户界面#

当前选项卡允许我们编辑应用程序参数,如 图 20.7

image164_xmi

图 20.7 Convert应用程序图形用户界面#

当前选项卡提供应用程序描述(红色)、有关其参数的信息(绿色)和使用示例(蓝色)。 有关该图形的彩色版本,请访问 www.iste.co.uk/baghdadi/qgis1.zip

20.2.4. 来自QGIS的使用#

QGIS是一个免费的、开源的、多平台地理信息系统(地理信息系统),根据通用公共许可证发布, 它提供了大量功能:管理大量的载体数据或数据库格式、基于Python的引擎脚本以及允许我们使用QGIS社区开发的模块的插件机制。

OTB 应用程序可以直接从QGIS调用。与上一节中介绍的图形用户界面类似,QIIS动态创建一个窗口, 以启用 OTB 应用程序参数化。

Python绑定#

由于绑定机制,可以使用Python编写的代码来使用OTB 应用程序。 OTB 应用程序可以与Python模块结合用于地理空间目的。还有将OTB 图像转换为NumPy数组的机制, 使OTB 应用程序与Python集成变得更加容易。

Monteverdi#

最后,OTB 包括一个名为Monteverdi的可视化软件。 该软件使我们能够以快速且用户友好的方式浏览图像集(例如系列或马赛克)。 它基于GL着色语言技术来提供实时动态显示功能,并基于OTB 功能来实时配准图像[MIC15]。 Monteverdi还允许完全访问应用程序的图形界面。加载到Monteverdi的图像可以拖放到应用程序中, 执行后生成的图像会自动加载到 MonteverdiMonteverdi 的图形界面, 如 图 20.8

image165_x1j

图 20.8 Monteverdi软件#

加载两个上沉积图像层并使用局部透明度工具。 有关该图的彩色版本,请参阅www.iste.co.uk/baghdadi/qgis1.zip

值得注意的是, Monteverdi 并不是像QGIS那样的完整地理信息系统软件, 并且仅限于图像可视化和应用程序的简化集成。 对于几何特征编辑或属性表操作等高级地理信息系统操作,建议结合使用 Monteverdi 和QGIS软件。