BandMath¶
输出单频图像,该图像是对多个多波段图像进行数学运算的结果。
描述¶
该应用程序对多个多波段图像执行数学运算,并将结果输出为单波段图像。在每个像素位置计算给定的表达式。数学公式的求值由muParser库完成。
可以使用以下命令来编写公式:
- 数值(2.3、-5、3.1e4、...)
- 包含像素值的变量(例如
im2b3是第二幅图像中的像素值,第三个频段) - 二元运算符:
+此外,-减法,*乘法,/分部^将x乘以y的幂<少于,>大于,<=小于或等于,>=大于或等于==平等,!=不相等||逻辑或,&&逻辑与- If-Then-Else运算符:
(condition ? value_true : value_false)
- 功能:
exp(),log(),sin(),cos(),min(),max()..
完整的功能和运算符列表可在muParser网站上找到 [1] 。
参数¶
Input image list -il image1 image2... Mandatory
Image list of operands to the mathematical expression.
Output Image -out image [dtype] Mandatory
Output image which is the result of the mathematical expressions on input image list operands.
Expression -exp string Mandatory
The muParser mathematical expression to apply on input images.
Available RAM (MB) -ram int Default value: 256
Available memory for processing (in MB).
实例¶
从命令行执行以下操作:
otbcli_BandMath -il verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif -out apTvUtBandMathOutput.tif -exp "cos( im1b1 ) > cos( im2b1 ) ? im3b1 : im3b2"
来自Python的评论:
import otbApplication
app = otbApplication.Registry.CreateApplication("BandMath")
app.SetParameterStringList("il", ['verySmallFSATSW_r.tif', 'verySmallFSATSW_nir.tif', 'verySmallFSATSW.tif'])
app.SetParameterString("out", "apTvUtBandMathOutput.tif")
app.SetParameterString("exp", "cos( im1b1 ) > cos( im2b1 ) ? im3b1 : im3b2")
app.ExecuteAndWriteOutput()