Orfeo ToolBox Cook Book
Orfeo ToolBox Cook Book
Orfeo ToolBox Cook Book
Release 6.6.0
OTB Team
2 Installation 3
2.1 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 Python bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.2 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.1 System dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Caveat on OTB 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.3 Python bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.4 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 MacOS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.1 Python bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.2 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Other packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4.1 Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4.2 Ubuntu 12.04 and higher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4.3 OpenSuse 12.X and higher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 Monteverdi 23
4.1 Main menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 Top toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.3 Image displaying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.4 Right side dock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.5 Layer stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.5.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.6 Optical calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.7 BandMath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.8 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.9 Polarimetry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
i
4.10 Pansharpening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.11 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5 Advanced Use 39
5.1 Environment variables that affects Orfeo ToolBox . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 Extended filenames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.1 Reader options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.2.2 Writer options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.2.3 OGR DataSource options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6 Recipes 45
6.1 From raw image to calibrated product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.1.1 Optical radiometric calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.1.2 Pan-sharpening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.1.3 Digital Elevation Model management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.1.4 Ortho-rectification and map projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.2 SAR processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.2.1 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.2.2 Despeckle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.2.3 Polarimetry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
6.3 Residual registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.3.1 Extract metadata from the image reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.3.2 Extract homologous points from images . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.3.3 Geometry refinement using homologous points . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3.4 Orthorectify image using the affine geometry . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.4 Image processing and information extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.4.1 Simple calculus with channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.4.2 Images with no-data values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.4.3 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.4.4 Large-Scale Mean-Shift (LSMS) segmentation . . . . . . . . . . . . . . . . . . . . . . . . 78
6.4.5 Dempster Shafer based Classifier Fusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.5 BandMathImageFilterX (based on muParserX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.5.1 Fundamentals: headers, declaration and instantiation . . . . . . . . . . . . . . . . . . . . . 82
6.5.2 Syntax: first elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.5.3 New operators and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.5.4 Application Programming Interface (API) . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.6 Enhance local contrast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.6.1 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.6.2 Advanced parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.7 Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.7.1 Feature classification and training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.7.2 Pixel based classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.7.3 Unsupervised learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.7.4 Fusion of classification maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.7.5 Majority voting based classification map regularization . . . . . . . . . . . . . . . . . . . . 103
6.7.6 Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.8 Feature extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.8.1 Local statistics extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.8.2 Edge extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.8.3 Radiometric indices extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.8.4 Morphological features extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
6.8.5 Textural features extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
6.9 Stereoscopic reconstruction from VHR optical images pair . . . . . . . . . . . . . . . . . . . . . . . 113
ii
6.9.1 Estimate epipolar geometry transformation . . . . . . . . . . . . . . . . . . . . . . . . . . 114
6.9.2 Resample images in epipolar geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
6.9.3 Disparity estimation: Block matching along epipolar lines . . . . . . . . . . . . . . . . . . 115
6.9.4 From disparity to Digital Surface Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
6.9.5 One application to rule them all in multi stereo framework scheme . . . . . . . . . . . . . . 120
6.9.6 Stereo reconstruction good practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
6.9.7 Algorithm outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
6.10 OTB processing in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
6.10.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
6.10.2 Numpy array processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
6.10.3 In-memory connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
6.10.4 Interactions with OTB pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.10.5 Corner cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
iii
7.4.7 ImageEnvelope - Image Envelope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
7.4.8 OrthoRectification - Ortho-rectification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
7.4.9 Pansharpening - Pansharpening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
7.4.10 RefineSensorModel - Refine Sensor Model . . . . . . . . . . . . . . . . . . . . . . . . . . 220
7.4.11 RigidTransformResample - Image resampling with a rigid transform . . . . . . . . . . . . . 223
7.4.12 Superimpose - Superimpose sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
7.5 Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.5.1 ClassificationMapRegularization - Classification Map Regularization . . . . . . . . . . . . . 228
7.5.2 ComputeConfusionMatrix - Confusion matrix Computation . . . . . . . . . . . . . . . . . . 230
7.5.3 ComputeImagesStatistics - Compute Images second order statistics . . . . . . . . . . . . . . 233
7.5.4 FusionOfClassifications - Fusion of Classifications . . . . . . . . . . . . . . . . . . . . . . 234
7.5.5 ImageClassifier - Image Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
7.5.6 ImageDimensionalityReduction - Image Dimensionality Reduction . . . . . . . . . . . . . . 239
7.5.7 KMeansClassification - Unsupervised KMeans image classification . . . . . . . . . . . . . 240
7.5.8 MultiImageSamplingRate - Multi-image sampling rate estimation . . . . . . . . . . . . . . 243
7.5.9 PolygonClassStatistics - Polygon Class Statistics . . . . . . . . . . . . . . . . . . . . . . . 246
7.5.10 PredictRegression - Predict Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
7.5.11 SOMClassification - SOM Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
7.5.12 SampleAugmentation - Sample Augmentation . . . . . . . . . . . . . . . . . . . . . . . . . 252
7.5.13 SampleExtraction - Sample Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
7.5.14 SampleSelection - Sample Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
7.5.15 TrainDimensionalityReduction - Train Dimensionality Reduction . . . . . . . . . . . . . . 259
7.5.16 TrainImagesClassifier - Train a classifier from multiple images . . . . . . . . . . . . . . . . 262
7.5.17 TrainRegression - Train a regression model . . . . . . . . . . . . . . . . . . . . . . . . . . 270
7.5.18 TrainVectorClassifier - Train Vector Classifier . . . . . . . . . . . . . . . . . . . . . . . . . 277
7.5.19 VectorClassifier - Vector Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
7.5.20 VectorDimensionalityReduction - Vector Dimensionality Reduction . . . . . . . . . . . . . 286
7.6 Image Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
7.6.1 ColorMapping - Color Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
7.6.2 ConcatenateImages - Images Concatenation . . . . . . . . . . . . . . . . . . . . . . . . . . 292
7.6.3 DEMConvert - DEM Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
7.6.4 DownloadSRTMTiles - Download or list SRTM tiles related to a set of images . . . . . . . . 295
7.6.5 DynamicConvert - Dynamic Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
7.6.6 ExtractROI - Extract ROI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
7.6.7 ManageNoData - No Data management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
7.6.8 MultiResolutionPyramid - Multi Resolution Pyramid . . . . . . . . . . . . . . . . . . . . . 304
7.6.9 Quicklook - Quick Look . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
7.6.10 ReadImageInfo - Read image information . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
7.6.11 SplitImage - Split Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
7.6.12 TileFusion - Image Tile Fusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
7.7 SAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
7.7.1 ComputeModulusAndPhase - Compute Modulus And Phase . . . . . . . . . . . . . . . . . 313
7.7.2 SARDeburst - SAR Deburst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
7.7.3 SARDecompositions - SARDecompositions . . . . . . . . . . . . . . . . . . . . . . . . . . 316
7.7.4 SARPolarMatrixConvert - SARPolarMatrixConvert . . . . . . . . . . . . . . . . . . . . . . 319
7.7.5 SARPolarSynth - SARPolarSynth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
7.8 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
7.8.1 ComputeOGRLayersFeaturesStatistics - ComputeOGRLayersFeaturesStatistics . . . . . . . 325
7.8.2 ConnectedComponentSegmentation - Connected Component Segmentation . . . . . . . . . 326
7.8.3 HooverCompareSegmentation - Hoover compare segmentation . . . . . . . . . . . . . . . . 328
7.8.4 LSMSSegmentation - Exact Large-Scale Mean-Shift segmentation, step 2 . . . . . . . . . . 330
7.8.5 LSMSSmallRegionsMerging - Exact Large-Scale Mean-Shift segmentation, step 3 (optional) 333
7.8.6 LSMSVectorization - Exact Large-Scale Mean-Shift segmentation, step 4 . . . . . . . . . . 335
7.8.7 LargeScaleMeanShift - Large-Scale MeanShift . . . . . . . . . . . . . . . . . . . . . . . . 337
iv
7.8.8 OGRLayerClassifier - OGRLayerClassifier . . . . . . . . . . . . . . . . . . . . . . . . . . 339
7.8.9 Segmentation - Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
7.9 Vector Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
7.9.1 ConcatenateVectorData - Concatenate Vector Data . . . . . . . . . . . . . . . . . . . . . . 345
7.9.2 Rasterization - Rasterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
7.9.3 VectorDataExtractROI - VectorData Extract ROI . . . . . . . . . . . . . . . . . . . . . . . 349
7.9.4 VectorDataReprojection - Vector Data reprojection . . . . . . . . . . . . . . . . . . . . . . 350
7.9.5 VectorDataSetField - Vector data set field . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
7.9.6 VectorDataTransform - Vector Data Transformation . . . . . . . . . . . . . . . . . . . . . . 354
7.10 Image Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
7.10.1 ContrastEnhancement - Contrast Enhancement . . . . . . . . . . . . . . . . . . . . . . . . 356
7.10.2 Despeckle - Despeckle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
7.10.3 DimensionalityReduction - Dimensionality reduction . . . . . . . . . . . . . . . . . . . . . 362
7.10.4 DomainTransform - DomainTransform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
7.10.5 MeanShiftSmoothing - MeanShift Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . 367
7.10.6 Smoothing - Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
7.11 Deprecated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
7.11.1 Convert - Image Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
7.11.2 Rescale - Rescale Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
7.12 Change Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
7.12.1 MultivariateAlterationDetector - Multivariate Alteration Detector . . . . . . . . . . . . . . . 376
7.13 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
7.13.1 OpticalCalibration - Optical calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
7.13.2 SARCalibration - SAR Radiometric calibration . . . . . . . . . . . . . . . . . . . . . . . . 382
v
8.7.1 I want to contribute to OTB, where to begin? . . . . . . . . . . . . . . . . . . . . . . . . . 390
8.7.2 What are the benefits of contributing to OTB? . . . . . . . . . . . . . . . . . . . . . . . . . 390
8.7.3 What functionality can I contribute? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
8.8 Running the tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
8.8.1 What are the tests? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
8.8.2 How to run the tests? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
8.8.3 How to get the test data? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
8.8.4 How to submit the results? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
8.8.5 What features will the OTB include and when? . . . . . . . . . . . . . . . . . . . . . . . . 391
vi
CHAPTER
ONE
Orfeo ToolBox (OTB) is an open-source project for state-of-the-art remote sensing. Built on the shoulders of the
open-source geospatial community, it can process high resolution optical, multispectral and radar images at the ter-
abyte scale. A wide variety of applications are available: from ortho-rectification or pansharpening, all the way to
classification, SAR processing, and much more!
All of OTB’s algorithms are accessible from Monteverdi, QGIS, Python, the command line or C++. Monteverdi is an
easy to use visualization tool with an emphasis on hardware accelerated rendering for high resolution imagery (optical
and SAR). With it, end-users can visualize huge raw imagery products and access all of the applications in the toolbox.
From resource limited laptops to high performance MPI clusters, OTB is available on Windows, Linux and Mac. It is
community driven, extensible and heavily documented. Orfeo ToolBox is not a black box!
This is the CookBook documentation for users. If you are new to OTB and Monteverdi, start here. It will go through
how to install OTB on your system, how to start using Monteverdi and OTB applications to view and process your
data, and recipes on how to accomplish typical remote sensing tasks. Finally, there is also documentation on every
application shipped with OTB.
Get started now with the Installation chapter.
Get help, share your experience and contribute to the Orfeo-Toolbox project by joining our community and users
mailing list.
For other documentation, be sure to read:
• OTB’s website: www.orfeo-toolbox.org
• OTB Software Guide for advanced users and developers. The software guide contains documented code exam-
ples, descriptions of the ITK pipeline model, multithreading and streaming functionalities, and an introduction
to the C++ API.
• Doxygen, for exhaustive documentation of the C++ API.
1
OTB CookBook Documentation, Release 6.6.0
TWO
INSTALLATION
Windows
Windows binary packages are available for Windows 7 or higher. They can be downloaded from otb download page .
Pick the correct version (32 bit or 64 bit) depending on your system.
Extract the archive and use one of the launchers, they contain all applications and their launchers (both command line
and graphical launchers are provided):
• monteverdi.bat: A launcher script for Monteverdi
• mapla.bat: A launcher script for Mapla
• otbenv.bat: A script to initialize the environment for OTB executables
• bin: A folder containing application launchers (otbcli.bat, otbgui.bat) and the DLLs.
• lib: A folder containing application DLLs.
• include: A folder containing all the necessary headers to compile OTB based projects.
• tool: A folder containing useful scripts to test the installation or to uninstall OTB libraries and headers while
keeping all the dependencies.
The applications can be launched from the Mapla launcher. If you want to use the otbcli and otbgui launchers, you
can initialize a command prompt with otbenv.bat.
The package can be used to compile other projects using OTB (binaries, libraries and headers are included). If you want
to build OTB from source using this package, you should first uninstall the specific OTB files from the package to leave
only the dependencies (what we call an XDK). You can do it using the supplied script tools/uninstall_otb.
bat.
3
OTB CookBook Documentation, Release 6.6.0
In the package you also have a template project for Visual 2015 OTB Project.zip. This template can
be placed in your user Visual 2015 template directory : %USERPROFILE%\Documents\Visual Studio
2015\Templates\ProjectTemplates. The script start_devenv.bat allows to copy the template in that
folder and start Visual Studio.
Python bindings
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed with binary package. With OTB 6.4.0, additional
bindings for Python 3.5 are also included. Please note that using a different Python version may not be compatible
with OTB wrappings. If no compatible Python 2.x version is found a notification is generated during the installation
process. If the installation completes without issue, information relating to your Python bindings will be provided.
You must have Python numpy bindings installed in your system. They can be installed locally without admin rights
as follows: “pip install –user numpy”. This is to give users the option to select their own existing Python installation
rather than the one dibstributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the otbenv script. If you want to use bindings for Python
3.5, you can copy this script and modify:
• lib/python into lib/python3, for variable PYTHONPATH
Notes
• You must have “Visual C++ Redistributable for Visual Studio 2015” installed for using this package. It can be
downloaded freely from microsoft
Linux
We provide a binary package for GNU/Linux x86_64. This package includes all of the OTB applications along with
command line and graphical launchers. It can be downloaded from OTB’s download page.
This package is a self-extractable archive. You may uncompress it with a double-click on the file, or from the command
line as follows:
chmod +x OTB-6.6.0-Linux64.run
./OTB-6.6.0-Linux64.run
The self-extractable archive only needs common tools found on most Linux distributions (“sed”, “grep”, “find”, “cat”,
“printf”, “ln”, ...). However, be aware that it requires tools such as “which” and “file” (they are not always present, for
instance when building a container).
Please note that the resulting installation is not meant to be moved, you should uncompress the archive in its final
location. Once the archive is extracted, the directory structure consists of:
• monteverdi.sh: A launcher script for Monteverdi
• mapla.sh: A launcher script for Mapla
• otbenv.profile: A script to initialize the environment for OTB executables
• bin: A folder containing application launchers (otbcli.sh, otbgui.sh), Monteverdi and Mapla.
• lib: A folder containing all shared libraries and OTB applications.
• include: A folder containing all the necessary headers to compile OTB based projects.
• share: A folder containing common resources and copyright mentions.
4 Chapter 2. Installation
OTB CookBook Documentation, Release 6.6.0
• tool: A folder containing useful scripts to test the installation or to uninstall OTB libraries and headers while
keeping all the dependencies.
The applications can be launched from the Mapla launcher. If you want to use the otbcli and otbgui launchers, you
can initialize your environment with source otbenv.profile.
The package can be used to compile other projects using OTB (binaries, libraries and headers are included). If you want
to build OTB from source using this package, you should first uninstall the specific OTB files from the package to leave
only the dependencies (what we call an XDK). You can do it using the supplied script tools/uninstall_otb.
sh.
System dependencies
In order to run the command line launchers, this package doesn’t require any special library that is not present in most
modern Linux distributions. The graphical executable (otbgui launchers, Monteverdi and Mapla) use the X11 libraries,
which are widely used in a lot of distributions:
Monteverdi also requires the standard graphics libraries libgl1 and libglu1. Make sure you have at least one version
of them installed in your system.
In OTB 6.0 binaries, there is a small caveat for “expat” as the supplied binaries depend on “libexpat.so”, which is not
contained in the package. It can be supplied by most package managers (apt, yum, ...). If not already present, it is
necessary to install one of the following packages:
libexpat-dev libexpat1-dev
Python bindings
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed with binary package. With OTB 6.4.0, additional
bindings for Python 3.5 are also included. Please note that using a different Python version may not be compatible
with OTB wrappings. If no compatible Python 2.x version is found a notification is generated during the installation
process. If the installation completes without issue, information relating to your Python bindings will be provided.
You must have Python NumPy bindings installed in your system. They can be installed locally without admin rights
as follows: “pip install –user numpy”. This is to give users the option to select their own existing Python installation
rather than the one distributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the otbenv script. If you want to use bindings for Python
3.5, you can copy this script and modify:
• lib/python into lib/python3, for variable PYTHONPATH
Notes:
• You must use monteverdi and mapla through mapla.sh and monteverdi.sh helper scripts in extracted
directory.
• The helper scripts for monteverdi and mapla set required environment variables
• You might be tempted to move “OTB-6.6.0-Linux64” into another location say /usr/local/ after extraction. But
avoid this action!
2.2. Linux 5
OTB CookBook Documentation, Release 6.6.0
FAQ
MacOS X
We provide for MacOS X through a standalone package. This package is a self-extractible archive, quite similar to the
Linux one. You may uncompress it with the command line:
chmod +x OTB-6.6.0-Darwin64.run
./OTB-6.6.0-Darwin64.run
Once the archive is extracted, you can see OTB-6.6.0-Darwin64 directory in the same direcrtory along with OTB-
6.6.0-Darwin64.run
Contents of OTB-6.6.0-Darwin64 is briefly listed below:
• Monteverdi.app: A Mac OSX .app for Monteverdi
• Mapla.app: A Mac OSX .app for Mapla.
• bin: A folder containing application launchers (otbcli.sh, otbgui.sh), monteverdi and mapla binaries.
• lib: A folder containing all shared libraries and OTB applications.
• include: A folder containing all the necessary headers to compile OTB based projects.
• share: A folder containing common resources and copyright mentions.
• tool: A folder containing useful scripts to test the installation or to uninstall OTB libraries and headers while
keeping all the dependencies.
The applications can be launched from the Mapla launcher. If you want to use the otbcli and otbgui launchers, you
can initialize your environment with source otbenv.profile.
The package can be used to compile other projects using OTB (binaries, libraries and headers are included). If you want
to build OTB from source using this package, you should first uninstall the specific OTB files from the package to leave
only the dependencies (what we call an XDK). You can do it using the supplied script tools/uninstall_otb.
sh.
6 Chapter 2. Installation
OTB CookBook Documentation, Release 6.6.0
Python bindings
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed with binary package. With OTB 6.4.0, additional
bindings for Python 3.5 are also included. Please note that using a different Python version may not be compatible
with OTB wrappings. If no compatible Python 2.x version is found a notification is generated during the installation
process. If the installation completes without issue, information relating to your Python bindings will be provided.
You must have Python numpy bindings installed in your system. They can be installed locally without admin rights
as follows: “pip install –user numpy”. This is to give users the option to select their own existing Python installation
rather than the one dibstributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the otbenv script. If you want to use bindings for Python
3.5, you can copy this script and modify:
• lib/python into lib/python3, for variable PYTHONPATH
Notes:
• If you want to use the otbcli and otbgui launchers, you must access them via a terminal prompt.
• The OSX .app are provided for monteverdi (viewer) and mapla (application browser).
• You must use monteverdi and mapla through their .app files only.
• You are allowed to move these .app files and refrain from moving or deleting OTB-6.6.0-Darwin64 after extrac-
tion. In case you need to have OTB installed in some other directory. Extract the .run file there.
FAQ
A: You can get this error at startup running Monteverdi.app or Mapla.app. The solution is to run in a terminal the
following command:
xcode-select --install
Other packages
Warning! These packages may not be up-to-date with latest OTB releases. In addition, some features of the library
may not be available on every platform. Some of these are not maintained by OTB-team. If you want to get involved
in the packaging of OTB for your favourite platform, please contact us through the developer’s mailing list: otb-
[email protected].
Debian
There are OTB packages for Debian (unstable) since version 5.2.0. OTB Applications packages may be available as
Debian packages through APT repositories:
• otb-bin for command line applications
For Ubuntu 12.04 and higher, OTB Applications packages may be available as Debian packages through APT reposi-
tories:
• otb-bin for command line applications
• otb-bin-qt for Qt applications
• python-otb for python applications
Since release 3.14.1, OTB Applications packages are available in the ubuntugis-unstable repository.
Since release 5.2.0, the Ubuntu packages derive from the Debian packages.
You can add it by using these command-lines:
If you are using Synaptic, you can add the repositories, update and install the packages through the graphical interface.
For further information about Ubuntu packages go to ubuntugis-unstable launchpad page and click on Read about
installing.
apt-add-repository will try to retrieve the GPG keys of the repositories to certify the origin of the packages. If you are
behind a http proxy, this step won’t work and apt-add-repository will stall and eventually quit. You can temporarily
ignore this error and proceed with the update step. Following this, aptitude update will issue a warning about a
signature problem. This warning won’t prevent you from installing the packages.
For OpenSuse 12.X and higher, OTB Applications packages are available through zypper.
First, you need to add the appropriate repositories with the following commands (please replace 11.4 with your version
of OpenSuse):
sudo zypper ar
http://download.opensuse.org/repositories/games/openSUSE_11.4/ Games
sudo zypper ar
http://download.opensuse.org/repositories/Application:/Geo/openSUSE_11.4/ GEO
sudo zypper ar
http://download.opensuse.org/repositories/home:/tzotsos/openSUSE_11.4/ tzotsos
8 Chapter 2. Installation
OTB CookBook Documentation, Release 6.6.0
Alternatively you can use the One-Click Installer from the openSUSE Download page or add the above repositories
and install through Yast Package Management.
There is also support for the recently introduced ’rolling’ openSUSE distribution named ’Tumbleweed’. For Tumble-
weed you need to add the following repositories with these command-lines:
sudo zypper ar
http://download.opensuse.org/repositories/games/openSUSE_Tumbleweed/ Games
sudo zypper ar
http://download.opensuse.org/repositories/Application:/Geo/openSUSE_Tumbleweed/ GEO
sudo zypper ar
http://download.opensuse.org/repositories/home:/tzotsos/openSUSE_Tumbleweed/ tzotsos
10 Chapter 2. Installation
CHAPTER
THREE
OTB ships with more than 90 ready to use applications for remote sensing tasks. They usually expose existing pro-
cessing functions from the underlying C++ library, or integrate them into high level pipelines. OTB applications allow
the user to:
• Combine two or more functions from the Orfeo ToolBox,
• Provide a high level interface to handle: input and output data, definition of parameters and communication with
the user.
OTB applications can be launched in different ways, and accessed from different entry points. While the framework
can be extended, the Orfeo ToolBox ships with the following:
• A command-line launcher, to call applications from the terminal,
• A graphical launcher, with an auto-generated QT interface, providing ergonomic parameters setting, display of
documentation, and progress reporting,
• A SWIG interface, which means that any application can be loaded set-up and executed into a high-level lan-
guage such as Python or Java for instance.
• QGIS plugin built on top of the SWIG/Python interface is available with seamless integration within QGIS.
The complete list of applications is described in the Applications Reference Documentation.
All standard applications share the same implementation and expose automatically generated interfaces. Thus, the
command-line interface is prefixed by otbcli_, while the Qt interface is prefixed by otbgui_. For instance, calling
otbcli_Convert will launch the command-line interface of the Convert application, while otbgui_Convert
will launch its GUI.
Command-line launcher
The command-line application launcher allows to load an application plugin, to set its parameters, and execute it using
the command line. Launching the otbApplicationLauncherCommandLine without argument results in the
following help to be displayed:
$ otbApplicationLauncherCommandLine
Usage: ./otbApplicationLauncherCommandLine module_name [MODULEPATH] [arguments]
The module_name parameter corresponds to the application name. The [MODULEPATH] argument is optional and
allows the path to the shared library (or plugin) correpsonding to the module_name to be passed to the launcher.
It is also possible to set this path with the environment variable OTB_APPLICATION_PATH, making the
[MODULEPATH] optional. This variable is checked by default when no [MODULEPATH] argument is given. When
using multiple paths in OTB_APPLICATION_PATH, one must make sure to use the standard path separator of the
target system, which is : on Unix and ; on Windows.
11
OTB CookBook Documentation, Release 6.6.0
An error in the application name (i.e. in parameter module_name) will make the
otbApplicationLauncherCommandLine lists the name of all applications found in the available path
(either [MODULEPATH] and/or OTB_APPLICATION_PATH).
To ease the use of the applications, and try avoiding extensive environment customization, ready-to-use scripts are pro-
vided by the OTB installation to launch each application, and takes care of adding the standard application installation
path to the OTB_APPLICATION_PATH environment variable.
These scripts are named otbcli_<ApplicationName> and do not need any path settings. For example, you can
start the Orthorectification application with the script called otbcli_Orthorectification.
Launching an application without parameters, or with incomplete parameters, will cause the launcher to display a
summary of the parameters. This summary will display the minimum set of parameters that are required to execute
the application. Here is an example with the OrthoRectification application:
$ otbcli_OrthoRectification
EXAMPLE OF USE:
otbcli_OrthoRectification -io.in QB_TOULOUSE_MUL_Extract_500_500.tif -io.out QB_
˓→Toulouse_ortho.tif
DOCUMENTATION: http://www.orfeo-toolbox.org/Applications/OrthoRectification.html
======================= PARAMETERS =======================
-progress <boolean> Report progress
MISSING -io.in <string> Input Image
MISSING -io.out <string> [pixel] Output Image [pixel=uint8/
˓→int8/uint16/int16/uint32/int32/float/double]
For a detailed description of the application behaviour and parameters, please check the application reference
documentation presented chapter [chap:apprefdoc], page or follow the DOCUMENTATION hyperlink provided in
otbApplicationLauncherCommandLine output. Parameters are passed to the application using the parame-
ter key (which might include one or several . character), prefixed by a -. Command-line examples are provided in
chapter [chap:apprefdoc], page.
Graphical launcher
The graphical interface for the applications provides a useful interactive user interface to set the parameters, choose
files, and monitor the execution progress.
This launcher needs the same two arguments as the command line launcher:
The application paths can be set with the OTB_APPLICATION_PATH environment variable, as for the command line
launcher. Also, as for the command-line application, a more simple script is generated and installed by OTB to ease
the configuration of the module path: to launch the graphical user interface, one will start the otbgui_Rescale
script.
The resulting graphical application displays a window with several tabs:
• Parameters is where you set the parameters and execute the application.
• Logs is where you see the output given by the application during its execution.
• Progress is where you see a progress bar of the execution (not available for all applications).
• Documentation is where you find a summary of the application documentation.
In this interface, every optional parameter has a check box that you have to tick if you want to set a value and use this
parameter. The mandatory parameters cannot be unchecked.
The interface of the application is shown here as an example.
Python interface
The applications can also be accessed from Python, through a module named otbApplication. However, there
are technical requirements to use it. If you use OTB through standalone packages, you should use the supplied
environment script otbenv to properly setup variables such as PYTHONPATH and OTB_APPLICATION_PATH (on
Unix systems, don’t forget to source the script). In other cases, you should set these variables depending on your
configuration.
On Unix systems, it is typically available in the /usr/lib/otb/python directory. Depending on how you in-
stalled OTB, you may need to configure the environment variable PYTHONPATH to include this directory so that the
module becomes available from Python.
On Windows, you can install the otb-python package, and the module will be available from an OSGeo4W shell
automatically.
As for the command line and GUI launchers, the path to the application modules needs to be properly set with the
OTB_APPLICATION_PATH environment variable. The standard location on Unix systems is /usr/lib/otb/
applications. On Windows, the applications are available in the otb-bin OSGeo4W package, and the environ-
ment is configured automatically so you don’t need to tweak OTB_APPLICATION_PATH.
Once your environment is set, you can use OTB applications from Python, just like this small example:
# This will execute the application and save the output file
app.ExecuteAndWriteOutput()
For more information about this Python interface, check the recipe section.
QGIS interface
OTB applications are available from QGIS. Use them from the processing toolbox, which is accessible with Processing
→ ToolBox. Switch to “advanced interface” in the bottom of the application widget and OTB applications will be
there.
If QGIS cannot find OTB, the “applications folder” and “binaries folder” can be set from the settings in the Processing
→ Settings → “service provider”.
On some versions of QGIS, if an existing OTB installation is found, the textfield settings will not be shown. To use a
custom OTB instead of the existing one, you will need to replace the otbcli, otbgui and library files in QGIS installation
directly.
Since OTB 3.20, OTB applications parameters can be export/import to/from an XML file using inxml/outxml param-
eters. Those parameters are available in all applications.
An example is worth a thousand words
Then, you can run the applications with the same parameters using the output XML file previously saved. For this,
you have to use the inxml parameter:
otbcli_BandMath -inxml saved_applications_parameters.xml
Note that you can also overload parameters from command line at the same time
otbcli_BandMath -inxml saved_applications_parameters.xml
-exp "(im1b1 - im2b1)"
In this case it will use as mathematical expression “(im1b1 - im2b1)” instead of “abs(im1b1 - im2b1)”.
Finally, you can also launch applications directly from the command-line launcher executable using the inxml param-
eter without having to declare the application name. Use in this case:
otbApplicationLauncherCommandLine -inxml saved_applications_parameters.xml
It will retrieve the application name and related parameters from the input XML file and launch in this case the
BandMath applications.
Provided that Orfeo ToolBox has been built with MPI and SPTW modules activated, it is possible to use MPI for
massive parallel computation and writing of an output image. A simple call to mpirun before the command-line
activates this behaviour, with the following logic. MPI writing is only triggered if:
• OTB is built with MPI and SPTW,
• The number of MPI processes is greater than 1,
• The output filename is .tif or .vrt
In this case, the output image will be divided into several tiles according to the number of MPI processes specified to
the mpirun command, and all tiles will be computed in parallel.
If the output filename extension is .tif, tiles will be written in parallel to a single Tiff file using SPTW (Simple
Parallel Tiff Writer).
If the output filename extension is .vrt, each tile will be written to a separate Tiff file, and a global VRT file will be
written.
Here is an example of MPI call on a cluster:
$ mpirun -np $nb_procs --hostfile $PBS_NODEFILE \
otbcli_BundleToPerfectSensor \
-inp $ROOT/IMG_PHR1A_P_001/IMG_PHR1A_P_201605260427149_ORT_1792732101-001_R1C1.JP2 \
-inxs $ROOT/IMG_PHR1A_MS_002/IMG_PHR1A_MS_201605260427149_ORT_1792732101-002_R1C1.
˓→JP2 \
JOBID : 1043196.tu-adm01
USER : michelj
GROUP : ctsiap
JOB NAME : OTB_mpi
SESSION : 631249
RES REQSTED : mem=1575000mb,ncpus=560,place=free,walltime=04:00:00
RES USED : cpupercent=1553,cput=00:56:12,mem=4784872kb,ncpus=560,
˓→vmem=18558416kb,
walltime=00:04:35
BILLING : 42:46:40 (ncpus x walltime)
QUEUE : t72h
ACCOUNT : null
JOB EXIT CODE : 0
One can see that the registration and pan-sharpening of the panchromatic and multi-spectral bands of a Pleiades image
has been split among 560 cpus and took only 56 seconds.
Note that this MPI parallel invocation of applications is only available for command-line calls to OTB applications,
and only for images output parameters.
FOUR
MONTEVERDI
23
OTB CookBook Documentation, Release 6.6.0
Main menu
The main menu is made up of four items. The main one is the File item, from which you can: open a image, load the
otb applications, and finally quit. The Edit item lets the user change his/her preferences. The view item is intended to
let the user display or hide different parts of the main window. Finally, the Help item lets the user know the ’About’
information of the software, and also can display an useful keymap.
Top toolbar
Image displaying
This part of the main window is intended to display the images loaded by the user. There are many nice keyboard
shortcuts or mouse tricks that let the user have a better experience in navigating throughout the loaded images. These
shortcuts and tricks are provided within the Help item of the main menu under Keymap. Here is a short list of the most
commonly used ones:
The standard ones:
• CTRL+O = Open file(s)
• CTRL+Q = Quit application
In the image displaying part:
• Mouse drag = Scroll view
• CTRL+Mouse drag = Quick scroll view (rending is done after releasing CTRL key)
• Mouse wheel = Zoom
• – or - = Zoom
In the layer stack part:
• SHIFT+Page Up = Move layer to top of stack
• SHIFT+Page Down = Move layer to bottom of stack
24 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
Layer stack
The layer stack is made up of one list of layers located beneath six icons. The list of layers gives the user some
information about the loaded images: projection, resolution (if available), name, and effect applied to the images (see
top toolbar subsection). If the user moves the mouse over the displayed images, they will get more information:
• (i,j): pixel index
• (Red Green Blue): original image pixel values from channel mapped to the RGB ones.
• (X,Y): pixel position
Concerning the six icons, from left to right:
• 1st: moves the selected layer to the top of the stack
• 2nd: moves the selected layer up within the stack
• 3rd: moves the selected layer down within the stack
• 4th: moves the selected layer to the bottom of the stack
• 5th: use selected layer as projection reference
• 6th: applies all display settings (color-setup, color-dynamics, shader and so forth) of selected layer to all other
layers
The layer stack is represented in the figure below ( [fig:layerstack]):
Examples
With , it is also possible to interactively load otb-applications and use them to process images. For that purpose, the
user just has to load otb-applications by clicking on the Main menu, File/Load OTB-Applications (or by simply using
the shortcut CTRL+A). The figure below ( [fig:applications]) represents the otb-applications loading window. The
26 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
applications are arranged in thematic functionalities; the user can also quickly find the wanted application by typing
its name in the dedicated field at the top of the loading window.
Optical calibration
In order to perform an optical calibration, launch the Optical calibration application (shortcut CTRL+A). We are going
to use this application to perform a TOA (Top Of Atmosphere) conversion, which consists in converting the DN pixel
values into spectral radiance (in W/m2/steradians/micrometers). Once the application is launched, the user must fill
the required fields in (in, out, gainbias.txt -gain and bias values in a txt file-, solarillumination.txt -solar illumination
values in watt/m2/micron for each band in a txt file-, and so on... refer to the documentation of the application).
• Note: if OTB (on which is based ) is able to parse the metadata of the image to be calibrated, then some of the
fields will be automatically filled in.
In the figure below ( [fig:OC]), by taking a look at the layer stack, one can notice that the values of the calibrated
image are now expressed in spectral radiance.
BandMath
BandMath application is intended to apply mathematical operations on pixels (launch it with shortcut CTRL+A). In
this example, we are going to use this application to change the dynamics of an image, and check the result by looking
at the histogram tab on the right-hand side of the GUI. The formula used is the following: im1b1 × 1000. In the figures
below ( [fig:BM]), one can notice that the mode of the distribution is located at position 356.0935, whereas in the
transformed image, the mode is located at position 354737.1454, that’s to say approximately 1000 times further away
(the cursors aren’t placed exactly at the same position in the screenshots).
Segmentation
From within Monteverdi, the Segmentation application can be launched using the shortcut CTRL+A. We let the user
take a look at the application’s documentation; let’s simply say that as we wish we could display the segmentation with
, we must tell the application to output the segmentation in raster format. Thus, the value of the mode option must be
set to raster. The following figure ( [fig:seg12]) shows the original image and the labels image.
Gray colors aren’t very convenient for visualizing a segmentation. That’s why we are going to use another application,
the ColorMapping one (launch it with the shortcut CTRL+A as usual). There are many ways to use this application
(see the documentation for more details). We wish we could colour the segmentation so that color difference between
adjacent regions is maximized. For this purpose, we can use the method optimal (set the value of this option to
optimal). The figure below ( [fig:seg3]) shows the result of such colorization.
Now it should be nice to superimpose this colorization with the original image to assess the quality of the segmentation.
provides the user a very simple way to do it. Once the two images are loaded in and that the original image is placed
on the top of the stack, the user just has to select the translucency layer effect and set the size of the exploration circle
28 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
4.8. Segmentation 29
OTB CookBook Documentation, Release 6.6.0
to convenience. The figure below ( [fig:seg4]) shows the result of such colorization. We encourage the reader to test
the other layer effects.
Polarimetry
Pansharpening
Finally, let’s try a last example with the Pansharpening application (launch it with shortcut CTRL+A). The fields are
quite easy to fill in: this application needs a panchromatic image, a XS image, and an output image. These images are
represented in the figures below ( [fig:ps12] and [fig:ps3]):
Now, in order to inspect the result properly, these three images are loaded in . The pansharpened image is placed to
the top of the stack layer, and different layer effects are applied to it:
• in figure [fig:ps4]: chessboard effect, to compare the result with the XS image.
• in figure [fig:ps5]: translucency effect, to compare the result with the panchromatic image.
30 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
4.10. Pansharpening 31
OTB CookBook Documentation, Release 6.6.0
32 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
4.10. Pansharpening 33
OTB CookBook Documentation, Release 6.6.0
34 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
4.10. Pansharpening 35
OTB CookBook Documentation, Release 6.6.0
36 Chapter 4. Monteverdi
OTB CookBook Documentation, Release 6.6.0
4.10. Pansharpening 37
OTB CookBook Documentation, Release 6.6.0
Conclusion
The images used in this documentation can be found in the OTB-Data repository (https://gitlab.orfeo-toolbox.org/
orfeotoolbox/otb-data.git):
• in OTB-Data/Input:
– QB_TOULOUSE_MUL_Extract_500_500.tif and QB_Toulouse_Ortho_XS_ROI_170x230.tif (GUI pre-
sentation)
– RSAT_imagery_HH.tif RSAT_imagery_HV.tif RSAT_imagery_VV.tif (polarimetry example)
– QB_Toulouse_Ortho_PAN.tif QB_Toulouse_Ortho_XS.tif (pansharpening example)
• in OTB-Data/Input/mv2-test: QB_1_ortho.tif
38 Chapter 4. Monteverdi
CHAPTER
FIVE
ADVANCED USE
The following environment variables are parsed by Orfeo ToolBox. Note that they only affect default values, and that
settings in extended filenames, applications, monteverdi or custom C++ code might override those values.
• OTB_DEM_DIRECTORY: Default directory were DEM tiles are stored. It should only contain `.hgt or or
georeferenced .tif files. Empty if not set (no directory set)
• OTB_GEOID_FILE: Default path to the geoid file that will be used to retrieve height of DEM above ellipsoid.
Empty if not set (no geoid set)
• OTB_MAX_RAM_HINT: Default maximum memory that OTB should use for processing, in MB. If not set,
default value is 128 MB.
• OTB_LOGGER_LEVEL: Default level of logging for OTB. Should be one of DEBUG, INFO, WARNING,
CRITICAL or FATAL, by increasing order of priority. Only messages with a higher priority than the level
of logging will be displayed. If not set, default level is INFO.
Extended filenames
Extended filenames is an interesting feature of OTB. With it, you can control several aspects of the beahvior of the
OTB in the OTB-Applications or in our own C++ applications. Historically this feature has been desingn to solve an
issue with how to handle geo-referencing information.
Indeed, there are multiple ways to define geo-referencing information. For instance, one can use a geographic trans-
form, a cartographic projection, or a sensor model with RPC coefficients. A single image may contain several of these
elements, such as in the “ortho-ready” products: this is a type of product still in sensor geometry (the sensor model is
supplied with the image) but it also contains an approximative geographic transform that can be used to have a quick
estimate of the image localisation. For instance, your product may contain a “.TIF” file for the image, along with a
“.RPB” file that contains the sensor model coefficients and an “.IMD” file that contains a cartographic projection.
This case leads to the following question: which geo-referencing element should be used when opening this image in
OTB. In fact, it depends on the users need. For an orthorectification application, the sensor model must be used. In
order to specify which information should be skipped, a syntax of extended filenames has been developed for both
reading and writing.
Since the development of this feature we have extend this mechanism for other aspaects: like band or overview
selection in reader part or support create option of gdal in writer part.The reader and writer extended filename support
39
OTB CookBook Documentation, Release 6.6.0
is based on the same syntax, only the options are different. To benefit from the extended file name mechanism, the
following syntax is to be used:
Path/Image.ext?&key1=<value1>&key2=<value2>
Note that you’ll probably need to “quote” the filename, especially if calling applications from the bash command
line.
Reader options
&geom=<path/filename.geom>
&sdataidx=<(int)idx>
&resol=<(int)resolution factor>
&bands=r1,r2,...,rn
&skipcarto=<(bool)true>
&skipgeom=<(bool)true>
&skiprpctag=<(bool)true>
• Skip the reading of internal RPC tags (see [sec:TypesofSensorModels] for details)
• false by default.
Writer options
&writegeom=<(bool)false>
&writerpctags=<(bool)true>
&gdal:co:<GDALKEY>=<VALUE>
&streaming:type=<VALUE>
&streaming:sizemode=<VALUE>
&streaming:sizevalue=<VALUE>
&box=<startx>:<starty>:<sizex>:<sizey>
&bands=r1,r2,...,rn
We extended this process to OGR DataSource. There are three different type of option : open, creation and layer
creation. Those options come from the GDAL API. In order to use them one just need to specify to which of this
family the option one want to use is from.
For open option :
&gdal:oo:<GDALKEY>=<VALUE>
&gdal:co:<GDALKEY>=<VALUE>
&gdal:lco:<GDALKEY>=<VALUE>
Examples
SIX
RECIPES
This chapter presents guidelines to perform various remote sensing and image processing tasks with either , or both.
Its goal is not to be exhaustive, but rather to familiarise users with the OTB package functionality and demonstrate
how the can be applied.
This section presents various pre-processing tasks that are presented in a standard order to obtain a calibrated, pan-
sharpened image.
In remote sensing imagery, pixel values are referred to as Digital Numbers (DN) and they cannot be physically inter-
preted or compared. They are influenced by various factors such as the amount of light flowing through the sensor, the
gain of the detectors and the analogic to numeric converter.
Depending on the season, the light and atmospheric conditions, the position of the sun or the sensor internal parameters,
these DN can drastically change for a given pixel (apart from any ground change effects). Moreover, these effects are
not uniform over the spectrum: for instance aerosol amount and type has usually more impact on the blue channel.
Therefore, it is necessary to calibrate the pixel values before any physical interpretation is made out of them. In
particular, this processing is mandatory before any comparison of pixel spectrum between several images (from the
same sensor), and to train a classifier without dependence to the atmospheric conditions at the acquisition time.
Calibrated values are called surface reflectivity, which is a ratio denoting the fraction of light that is reflected by the
underlying surface in the given spectral range. As such, its values lie in the range [0, 1]. For convenience, images are
often stored in thousandth of reflectivity, so that they can be encoded with an integer type. Two levels of calibration
are usually distinguished:
• The first level is called Top Of Atmosphere (TOA) reflectivity. It takes into account the sensor gain, sensor
spectral response and the solar illumination.
• The second level is called Top Of Canopy (TOC) reflectivity. In addition to sensor gain and solar illumination,
it takes into account the optical thickness of the atmosphere, the atmospheric pressure, the water vapor amount,
the ozone amount, as well as the composition and amount of aerosol gasses.
This transformation can be done either with OTB Applications or with Monteverdi . Sensor-related parameters such
as gain, date, spectral sensitivity and sensor position are seamlessly read from the image metadata. Atmospheric
parameters can be tuned by the user. Supported sensors are:
• Pleiades
• SPOT5
45
OTB CookBook Documentation, Release 6.6.0
• QuickBird
• Ikonos
• WorldView-1
• WorldView-2
• Formosat
The OpticalCalibration application allows to perform optical calibration. The mandatory parameters are the input
and output images. All other parameters are optional. By default the level of calibration is set to TOA (Top Of
Atmosphere). The output images are expressed in thousandth of reflectivity using a 16 bits unsigned integer type.
A basic TOA calibration task can be performed with the following command:
A basic TOC calibration task can be performed with the following command:
Pan-sharpening
Because of physical constrains on the sensor design, it is difficult to achieve high spatial and spectral resolution at the
same time: a better spatial resolution means a smaller detector, which in turn means lesser optical flow on the detector
surface. On the contrary, spectral bands are obtained through filters applied on the detector surface, that lowers the
optical flow, so that it is necessary to increase the detector size to achieve an acceptable signal to noise ratio.
For these reasons, many high resolution satellite payload are composed of two sets of detectors, which in turn delivers
two different kind of images:
• The multi-spectral (XS) image, composed of 3 to 8 spectral bands containing usually blue, green, red and near
infra-red bands at a given resolution (usually from 2.8 meters to 2 meters).
• The panchromatic (PAN) image, which is a grayscale image acquired by a detector covering a wider part of the
light spectrum, which allows to increase the optical flow and thus to reduce pixel size. Therefore, resolution of
the panchromatic image is usually around 4 times lower than the resolution of the multi-spectral image (from
46 centimeters to 70 centimeters).
It is very frequent that those two images are delivered side by side by data providers. Such a dataset is called a bundle.
A very common remote sensing processing is to fuse the panchromatic image with the multi-spectral one so as to get
an image combining the spatial resolution of the panchromatic image with the spectral richness of the multi-spectral
image. This operation is called pan-sharpening.
This fusion operation requires two different steps:
1. The multi-spectral (XS) image is zoomed and registered to the panchromatic image,
2. A pixel-by-pixel fusion operator is applied to the co-registered pixels of the multi-spectral and panchromatic
image to obtain the fused pixels.
Using either OTB Applications or modules from Monteverdi , it is possible to perform both steps in a row, or
step-by-step fusion, as described in the above sections.
The BundleToPerfectSensor application allows to perform both steps in a row. Seamless sensor modelling is used to
perform zooming and registration of the multi-spectral image on the panchromatic image. In the case of a Pléiades
bundle, a different approach is used: an affine transform is used to zoom the multi-spectral image and apply a residual
translation. This translation is computed based on metadata about the geometric processing of the bundle. This
zooming and registration of the multi-spectral image over the panchromatic image can also be performed by the
Superimpose application.
46 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
After the registration step, a simple pan-sharpening is applied, according to the following formula:
𝑃 𝐴𝑁 (𝑖, 𝑗)
𝑃 𝑋𝑆(𝑖, 𝑗) = · 𝑋𝑆(𝑖, 𝑗)
𝑃 𝐴𝑁𝑠𝑚𝑜𝑜𝑡ℎ (𝑖, 𝑗)
Where 𝑖 and 𝑗 are pixels indices, 𝑃 𝐴𝑁 is the panchromatic image, 𝑋𝑆 is the multi-spectral image and 𝑃 𝐴𝑁𝑠𝑚𝑜𝑜𝑡ℎ
is the panchromatic image smoothed with a kernel to fit the multi-spectral image scale.
Here is a simple example of how to use the BundleToPerfectSensor application:
There are also optional parameters that can be useful for this tool:
• The -elev option allows to specify the elevation, either with a DEM formatted for OTB (-elev.dem op-
tion, see section [ssec:dem]) or with an average elevation (-elev.default option). Since registration and
zooming of the multi-spectral image is performed using sensor-models, it may happen that the registration is
not perfect in case of landscape with high elevation variation. Using a DEM in this case allows to get better
registration.
• The -lmSpacing option allows to specify the step of the registration grid between the multi-spectral image
and panchromatic image. This is expressed in amount of panchromatic pixels. A lower value gives a more
precise registration but implies more computation with the sensor models, and thus increase the computation
time. Default value is 10 pixels, which gives sufficient precision in most of the cases.
• The -mode option allows to select the registration mode for the multi-spectral image. The default mode
uses the sensor model of each image to create a generic “MS to Pan” transform. The phr mode uses a simple
affine transform (which doesn’t need an elevation source nor a registration grid).
Pan-sharpening is a quite heavy processing requiring a lot of system resource. The -ram option allows you to limit the
amount of memory available for the computation, and to avoid overloading your computer. Increasing the available
amount of RAM may also result in better computation time, seems it optimises the use of the system resources. Default
value is 256 Mb.
A Digital Elevation Model (DEM) is a georeferenced image (or collection of images) where each pixel corresponds to
a local elevation. DEM are useful for tasks involving sensor to ground and ground to sensor coordinate transforms, like
during ortho-rectification (see Ortho-rectification and map projections). These transforms need to find the intersection
between the line of sight of the sensor and the Earth geoid. If a simple spheroid is used as the Earth model, potentially
high localisation errors can be made in areas where elevation is high or perturbed. Of course, DEM accuracy and
resolution have a great impact on the precision of these transformations.
Two main available DEM, free of charges, and with worldwide cover, are both delivered as 1 degree by 1 degree tiles:
• The Shuttle Radar topographic Mission (SRTM) is a DEM with a resolution of 90 metres, obtained by radar
interferometry during a campaign of the Endeavour space shuttle from NASA in 2000.
• The Advanced Spaceborne Thermal Emission and Reflection Radiometer (ASTER) is a DEM with a resolution
of 30 metres obtained by stereoscopic processing of the archive of the ASTER instrument.
The Orfeo ToolBox relies on OSSIM capabilities for sensor modelling and DEM handling. Tiles of a given DEM are
supposed to be located within a single directory. General elevation support is also supported from GeoTIFF files.
Whenever an application or Monteverdi module requires a DEM, the option elev.dem allows set the DEM directory.
This directory must contain the DEM tiles, either in DTED or SRTM format or as a GeoTIFF. Subdirectories are not
supported.
Depending on the reference of the elevation, you also need to use a geoid to accurately manage the elevation. For
this, you need to specify a path to a file which contains the geoid. Geoid corresponds to the equipotential surface that
would coincide with the mean ocean surface of the Earth.
We provide one geoid in the OTB-Data repository.
In all applications, the option elev.geoid allows to manage the path to the geoid. Finally, it is also possible to use an
average elevation in case no DEM is available by using the elev.default option.
There are several level of products available on the remote sensing imagery market. The most basic level often provide
the geometry of acquisition (sometimes called the raw geometry). In this case, pixel coordinates can not be directly
used as geographical positions. For most sensors (but not for all), the different lines corresponds to different acquisition
times and thus different sensor positions, and different rows correspond to different cells of the detector.
The mapping of a raw image so as to be registered to a cartographic grid is called ortho-rectification, and consist in
inverting the following effects (at least):
• In most cases, lines are orthogonal to the sensor trajectory, which is not exactly (and in some case not at all)
following a north-south axis,
• Depending on the sensor, the line of sight may be different from a Nadir (ground position of the sensor), and
thus a projective warping may appear,
• The variation of height in the landscape may result in severe warping of the image.
48 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Moreover, depending on the area of the world the image has been acquired on, different map projections should be
used.
The ortho-rectification process is as follows: once an appropriate map projection has been defined, a localisation grid is
computed to map pixels from the raw image to the ortho-rectified one. Pixels from the raw image are then interpolated
according to this grid in order to fill the ortho-rectified pixels.
Ortho-rectification can be performed either with OTB Applications or Monteverdi . Sensor parameters and image
meta-data are seamlessly read from the image files without needing any user interaction, provided that all auxiliary
files are available. The sensor for which Orfeo ToolBox supports ortho-rectification of raw products are the following:
• Pleiades
• SPOT5
• Ikonos
• Quickbird
• GeoEye
• WorldView
In addition, GeoTiff and other file format with geographical information are seamlessly read by Orfeo ToolBox , and
the ortho-rectification tools can be used to re-sample these images in another map projection.
There are some image products, called “ortho-ready”, that should be processed carefully. They are actual products in
raw geometry, but their metadata also contains projection data:
• a map projection
• a physical origin
• a physical spacing
• and sometimes an orientation angle
The purpose of this projection information is to give an approximate map projection to a raw product. It allows you
to display the raw image in a GIS viewer at the (almost) right location, without having to reproject it. Obviously,
this map projection is not as accurate as the sensor parameters of the raw geometry. In addition, the impact of the
elevation model can’t be observed if the map projection is used. In order to perform an ortho-rectification on this type
of product, the map projection has to be hidden from Orfeo ToolBox .
You can see if a product is an “ortho-ready” product by using gdalinfo or OTB ReadImageInfo application. Check
if your product verifies following two conditions:
• The product is in raw geometry: you should expect the presence of RPC coefficients and a non-empty OSSIM
keywordlist.
• The product has a map projection: you should see a projection name with physical origin and spacing.
In that case, you can hide the map projection from the Orfeo ToolBox by using extended filenames. Instead of using
the plain input image path, you append a specific key at the end:
"path_to_image?&skipcarto=true"
The double quote can be necessary for a successful parsing. More details about the extended filenames can be found
in the Extended filenames section.
The OrthoRectification application allows to perform ortho-rectification and map re-projection. The simplest way to
use it is the following command:
otbcli_OrthoRectification -io.in input_image -io.out output_image
In this case, the tool will automatically estimates all the necessary parameters:
• The map projection is set to UTM (a worldwide map projection) and the UTM zone is automatically estimated,
• The ground sampling distance of the output image is computed to fit the image resolution,
• The region of interest (upper-left corner and size of the image) is estimated so as to contain the whole input
image extent.
In order to use a Digital Elevation Model (see Digital Elevation Model management.) for better localisation perfor-
mances, one can pass the directory containing the DEM tiles to the application:
otbcli_OrthoRectification -io.in input_image
-io.out output_image
-elev.dem dem_dir
If one wants to use a different map projection, the -map option may be used (example with lambert93 map projection):
otbcli_OrthoRectification -io.in input_image
-io.out output_image
-elev.dem dem_dir
-map lambert93
Map projections handled by the application are the following (please note that the ellipsoid is always WGS84):
• UTM: -map utm | The UTM zone and hemisphere can be set by the options -map.utm.zone and
-map.utm.northhem.
• Lambert 2 etendu: -map lambert2
• Lambert 93: -map lambert93
• TransMercator: -map transmercator | The related parameters (false easting, false northing and scale
factor) can be set by the options -map.transmercator.falseeasting,
-map.transmercator.falsenorthing and -map.transmercator.scale
• WGS: -map wgs
• Any map projection system with an EPSG code: -map epsg | The EPSG code is set with the option
-map.epsg.code
The group outputs contains parameters to set the origin, size and spacing of the output image. For instance, the
ground spacing can be specified as follows:
otbcli_OrthoRectification -io.in input_image
-io.out output_image
-elev.dem dem_dir
-map lambert93
-outputs.spacingx spx
-outputs.spacingy spy
Please note that since the y axis of the image is bottom oriented, the y spacing should be negative to avoid switching
north and south direction.
A user-defined region of interest to ortho-rectify can be specified as follows:
50 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Where the -outputs.ulx and -outputs.uly options allow to specify the coordinates of the upper-left corner
of the output image. The -outputs.sizex and -outputs.sizey options allow to specify the size of the output
image.
A few more interesting options are available:
• The -opt.rpc option allows to use an estimated RPC model instead of the rigorous SPOT5 model, which
speeds-up the processing,
• The -opt.gridspacing option allows to define the spacing of the localisation grid used for ortho-
rectification. A coarser grid results in speeding-up the processing, but with potential loss of accuracy. A standard
value would be 10 times the ground spacing of the output image.
• The -interpolator option allows to change the interpolation algorithm between nearest neighbor, linear
and bicubic. Default is nearest neighbor interpolation, but bicubic should be fine in most cases.
• The -opt.ram option allows to specify the amount of memory available for the processing (in Mb). Default
is 256 Mb. Increasing this value to fit the available memory on your computer might speed-up the processing.
SAR processing
This section describes how to use the applications related to SAR processing.
Calibration
The application SarRadiometricCalibration can deal with the calibration of data from four radar sensors: RadarSat2,
Sentinel1, COSMO-SkyMed and TerraSAR-X.
Examples:
If SARimg.tif is a TerraSAR-X or a COSMO-SkyMed image:
If SARimg.tif is a RadarSat2 or a Sentinel1 image, it is possible to specify the look-up table (automatically found in
the metadata provided with such image):
For TerraSAR-X (and soon for RadarSat2 and Sentinel1), it is also possible to use a noise LUT to derive calibrated
noise profiles:
Despeckle
SAR images are generally corrupted by speckle noise. To suppress speckle and improve the radar image analysis lots
of filtering techniques have been proposed. The module implements to well-known despeckle methods: Frost, Lee,
Gamma-MAP and Kuan.
Figure ([ffig:S1VVdespeckledextract] shows an extract of a SLC Sentinel1 image, band VV, taken over Cape Verde
and the result of the Gamma filter. The following commands were used to produce the despeckled extract:
First, the original image is converted into an intensity one (real part corresponds to band 1, and imaginary part to band
2):
The produced images were then rescaled to intensities ranging from 0 to 255 in order to be displayed.
Polarimetry
In conventional imaging radar the measurement is a scalar which is proportional to the received back-scattered power at
a particular combination of linear polarization (HH, HV, VH or VV). Polarimetry is the measurement and interpretation
of the polarization of this measurement which allows to measure various optical properties of a material. In polarimetry
the basic measurement is a 2𝑥2 complex scattering matrix yielding an eight dimensional measurement space (Sinclair
matrix). For reciprocal targets where 𝐻𝑉 = 𝑉 𝐻, this space is compressed to five dimensions: three amplitudes
(|𝐻𝐻|, |𝐻𝑉 |, and |𝑉 𝑉 |); and two phase measurements, (co-pol: HH-VV, and cross-pol: HH-HV). (see grss-ieee).
Matrix conversions
This applications allows converting classical polarimetric matrices to each other. For instance, it is possible to get the
coherency matrix from the Sinclair one, or the Mueller matrix from the coherency one. The figure below ([fig:polconv])
shows the workflow used in this application.
The filters used in this application never handle matrices, but images where each band is related to their elements.
As most of the time SAR polarimetry handles symmetric matrices, only the relevant elements are stored, so that the
images representing them have a minimal number of bands. For instance, the coherency matrix size is 3x3 in the
monostatic case, and 4x4 in the bistatic case: it will thus be stored in a 6-band or a 10-band complex image (the
diagonal and the upper elements of the matrix).
The Sinclair matrix is a special case: it is always represented as 3 or 4 one-band complex images (for mono- or bistatic
case).
There are 13 available conversions, each one being related to the following parameters:
52 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
1. msinclairtocoherency
2. msinclairtocovariance
3. msinclairtocircovariance
4. mcoherencytomueller
5. mcovariancetocoherencydegree
6. mcovariancetocoherency
7. mlinearcovariancetocircularcovariance
8. muellertomcovariance
9. bsinclairtocoherency
10. bsinclairtocovariance
11. bsinclairtocircovariance
12. sinclairtomueller
13. muellertopoldegandpower
For each option parameter, the list below gives the formula used.
— Monostatic case —
1. msinclairtocoherency (SinclairToReciprocalCoherencyMatrixFunctor)
(a) 0.5.(𝑆ℎℎ + 𝑆𝑣𝑣 ).(𝑆ℎℎ + 𝑆𝑣𝑣 )*
(b) 0.5.(𝑆ℎℎ + 𝑆𝑣𝑣 ).(𝑆ℎℎ − 𝑆𝑣𝑣 )*
(c) 0.5.(𝑆ℎℎ + 𝑆𝑣𝑣 ).(2𝑆ℎ𝑣 )*
(d) 0.5.(𝑆ℎℎ − 𝑆𝑣𝑣 ).(𝑆ℎℎ − 𝑆𝑣𝑣 )*
(e) 0.5.(𝑆ℎℎ − 𝑆𝑣𝑣 ).(2𝑆ℎ𝑣 )*
(f) 0.5.(2𝑆ℎ𝑣 ).(2𝑆ℎ𝑣 )*
2. msinclairtocovariance (SinclairToReciprocalCovarianceMatrixFunctor)
*
(a) 𝑆ℎℎ .𝑆ℎℎ
√ *
(b) 2.𝑆ℎℎ .𝑆ℎ𝑣
*
(c) 𝑆ℎℎ .𝑆𝑣𝑣
*
(d) 2.𝑆ℎ𝑣 .𝑆ℎ𝑣
√ *
(e) 2.𝑆ℎ𝑣 .𝑆𝑣𝑣
*
(f) 𝑆𝑣𝑣 .𝑆𝑣𝑣
3. msinclairtocircovariance (SinclairToReciprocalCircularCovarianceMatrixFunctor)
(a) 𝑆𝑙𝑙 .𝑆𝑙𝑙*
*
(b) 𝑆𝑙𝑙 .𝑆𝑙𝑟
*
(c) 𝑆𝑙𝑙 .𝑆𝑟𝑟
*
(d) 𝑆𝑙𝑟 .𝑆𝑙𝑟
*
(e) 𝑆𝑙𝑟 .𝑆𝑟𝑟
*
(f) 𝑆𝑟𝑟 .𝑆𝑟𝑟
54 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
With:
• 𝑆𝑙𝑙 = 0.5(𝑆ℎℎ + 2𝑗𝑆ℎ𝑣 − 𝑆𝑣𝑣 )
• 𝑆𝑙𝑟 = 0.5(𝑗𝑆ℎℎ + 𝑗𝑆𝑣𝑣 )
• 𝑆𝑟𝑟 = 0.5(−𝑆ℎℎ + 2𝑗𝑆ℎ𝑣 + 𝑆𝑣𝑣 )
4. mcoherencytomueller (ReciprocalCoherencyToReciprocalMuellerFunctor)
(a) 0.5 * (𝐶11 + 𝐶22 + 𝐶33 )
(b) 𝑅𝑒(𝐶12 ) + 𝐼𝑚(𝐶22 )
(c) 𝑅𝑒(𝐶13 )
(d) 𝐼𝑚(𝐶23 )
(e) 𝑅𝑒(𝐶12 )
(f) 0.5 * (𝐶11 + 𝐶22 − 𝐶33 )
(g) 𝑅𝑒(𝐶23 )
(h) 𝐼𝑚(𝐶13 )
(i) −𝑅𝑒(𝐶13 )
(j) −𝑅𝑒(𝐶23 )
(k) 0.5.𝑅𝑒(𝑉 𝐴𝐿1)
(l) 0.5.𝐼𝑚(𝑉 𝐴𝐿0)
(m) 𝐼𝑚(𝐶23 )
(n) 𝐼𝑚(𝐶13 )
(o) 0.5.𝐼𝑚(𝑉 𝐴𝐿1* )
(p) 0.5.𝑅𝑒(𝑉 𝐴𝐿0)
With:
• 𝑉 𝐴𝐿0 = 𝐶33 + 𝐶12 − 𝐶11 − (𝐶12 − 𝐶22 )*
• 𝑉 𝐴𝐿1 = −𝐶33 + 𝐶12 − 𝐶11 − (𝐶12 − 𝐶22 )*
Where 𝐶𝑖𝑗 are related to the elements of the reciprocal coherence matrix.
5. mcovariancetocoherencydegree (ReciprocalCovarianceToCoherencyDegreeFunctor)
* * *
(a) 𝑎𝑏𝑠(𝑆ℎℎ .𝑆𝑣𝑣 )/𝑠𝑞𝑟𝑡(𝑆ℎℎ .𝑆ℎℎ )/𝑠𝑞𝑟𝑡(𝑆𝑣𝑣 .𝑆𝑣𝑣 )
* * *
(b) 𝑎𝑏𝑠(𝑆ℎ𝑣 .𝑆𝑣𝑣 )/𝑠𝑞𝑟𝑡(𝑆ℎ𝑣 .𝑆ℎ𝑣 )/𝑠𝑞𝑟𝑡(𝑆𝑣𝑣 .𝑆𝑣𝑣 )
* * *
(c) 𝑎𝑏𝑠(𝑆ℎℎ .𝑆ℎ𝑣 )/𝑠𝑞𝑟𝑡(𝑆ℎℎ .𝑆ℎℎ )/𝑠𝑞𝑟𝑡(𝑆ℎ𝑣 .𝑆ℎ𝑣 )
6. mcovariancetocoherency (ReciprocalCovarianceToReciprocalCoherencyFunctor)
*
(a) 0.5.(𝐶33 + 𝐶13 + 𝐶13 + 𝐶11 )
*
(b) 0.5.(−𝐶33 − 𝐶13 + 𝐶13 + 𝐶11 )
√ √ *
(c) 0.5.( 2.𝐶12 + 2.𝐶23 )
*
(d) 0.5.(𝐶33 − 𝐶13 − 𝐶13 + 𝐶11 )
√ √ *
(e) 0.5.( 2.𝐶12 − 2.𝐶23 )
(f) 0.5.(2.𝐶22 )
Where 𝐶𝑖𝑗 are related to the elements of the reciprocal linear covariance matrix.
7. mlinearcovariancetocircularcovariance (ReciprocalLinearCovarianceToReciprocalCircularCovarianceFunctor)
√ √ * *
√ √ *
(a) 0.25.(𝐶33 − 𝑖. 2.𝐶23 − 𝐶13 + 𝑖. 2.𝐶23 − 𝐶13 + 2.𝐶22 − 𝑖. 2.𝐶12 + 𝑖. 2.𝐶12 + 𝐶11 )
√ √ √ * *
√
(b) 0.25.(𝑖. 2.𝐶33 + 2.𝐶23 − 𝑖. 2.𝐶13 + 𝑖. 2.𝐶13 + 2.𝐶12 − 𝑖. 2.𝐶11 )
√ √ * *
√ √ *
(c) 0.25.(−𝐶33 + 𝑖. 2.𝐶23 + 𝐶13 + 𝑖. 2.𝐶23 + 𝐶13 + 2.𝐶22 − 𝑖. 2.𝐶12 − 𝑖. 2.𝐶12 − 𝐶11 )
*
(d) 0.25.(2.𝐶33 + 2.𝐶13 + 2.𝐶13 + 2.𝐶11 )
√ √ *
√ *
√
(e) 0.25.(𝑖. 2.𝐶33 + 𝑖. 2.𝐶13 + 2.𝐶23 − 𝑖. 2.𝐶13 + 2.𝐶12 − 𝑖. 2.𝐶11 )
√ √ * *
√ √ *
(f) 0.25.(𝐶33 + 𝑖. 2.𝐶23 − 𝐶13 − 𝑖. 2.𝐶23 − 𝐶13 + 2.𝐶22 + 𝑖. 2.𝐶12 − 𝑖. 2.𝐶12 + 𝐶11 )
Where 𝐶𝑖𝑗 are related to the elements of the reciprocal linear covariance matrix.
8. muellertomcovariance (MuellerToReciprocalCovarianceFunctor)
(a) 0.5.(𝑀11 + 𝑀22 + 2.𝑀12 )
√
(b) 0.5. 2.[(𝑀13 + 𝑀23 ) + 𝑗.(𝑀14 + 𝑀24 )]
(c) −0.5.(𝑀33 + 𝑀44 ) − 𝑗.𝑀34
(d) 𝑀11 − 𝑀22
√
(e) 0.5. 2.[(𝑀13 − 𝑀23 ) + 𝑗.(𝑀14 − 𝑀24 )]
(f) 0.5.(𝑀11 + 𝑀22 − 2.𝑀12 )
— Bistatic case —
1. bsinclairtocoherency (SinclairToCoherencyMatrixFunctor)
(a) (𝑆ℎℎ + 𝑆𝑣𝑣 ).(𝑆ℎℎ + 𝑆𝑣𝑣 )*
(b) (𝑆ℎℎ + 𝑆𝑣𝑣 ).(𝑆ℎℎ − 𝑆𝑣𝑣 )*
(c) (𝑆ℎℎ + 𝑆𝑣𝑣 ).(𝑆ℎ𝑣 + 𝑆𝑣ℎ )*
(d) (𝑆ℎℎ + 𝑆𝑣𝑣 ).(𝑗(𝑆ℎ𝑣 − 𝑆𝑣ℎ ))*
(e) (𝑆ℎℎ − 𝑆𝑣𝑣 ).(𝑆ℎℎ − 𝑆𝑣𝑣 )*
(f) (𝑆ℎℎ − 𝑆𝑣𝑣 ).(𝑆ℎ𝑣 + 𝑆𝑣ℎ )*
(g) (𝑆ℎℎ − 𝑆𝑣𝑣 ).(𝑗(𝑆ℎ𝑣 − 𝑆𝑣ℎ ))*
(h) (𝑆ℎ𝑣 + 𝑆𝑣ℎ ).(𝑆ℎ𝑣 + 𝑆𝑣ℎ )*
(i) (𝑆ℎ𝑣 + 𝑆𝑣ℎ ).(𝑗(𝑆ℎ𝑣 − 𝑆𝑣ℎ ))*
(j) 𝑗(𝑆ℎ𝑣 − 𝑆𝑣ℎ ).(𝑗(𝑆ℎ𝑣 − 𝑆𝑣ℎ ))*
2. bsinclairtocovariance (SinclairToCovarianceMatrixFunctor)
*
(a) 𝑆ℎℎ .𝑆ℎℎ
*
(b) 𝑆ℎℎ .𝑆ℎ𝑣
*
(c) 𝑆ℎℎ .𝑆𝑣ℎ
*
(d) 𝑆ℎℎ .𝑆𝑣𝑣
*
(e) 𝑆ℎ𝑣 .𝑆ℎ𝑣
*
(f) 𝑆ℎ𝑣 .𝑆𝑣ℎ
*
(g) 𝑆ℎ𝑣 .𝑆𝑣𝑣
56 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
*
(h) 𝑆𝑣ℎ .𝑆𝑣ℎ
*
(i) 𝑆𝑣ℎ .𝑆𝑣𝑣
*
(j) 𝑆𝑣𝑣 .𝑆𝑣𝑣
3. bsinclairtocircovariance (SinclairToCircularCovarianceMatrixFunctor)
(a) 𝑆𝑙𝑙 .𝑆𝑙𝑙*
*
(b) 𝑆𝑙𝑙 .𝑆𝑙𝑟
*
(c) 𝑆𝑙𝑙 .𝑆𝑟𝑙
*
(d) 𝑆𝑙𝑙 .𝑆𝑟𝑟
*
(e) 𝑆𝑙𝑟 .𝑆𝑙𝑟
*
(f) 𝑆𝑙𝑟 .𝑆𝑟𝑙
*
(g) 𝑆𝑙𝑟 .𝑆𝑟𝑟
*
(h) 𝑆𝑟𝑙 .𝑆𝑟𝑙
*
(i) 𝑆𝑟𝑙 .𝑆𝑟𝑟
*
(j) 𝑆𝑟𝑟 .𝑆𝑟𝑟
With:
• 𝑆𝑙𝑙 = 0.5(𝑆ℎℎ + 𝑗𝑆ℎ𝑣 + 𝑗𝑆𝑣ℎ − 𝑆𝑣𝑣 )
• 𝑆𝑙𝑟 = 0.5(𝑗𝑆ℎℎ + 𝑆ℎ𝑣 − 𝑆𝑣ℎ + 𝑗𝑆𝑣𝑣 )
• 𝑆𝑟𝑙 = 0.5(𝑗𝑆ℎℎ − 𝑆ℎ𝑣 + 𝑆𝑣ℎ + 𝑗𝑆𝑣𝑣 )
• 𝑆𝑟𝑟 = 0.5(−𝑆ℎℎ + 𝑗𝑆ℎ𝑣 + 𝑗𝑆𝑣ℎ + 𝑆𝑣𝑣 )
— Both cases —
4. sinclairtomueller (SinclairToMueller)
* * * *
(a) 0.5𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑥𝑥 + 𝑇𝑥𝑦 .𝑇𝑥𝑦 + 𝑇𝑦𝑥 .𝑇𝑦𝑥 + 𝑇𝑦𝑦 .𝑇𝑦𝑦 )
* * * *
(b) 0.5𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑥𝑥 − 𝑇𝑥𝑦 .𝑇𝑥𝑦 + 𝑇𝑦𝑥 .𝑇𝑦𝑥 − 𝑇𝑦𝑦 .𝑇𝑦𝑦 )
* *
(c) 𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑥𝑦 + 𝑇𝑦𝑥 .𝑇𝑦𝑦 )
* *
(d) 𝐼𝑚(𝑇𝑥𝑥 .𝑇𝑥𝑦 + 𝑇𝑦𝑥 .𝑇𝑦𝑦 )
* * * *
(e) 0.5𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑥𝑥 + 𝑇𝑥𝑦 .𝑇𝑥𝑦 − 𝑇𝑦𝑥 .𝑇𝑦𝑥 − 𝑇𝑦𝑦 .𝑇𝑦𝑦 )
* * * *
(f) 0.5𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑥𝑥 − 𝑇𝑥𝑦 .𝑇𝑥𝑦 − 𝑇𝑦𝑥 .𝑇𝑦𝑥 + 𝑇𝑦𝑦 .𝑇𝑦𝑦 )
* *
(g) 𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑥𝑦 − 𝑇𝑦𝑥 .𝑇𝑦𝑦 )
* *
(h) 𝐼𝑚(𝑇𝑥𝑥 .𝑇𝑥𝑦 − 𝑇𝑦𝑥 .𝑇𝑦𝑦 )
* *
(i) 𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑦𝑥 + 𝑇𝑥𝑦 .𝑇𝑦𝑦 )
* *
(j) 𝐼𝑚(𝑇𝑥𝑥 .𝑇𝑦𝑥 − 𝑇𝑥𝑦 .𝑇𝑦𝑦 )
* *
(k) 𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑦𝑦 + 𝑇𝑥𝑦 .𝑇𝑦𝑥 )
* *
(l) 𝐼𝑚(𝑇𝑥𝑥 .𝑇𝑦𝑦 − 𝑇𝑥𝑦 .𝑇𝑦𝑥 )
* *
(m) 𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑦𝑥 + 𝑇𝑥𝑦 .𝑇𝑦𝑦 )
* *
(n) 𝐼𝑚(𝑇𝑥𝑥 .𝑇𝑦𝑥 − 𝑇𝑥𝑦 .𝑇𝑦𝑦 )
* *
(o) 𝑅𝑒(𝑇𝑥𝑥 .𝑇𝑦𝑦 + 𝑇𝑥𝑦 .𝑇𝑦𝑥 )
* *
(p) 𝐼𝑚(𝑇𝑥𝑥 .𝑇𝑦𝑦 − 𝑇𝑥𝑦 .𝑇𝑦𝑥 )
With:
• 𝑇𝑥𝑥 = −𝑆ℎℎ
• 𝑇𝑥𝑦 = −𝑆ℎ𝑣
• 𝑇𝑦𝑥 = 𝑆𝑣ℎ
• 𝑇𝑦𝑦 = 𝑆𝑣𝑣
5. muellertopoldegandpower (MuellerToPolarisationDegreeAndPowerFunctor)
(a) 𝑃𝑚𝑖𝑛
(b) 𝑃𝑚𝑎𝑥
(c) 𝐷𝑒𝑔𝑃𝑚𝑖𝑛
(d) 𝐷𝑒𝑔𝑃𝑚𝑎𝑥
Examples:
58 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Polarimetric decompositions
From one-band complex images (HH, HV, VH, VV), returns the selected decomposition. The H-alpha-A decom-
position is currently the only one available; it is implemented for the monostatic case (transmitter and receiver are
co-located). User must provide three one-band complex images HH, HV or VH, and VV (HV = VH in monostatic
case). The H-alpha-A decomposition consists in averaging 3x3 complex coherency matrices (incoherent analysis):
The user must provide the size of the averaging window, thanks to the parameter inco.kernelsize. The applications
returns a float vector image, made of three channels: H(entropy), Alpha, A(Anisotropy).
Here are the formula used (refer to the previous section about how the coherence matrix is obtained from the Sinclair
one):
∑︀2
1. 𝑒𝑛𝑡𝑟𝑜𝑝𝑦 = − 𝑖=0 𝑝[𝑖].log log 𝑝[𝑖]
3
∑︀2
2. 𝛼 = 𝑖=0 𝑝[𝑖].𝛼𝑖
𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[1]−𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[2]
3. 𝑎𝑛𝑖𝑠𝑜𝑡𝑟𝑜𝑝𝑦 = 𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[1]+𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[2]
Where:
∑︀2,𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[𝑖]>0
• 𝑝[𝑖] = 𝑚𝑎𝑥(𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[𝑖], 0)/ 𝑖=0 𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑎𝑙𝑢𝑒𝑠[𝑖]
180
• 𝛼𝑖 = |𝑆𝑜𝑟𝑡𝑒𝑑𝐸𝑖𝑔𝑒𝑛𝑉 𝑒𝑐𝑡𝑜𝑟[𝑖]| * 𝜋
Example:
We first extract a ROI from the original image (not required). Here imagery_HH.tif represents the element HH of the
Sinclair matrix (and so forth).
The result has three bands: entropy (0..1) - alpha (0..90) - anisotropy (0..1). It is split into 3 mono-band images thanks
to following command:
Each image is then colored thanks to a color look-up table ’hot’. Notice how minimum and maximum values are
provided for each polarimetric variable.
The results are shown in the figures below ([fig:entropyimage] , [fig:alphaimage] and [fig:anisotropyimage]).
60 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
62 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Polarimetric synthetis
This application gives, for each pixel, the power that would have been received by a SAR system with a basis different
from the classical (H,V) one (polarimetric synthetis). The new basis are indicated through two Jones vectors, defined
by the user thanks to orientation (psi) and ellipticity (khi) parameters. These parameters are namely psii, khii, psir and
khir. The suffixes (i) and (r) refer to the transmitting antenna and the receiving antenna respectively. Orientations and
ellipticity are given in degrees, and are between -90/90 degrees and -45/45 degrees respectively.
Four polarization architectures can be processed:
1. HH_HV_VH_VV: full polarization, general bistatic case.
2. HH_HV_VV or HH_VH_VV: full polarization, monostatic case (transmitter and receiver are co-located).
3. HH_HV: dual polarization.
4. VH_VV: dual polarization.
The application takes a complex vector image as input, where each band correspond to a particular emission/reception
polarization scheme. User must comply with the band order given above, since the bands are used to build the Sinclair
matrix.
In order to determine the architecture, the application first relies on the number of bands of the input image.
1. Architecture HH_HV_VH_VV is the only one with four bands, there is no possible confusion.
2. Concerning HH_HV_VV and HH_VH_VV architectures, both correspond to a three channels image. But they
are processed in the same way, as the Sinclair matrix is symmetric in the monostatic case.
3. Finally, the two last architectures (dual-polarization), can’t be distinguished only by the number of bands of
the input image. User must then use the parameters emissionh and emissionv to indicate the architecture of the
system: emissionh=1 and emissionv=0 for HH_HV, emissionh=0 and emissionv=1 for VH_VV.
Note: if the architecture is HH_HV, khii and psii are automatically set to 0/0 degrees; if the architecture is VH_VV,
khii and psii are automatically set to 0/90 degrees.
It is also possible to force the calculation to co-polar or cross-polar modes. In the co-polar case, values for psir and
khir will be ignored and forced to psii and khii; same as the cross-polar mode, where khir and psir will be forced to
psii + 90 degrees and -khii.
Finally, the result of the polarimetric synthesis is expressed in the power domain, through a one-band scalar image.
The final formula is thus: 𝑃 =| 𝐵 𝑇 .[𝑆].𝐴 |2 , where A ans B are two Jones vectors and S is a Sinclair matrix.
The two figures below ([fig:polsynthll] and [fig:polsynthlr]) show the two images obtained with the basis LL and LR
(L for left circular polarization and R for right polarization), from a Radarsat-2 image taken over Vancouver, Canada.
Once the four two-band images imagery_HH imagery_HV imagery_VH imagery_VV were merged into a single four
complex band image imageryC_HH_HV_VH_VV.tif, the following commands were used to produce the LL and LR
images:
The produced images were then rescaled to intensities ranging from 0 to 255 in order to be displayed.
64 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Finally, let’s talk about polarimetric data visualization. There is a strong link between polarimetric data visualization
and the way they can be decomposed into significant physical processes. Indeed, by setting the results (or combina-
tions) of such decompositions to RGB channels that help in interpreting SAR polarimetric images.
There is no specific dedicated application yet, but it is possible to use a combination of different applications as a
replacement. Let’s do it with a RADARSAT-2 acquisition over the famous place of the Golden Gate Bridge, San
Francisco, California.
We first make an extract from the original image (not mandatory).
Then we compute the amplitude of each band using the BandMath application:
Note that BandMath application interprets the image ’imagery_XX_extract.tif’ as an image made of two bands, where
the first one is related to the real part of the signal, and where the second one is related to the imaginary part (that’s
why the modulus is obtained by the expressions 𝑖𝑚1𝑏12 + 𝑖𝑚1𝑏22 ).
Then, we rescale the produced images to intensities ranging from 0 to 255:
Figures below ([fig:hhfrisco] , [fig:hvfrisco] and [fig:vvfrisco]) show the images obtained:
Now the most interesting step. In order to get a friendly coloration of these data, we are going to use the Pauli
decomposition, defined as follows:
|𝑆𝐻𝐻 −𝑆𝑉 𝑉 |
• 𝑎= √
2
√
• 𝑏= 2.|𝑆𝐻𝑉 |
|𝑆𝐻𝐻 +𝑆𝑉 𝑉 |
• 𝑐= √
2
66 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
68 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Note that sqrt(2) factors have been omitted purposely, since their effects will be canceled by the rescaling step. Then,
we rescale the produced images to intensities ranging from 0 to 255:
And finally, we merge the three bands into a single RGB image.
Residual registration
Image registration is a fundamental problem in image processing. The aim is to align two or more images of the
same scene often taken at different times, from different viewpoints, or by different sensors. It is a basic step for
orthorectification, image stitching, image fusion, change detection, and others. But this process is also critical for
stereo reconstruction process to be able to obtain an accurate estimation of epipolar geometry.
Sensor model is generally not sufficient to provide image registrations. Indeed, several sources of geometric distortion
can be contained in optical remote sensing images including earth rotation, platform movement, non linearity, etc.
They result in geometric errors on scene level, image level and pixel level. It is critical to rectify the errors before a
thematic map is generated, especially when the remote sensing data need to be integrated together with other GIS data.
This figure illustrates the generic workflow in the case of image series registration:
70 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
We will now illustrate this process by applying this workflow to register two images. This process can be easily
extended to perform image series registration.
The aim of this example is to describe how to register a Level 1 QuickBird image over an orthorectify Pleiades image
over the area of Toulouse, France.
72 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Figure 4.10: From left to right: Pleiades ortho-image, and original QuickBird image over Toulouse
We first dump geometry metadata of the image we want to refine in a text file. In OTB, we use the extension .geom
for this type of file. As you will see the application which will estimate a refine geometry only needs as input this
metadata and a set of homologous points. The refinement application will create a new .geom file containing refined
geometry parameters which can be used after for reprojection for example.
The use of external .geom file is available in OTB since release 3.16. See here for more information.
74 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
The main idea of the residual registration is to estimate an second transformation (after the application of sensors
model).
The homologous point application use interest point detection method to get a set of point which match in both images.
The basic idea is to use this set of homologous points and estimate with them a residual transformation between the
two images.
There is a wide variety of keypoint detector in the literature. They allow to detect and describe local features in
images. These algorithms provide for each interesting point a “feature description”. This descriptor has the property
to be invariant to image translation, scaling, and rotation, partially invariant to illumination changes and robust to local
geometric distortion. keypoints. Features extracted from the input images are then matched against each other. These
correspondences are then used to create the homologous points.
SIFT or SURF keypoints can be computed in the application. The band on which keypoints are computed can be set
independently for both images.
The application offers two modes:
• the first is the full mode where keypoints are extracted from the full extent of both images (please note that in
this mode large image file are not supported).
• The second mode, called geobins, allows to set-up spatial binning so as to get fewer points spread across the
entire image. In this mode, the corresponding spatial bin in the second image is estimated using geographical
transform or sensor modeling, and is padded according to the user defined precision.
Moreover, in both modes the application can filter matches whose co-localization in the first image exceed this pre-
cision. Last, the elevation parameters allow to deal more precisely with sensor modelling in case of sensor geometry
data. The outvector option allows to create a vector file with segments corresponding to the localization error between
the matches.
Finally, with the 2wgs84 option, you can match two sensor geometry images or a sensor geometry image with an
ortho-rectified reference. In all cases, you get a list of ground control points spread all over your image.
Note that for a proper use of the application, elevation must be correctly set (including DEM and geoid file).
Now that we can use this set of tie points to estimate a residual transformation.For this we use the dedicated application
called RefineSensorModel. This application make use of OSSIM capabilities to align the sensor model.
It reads the input geometry metadata file (.geom) which contains the sensor model information that we want to refine
and the text file (homologous_points.txt) containing the list of ground control point. It performs a least-square fit of the
sensor model adjustable parameters to these tie points and produces an updated geometry file as output (the extension
which is always use is .geom)
The application can provide as well an optional ground control points based statistics file and a vector file containing
residues that you can display in a GIS software.
Please note again that for a proper use of the application, elevation must be correctly set (including DEM and geoid
file). The map parameters allows to choose a map projection in which the accuracy will be estimated (in meters).
Accuracy values are provided as output of the application (computed using tie points location) and allow also to control
the precision of the estimated model.
Now we will show how we can use this new sensor model. In our case we’ll use this sensor model to orthorectify the
image over the Pléiades reference. Orfeo ToolBox offers since version 3.16 the possibility to use hrefhttp://wiki.orfeo-
toolbox.org/index.php/ExtendedFileNameextend image path to use different metadata file as input. That’s what we
are going to use there to orthorectify the QuickBird image using the .geom file obtained by the RefineSensorModel
applications. over the first one using for the second image estimated sensor model which take into account the original
sensor model of the slave and which also fit to the set of tie points.
As a result, if you’ve got enough homologous points in images and control that the residual error between the set of
tie points and the estimated sensor model is small, you must achieve a good registration now between the 2 rectified
images. Normally far better than ’only’ performing separate orthorectification over the 2 images.
This methodology can be adapt and apply in several cases, for example:
• register stereo pair of images and estimate accurate epipolar geometry
• registration prior to change detection
76 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
The BandMath application provides a simple and efficient way to perform band operations. The command line ap-
plication and the corresponding Monteverdi module (shown in the section [Band:sub:math module]) are based on
the same standards. It computes a band wise operation according to a user defined mathematical expression. The
following code computes the absolute difference between first bands of two images.
The naming convention “im[x]b[y]” designates the yth band of the xth input image.
The BandMath application embeds built-in operators and functions listed in muparser documentation thus allowing a
vast choice of possible operations.
Image files can contain a no-data value in their metadata. It represents a special pixel value that should be treated as
“no data available for this pixel”. For instance, SRTM tiles use a particular no-data value of -32768 (usually found on
sea areas).
On multiband images, the no-data values are handled independently for each band. The case of an image with no-data
values defined only for a subset of its bands is supported.
This metadata is now handled by OTB image readers and writer (using the GDAL driver). The no-data value can be
read from an image files and stored in the image metadata dictionary. It can also be exported by image writers. The
OTB filters that produce a no-data value are able to export this value so that the output file will store it.
An application has been created to manage the no-data value. The application has the following features:
• Build a mask corresponding to the no-data pixels in the input image: it gives you a binary image of the no-data
pixels in your input image.
• Change the no-data value of the input image: it will change all pixels that carry the old no-data value to the new
one and update the metadata
• Apply an external mask to the input image as no-data: all the pixels that corresponds have a null mask value are
flagged as no-data in the output image.
For instance, the following command converts the no-data value of the input image to the default value for DEM
(which is -32768):
The third mode “apply” can be useful if you apply a formula to the entire image. This will likely change the values of
pixels flagged as no-data, but the no-data value in the image metadata doesn’t change. If you want to fix all no-data
pixels to their original value, you can extract the mask of the original image and apply it on the output image. For
instance:
-mode buildmask
You can also use this “apply” mode with an additional parameter “mode.apply.ndval”. This parameter allow to set the
output nodata value applying according to your input mask.
Segmentation
Segmenting objects across a very high resolution scene and with a controlled quality is a difficult task for which no
method has reached a sufficient level of performance to be considered as operational.
Even if we leave aside the question of segmentation quality and consider that we have a method performing reasonably
well on our data and objects of interest, the task of scaling up segmentation to real very high resolution data is itself
challenging. First, we can not load the whole data into memory, and there is a need for on the flow processing which
does not cope well with traditional segmentation algorithms. Second, the result of the segmentation process itself is
difficult to represent and manipulate efficiently.
The experience of segmenting large remote sensing images is packed into a single Segmentation in OTB Applications
.
You can find more information about this application here.
LSMS is a segmentation workflow which allows to perform tile-wise segmentation of very large image with theoretical
guarantees of getting identical results to those without tiling.
It has been developed by David Youssefi and Julien Michel during David internship at CNES.
For more a complete description of the LSMS method, please refer to the following publication, J. Michel, D. Youssefi
and M. Grizonnet, “Stable Mean-Shift Algorithm and Its Application to the Segmentation of Arbitrarily Large Remote
Sensing Images,” in IEEE Transactions on Geoscience and Remote Sensing, vol. 53, no. 2, pp. 952-964, Feb. 2015.
The workflow consists in chaining 3 or 4 dedicated applications and produces a GIS vector file with artifact-free
polygons corresponding to the segmented image, as well as mean and variance of the radiometry of each band for each
polygon.
The first step of the workflow is to perform Mean-Shift smoothing with the MeanShiftSmoothing application:
otbcli_MeanShiftSmoothing -in input_image.tif
-fout filtered_range.tif
-foutpos filtered_spatial.tif
-ranger 30
-spatialr 5
-maxiter 10
-modesearch 0
78 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Note that the modesearch option should be disabled, and that the foutpos parameter is optional: it can be activated if
you want to perform the segmentation based on both spatial and range modes.
This application will smooth large images by streaming them, and deactivating the modesearch will guarantee that the
results will not depend on the streaming scheme. Please also note that the maxiter is used to set the margin to ensure
these identical results, and as such increasing the maxiter may have an additional impact on processing time.
Step 2: Segmentation
The next step is to produce an initial segmentation based on the smoothed images produced by the MeanShiftSmoothing
application. To do so, the LSMSSegmentation will process them by tiles whose dimensions are defined by the tilesizex
and tilesizey parameters, and by writing intermediate images to disk, thus keeping the memory consumption very low
throughout the process. The segmentation will group together neighboring pixels whose range distance is below the
ranger parameter and (optionally) spatial distance is below the spatialr parameter.
Note that the final segmentation image may contains a very large number of segments, and the uint32 image type
should therefore be used to ensure that there will be enough labels to index those segments. The minsize parameter
will filter segments whose size in pixels is below its value, and their labels will be set to 0 (nodata).
Please note that the output segmented image may look patchy, as if there were tiling artifacts: this is because segments
are numbered sequentially with respect to the order in which tiles are processed. You will see after the result of the
vectorization step that there are no artifacts in the results.
The LSMSSegmentation application will write as many intermediate files as tiles needed during processing. As such,
it may require twice as free disk space as the final size of the final image. The cleanup option (active by default) will
clear the intermediate files during the processing as soon as they are not needed anymore. By default, files will be
written to the current directory. The tmpdir option allows to specify a different directory for these intermediate files.
The LSMSSegmentation application allows to filter out small segments. In the output segmented image, those seg-
ments will be removed and replaced by the background label (0). Another solution to deal with the small regions is to
merge them with the closest big enough adjacent region in terms of radiometry. This is handled by the LSMSSmallRe-
gionsMerging application, which will output a segmented image where small regions have been merged. Again, the
uint32 image type is advised for this output image.
The minsize parameter allows to specify the threshold on the size of the regions to be merged. Like the LSMSSeg-
mentation application, this application will process the input images tile-wise to keep resources usage low, with the
guarantee of identical results. You can set the tile size using the tilesizex and tilesizey parameters. However unlike the
LSMSSegmentation application, it does not require to write any temporary file to disk.
Step 4: Vectorization
The last step of the LSMS workflow consists in the vectorization of the segmented image into a GIS vector file. This
vector file will contain one polygon per segment, and each of these polygons will hold additional attributes denoting
the label of the original segment, the size of the segment in pixels, and the mean and variance of each band over the
segment. The projection of the output GIS vector file will be the same as the projection from the input image (if input
image has no projection, so does the output GIS file).
This application will process the input images tile-wise to keep resources usage low, with the guarantee of identical
results. You can set the tile size using the tilesizex and tilesizey parameters. However unlike the LSMSSegmentation
application, it does not require to write any temporary file to disk.
All-in-one
The LargeScaleMeanShift application is a composite application that chains all the previous steps:
• Mean-Shift Smoothing
• Segmentation
• Small region merging
• Vectorization
Most of the settings from the previous applications are also exposed in this composite application. The range and
spatial radius used for the segmentation step are half the values used for Mean-Shift smooting, which are obtained
from LargeScaleMeanShift parameters. There are two output modes: vector (default) and raster. When the raster
output is chosen, last step (vectorization) is skipped.
There is a cleanup option that can be disabled in order to check intermediate outputs of this composite application.
This framework is dedicated to perform cartographic validation starting from the result of a detection (for example
a road extraction), enhance the results fiability by using a classifier fusion algorithm. Using a set of descriptor, the
processing chain validates or invalidates the input geometrical features.
The DSFuzzyModelEstimation application performs the fuzzy model estimation (once by use case: descriptor set /
Belief support / Plausibility support). It has the following input parameters:
• -psin a vector data of positive samples enriched according to the “Compute Descriptors” part
80 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
• -nsin a vector data of negative samples enriched according to the “Compute Descriptors” part
• -belsup a support for the Belief computation
• -plasup a support for the Plausibility computation
• -desclist an initialization model (xml file) or a descriptor name list (listing the descriptors to be included in
the model)
The application can be used like this:
The output file FuzzyModel.xml contains the optimal model to perform information fusion.
The first step in the classifier fusion based validation is to compute, for each studied polyline, the chosen descriptors.
In this context, the ComputePolylineFeatureFromImage application can be used for a large range of descriptors. It has
the following inputs:
• -in an image (of the sudied scene) corresponding to the chosen descriptor (NDVI, building Mask. . . )
• -vd a vector data containing polyline of interest
• -expr a formula (“b1 >0.4”, “b1 == 0”) where b1 is the standard name of input image first band
• -field a field name corresponding to the descriptor codename (NONDVI, ROADSA...)
The output is a vector data containing polylines with a new field containing the descriptor value. In order to add the
“NONDVI” descriptor to an input vector data (“inVD.shp”) corresponding to the percentage of pixels along a polyline
that verifies the formula “NDVI >0.4”:
NDVI.TIF is the NDVI mono band image of the studied scene. This step must be repeated for each chosen descriptor:
Both NDVI.TIF and roadSpectralAngle.TIF can be produced using Monteverdi feature extraction ca-
pabilities, and Buildings.TIF can be generated using Monteverdi rasterization module. From now on,
VD_NONDVI_ROADSA_NOBUIL.shp contains three descriptor fields. It will be used in the following part.
The final application (VectorDataDSValidation ) will validate or unvalidate the studied samples using the Dempster-
Shafer theory . Its inputs are:
• -in an enriched vector data “VD_NONDVI_ROADSA_NOBUIL.shp”
• -belsup a support for the Belief computation
• -plasup a support for the Plausibility computation
• -descmod a fuzzy model FuzzyModel.xml
The output is a vector data containing only the validated samples.
#include "otbBandMathImageFilterX.h"
#include "otbVectorImage.h"
return EXIT_SUCCESS;
}
As we can see, the new band math filter works with the class otb::VectorImage.
The default prefix name for variables related to the ith input is im(i+1) (note the indexing from 1 to N, for N inputs).
The user has the possibility to change this default behaviour by setting its own prefix.
82 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
// All variables related to image1 (input 0) will have the prefix im1
filter->SetNthInput(0, image1);
// All variables related to image2 (input 1) will have the prefix toulouse
filter->SetNthInput(1, image2, "toulouse");
// All variables related to anotherImage (input 2) will have the prefix im3
filter->SetNthInput(2, anotherImage);
In this document, we will keep the default convention. Following list summaries the available variables for input #0
(and so on for every input).
Variables and their descriptions:
Variables Description Type
im1 a pixel from first input, made of n components/bands (first image is indexed Vec-
by 1) tor
im1bj jth component of a pixel from first input (first band is indexed by 1) Scalar
im1bjNkxp a neighbourhood (”N”) of pixels of the jth component from first input, of size Ma-
kxp trix
im1bjMini global statistic: minimum of the jth band from first input Scalar
im1bjMaxi global statistic: maximum of the jth band from first input Scalar
im1bjMean global statistic: mean of the jth band from first input Scalar
im1bjSum global statistic: sum of the jth band from first input Scalar
im1bjVar global statistic: variance of the jth band from first input Scalar
im1PhyX and spacing of first input in X and Y directions Scalar
im1PhyY
[variables]
Moreover, we also have the generic variables idxX and idxY that represent the indices of the current pixel (scalars).
Note that the use of a global statistics will automatically make the filter (or the application) request the largest possible
regions from the concerned input images, without user intervention.
For instance, the following formula (addition of two pixels)
𝑖𝑚1 + 𝑖𝑚2
[firstequation]
is correct only if the two first inputs have the same number of bands. In addition, the following formula is not consistent
even if im1 represents a pixel of an image made of only one band:
𝑖𝑚1 + 1
A scalar can’t be added to a vector. The right formula is instead (one can notice the way that muParserX allows to
define vectors on the fly):
𝑖𝑚1 + {1}
or
Concerning division, this operation is not originally defined between two vectors (see next section “New operators and
functions” -[ssec:operators]-).
Now, let’s go back to the first formula: this one specifies the addition of two images band to band. With muParserX
lib, we can now define such operation with only one formula, instead of many formulas (as many as the number of
bands). We call this new functionality the batch mode, which directly arises from the introduction of vectors within
muParserX framework.
Finally, let’s say a few words about neighbourhood variables. These variables are defined for each particular input,
and for each particular band. The two last numbers, kxp, indicate the size of the neighbourhood. All neighbourhoods
are centred: this means that k and p can only be odd numbers. Moreover, k represents the dimension in the x direction
(number of columns), and p the dimension in the y direction (number of rows). For instance, im1b3N3x5 represents
the following neighbourhood:
. . .
. . .
. . .
. . .
. . .
[correctness]
Fundamentally, a neighbourhood is represented as a matrix inside the muParserX framework; so the remark about
mathematically well-defined formulas still stands.
New operators and functions have been implemented within BandMathImageFilterX. These ones can be divided into
two categories.
• adaptation of existing operators/functions, that were not originally defined for vectors and matrices (for instance
cos, sin, ...). These new operators/ functions keep the original names to which we add the prefix “v” for vector
(vcos, vsin, ...) .
• truly new operators/functions.
84 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Concerning the last category, here is a list of implemented operators or functions (they are all implemented in otb-
ParserXPlugins.h/.cxx files -OTB/Code/Common-):
Operators div and dv The first operator allows the definition of an element-wise division of two vectors (and even
matrices), provided that they have the same dimensions. The second one allows the definition of the division of a
vector/matrix by a scalar (components are divided by the same unique value). For instance:
𝑖𝑚1 𝑑𝑣 2.0
Operators mult and mlt These operators are the duals of the previous ones. For instance:
𝑖𝑚1 𝑝𝑤 2.0
Function bands This function allows to select specific bands from an image, and/or to rearrange them in a new vector;
for instance:
produces a vector of 4 components made of band 1, band 2, band 1 and band 1 values from the first input. Note that
curly brackets must be used in order to select the desired band indices.
** Function dotpr ** This function allows the dot product between two vectors or matrices (actually in our case, a
kernel and a neighbourhood of pixels):
∑︁
𝑚1 (𝑖, 𝑗) * 𝑚2 (𝑖, 𝑗)
(𝑖,𝑗)
For instance:
is correct provided that kernel1 and im1b1N3x5 have the same dimensions. The function can take as many neighbour-
hoods as needed in inputs.
Function mean This function allows to compute the mean value of a given vector or neighborhood (the function can
take as many inputs as needed; one mean value is computed per input). For instance:
Note: a limitation coming from muparserX itself makes impossible to pass all those neighborhoods with a unique
variable.
Function var This function allows to compute the variance of a given vector or neighborhood (the function can take
as many inputs as needed; one var value is computed per input). For instance:
𝑣𝑎𝑟(𝑖𝑚1𝑏1𝑁 3𝑥3)
Function median This function allows to compute the median value of a given vector or neighborhood (the function
can take as many inputs as needed; one median value is computed per input). For instance:
𝑚𝑒𝑑𝑖𝑎𝑛(𝑖𝑚1𝑏1𝑁 3𝑥3)
Function corr This function allows to compute the correlation between two vectors or matrices of the same dimensions
(the function takes two inputs). For instance:
Function maj This function allows to compute the most represented element within a vector or a matrix (the function
can take as many inputs as needed; one maj element value is computed per input). For instance:
Function vmin and vmax These functions allow to compute the min or max value of a given vector or neighborhood
(only one input). For instance:
Function cat This function allows to concatenate the results of several expressions into a multidimensional vector,
whatever their respective dimensions (the function can take as many inputs as needed). For instance:
Note: the user should prefer the use of semi-colons (;) when setting expressions, instead of directly use this function.
The filter or the application will call the function ’cat’ automatically. For instance:
Please, also refer to the next section “Application Programming Interface” ([ssec:API]).
Function ndvi This function implements the classical normalized difference vegetation index; it takes two inputs. For
instance:
𝑛𝑑𝑣𝑖(𝑖𝑚1𝑏1, 𝑖𝑚1𝑏4)
First argument is related to the visible red band, and the second one to the near-infrareds band.
The table below summarises the different functions and operators.
Functions and operators summary:
86 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
Variables Remark
ndvi two inputs
bands two inputs; length of second vector input gives the dimension of the output
dotptr many inputs
cat many inputs
mean many inputs
var many inputs
median many inputs
maj many inputs
corr two inputs
div and dv operators
mult and mlt operators
pow and pw operators
vnorm adapation of an existing function to vectors: one input
vabs adapation of an existing function to vectors: one input
vmin adapation of an existing function to vectors: one input
vmax adapation of an existing function to vectors: one input
vcos adapation of an existing function to vectors: one input
vsin adapation of an existing function to vectors: one input
vtan adapation of an existing function to vectors: one input
vtanh adapation of an existing function to vectors: one input
vsinh adapation of an existing function to vectors: one input
vcosh adapation of an existing function to vectors: one input
vlog adapation of an existing function to vectors: one input
vlog10 adapation of an existing function to vectors: one input
vexp adapation of an existing function to vectors: one input
vsqrt adapation of an existing function to vectors: one input
[variables]
In this section, we make some comments about the public member functions of the new band math filter.
/** Set the nth filter input with or without a specified associated variable name */
void SetNthInput( unsigned int idx, const ImageType * image);
void SetNthInput( unsigned int idx, const ImageType * image, const std::string&
˓→varName);
Refer to the section “Syntax: first elements” ([ssec:syntax]) where the two first functions have already been com-
mented. The function GetNthInput is quite clear to understand.
Each time the function SetExpression is called, a new expression is pushed inside the filter. There are as many
outputs as there are expressions. The dimensions of the outputs (number of bands) are totally dependent on the
dimensions of the related expressions (see also last remark of the section “Syntax: first element” -[ssec:syntax]-).
Thus, the filter always performs a pre-evaluation of each expression, in order to guess how to allocate the outputs.
The concatenation of the results of many expressions (whose results can have different dimensions) into one unique
output is possible. For that puropose, semi-colons (“;”) are used as separating characters. For instance:
will produce a unique output (one expression) of many bands (actually, number of bands of im1 + 1).
This function allows the user to get any expression by its ID number.
This function allows the user to set new vectors or matrices. This is particularly useful when the user wants to use
the dotpr function (see previous section). First argument is related to the name of the variable, and the second one
to the definition of the vector/matrix. The definition is done by a string, where first and last elements must be curly
brackets (“{” and “}”). Different elements of a row are separated by commas (“,”), and different rows are separated by
semi-colons (“;”). For instance:
This function allows the user to get the list of the variable and constant names, in the form of a std::vector of strings.
This function allows the user to define new constants and/or expressions (context) by using a txt file with a specific
syntax. For the definition of constants, the following pattern must be observed: #type name value. For instance:
#F expo 1.1 #M kernel1 { 0.1 , 0.2 , 0.3 ; 0.4 , 0.5 , 0.6 ; 0.7 , 0.8 , 0.9 ; 1 , 1.1 , 1.2 ; 1.3 , 1.4 , 1.5 }
As we can see, #I/#F allows the definition of an integer/float constant, whereas #M allows the definition of a vec-
tor/matrix. It is also possible to define expressions within the same txt file, with the pattern #E expr. For instance:
#F expo 1.1 #M kernel1 0.1 , 0.2 , 0.3 ; 0.4 , 0.5 , 0.6 ; 0.7 , 0.8 , 0.9 ; 1 , 1.1 , 1.2 ; 1.3 , 1.4 , 1.5 #E
dotpr(kernel1,im1b1N3x5)
88 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
This function allows the user to export a txt file that saves its favorite constant or expression definitions. Such a file
will be reusable by the ImportContext function (see above).
Please, also refer to the section dedicated to application.
Principles
Sensor images have often a wide dynamic range. Whereas it is helpful to have high precision to do com-
plex processing, it is pretty hard to display high dynamic images, even on modern screen as the dynamic
range for basic screen is of 8 bits while images can be encoded on 12 or 16 bits (or even more!).
The ContrastEnhancement application aims to reduce the image dynamic by reorganizing it in a smarter
way than just linear compression and improve the local contrast and enhance the definitions of edges.
The equalization of histogram creates a look up table in order to maximize the dynamic. The target histogram is
perfectly flat. The gain applied on each pixel comes from the computation of the transfer function 𝑇 such that :
∫︁ 𝑖*𝑇 (𝑖) ∫︁ 𝑖
∀𝑖 ℎ𝑖𝑠𝑡𝑜𝑔𝑟𝑎𝑚 (𝑗)𝑑𝑗 = ℎ𝑡𝑎𝑟𝑔𝑒𝑡 (𝑗)𝑑𝑗
𝑚𝑖𝑛 𝑚𝑖𝑛
where ℎ𝑡𝑎𝑟𝑔𝑒𝑡 is the corresponding flat histogram with the constraint that white and black are still white and black after
equalization :
𝑇 (𝑚𝑖𝑛) = 𝑇 (𝑚𝑎𝑥) = 1
You can apply this transformation with the ContrastEnhancement application:
otbcli_ContrastEnhancement -in input_image.tif
-out output_image.tif
-spatial global
Advanced parameters
The ContrastEnhancement provides different options to configure the contrast enhancement method. Let us see what
there are for.
90 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
The ContrastEnhancement application also offers a way to limit contrast by adjusting original histogram with the hfact
parameter. The limitation factor represents the limit height that can have any bucket of the histogram; the application
computes the height of the flat histogram and the maximal height is the limitation factor time this “flat height”.
Finally, you can ignore a particular value with the nodata parameter, and also set manually your minimum and maxi-
mum value. Any value out of bound will be ignored.
Classification
The Orfeo ToolBox provided applications to train a supervised or unsupervised classifier from different set of features
and to use the generated classifier for vector data classification. Those features can be information extracted from
images (see feature extraction section) or it can be different types of features such as the perimeter, width, or area of a
surface present in a vector data file in an ogr compatible format.
The TrainVectorClassifier application provide a way to train a classifier with an input set of labeled geometries and a
list of features to consider for classification.
6.7. Classification 91
OTB CookBook Documentation, Release 6.6.0
The -classifier parameter allows to choose which machine learning model algorithm to train. You have the
possibility to do the unsupervised classification,for it, you must to choose the Shark kmeans classifier. Please refer to
the TrainVectorClassifier application reference documentation.
In case of multiple sample files, you can add them to the -io.vd parameter.
The feature to be used for training must be explicitly listed using the -feat parameter. Order of the list matters.
If you want to use a statistic file for features normalization, you can pass it using the -io.stats parameter. Make
sure that the order of feature statistics in the statistics file matches the order of feature passed to the -feat option.
The field in vector data allowing to specify the label of each sample can be set using the -cfield option.
By default, the application will estimate the trained classifier performances on the same set of samples that has been
used for training. The -io.vd parameter allows for the specification of different sample files for this purpose, for a
more fair estimation of the performances. Note that this scheme to estimate the performance can also be carried out
afterwards (see Validating the classification model section).
Feature classification
Once the classifier has been trained, one can apply the model to classify a set of features on a new vector data file
using the VectorClassifier application:
This application outputs a vector data file storing sample values and classification labels. The output vector file is
optional. If no output is given to the application, the input vector data classification label field is updated. If a statistics
file was used to normalize the features during training, it shall also be used here, during classification.
Note that with this application, the machine learning model may come from a training on image or vector data, it
doesn’t matter. The only requirement is that the chosen features to use should be the same as the one used during
training.
Validating classification
The performance of the model generated by the TrainVectorClassifier or TrainImagesClassifier applications is directly
estimated by the application itself, which displays the precision, recall and F-score of each class, and can generate
the global confusion matrix for supervised algorithms. For unsupervised algorithms a contingency table is generated.
These results are output as an *.CSV file.
Orfeo ToolBox ships with a set of application to perform supervised or unsupervised pixel-based image classification.
This framework allows to learn from multiple images, and using several machine learning method such as SVM, Bayes,
KNN, Random Forests, Artificial Neural Network, and others...(see application help of TrainImagesClassifier
and TrainVectorClassifier for further details about all the available classifiers). Here is an overview of the
complete workflow:
1. Compute samples statistics for each image
2. Compute sampling rates for each image (only if more than one input image)
3. Select samples positions for each image
92 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
The first step of the framework is to know how many samples are available for each class in your image. The
PolygonClassStatistics will do this job for you. This application processes a set of training geometries
and an image and outputs statistics about available samples (i.e. pixel covered by the image and out of a no-data mask
if provided), in the form of a XML file:
• number of samples per class
• number of samples per geometry
Supported geometries are polygons, lines and points. Depending on the geometry type, this application behaves
differently:
• polygon: select pixels whose center falls inside the polygon
• lines: select pixels intersecting the line
• points: select closest pixel to the provided point
The application will require the input image, but it is only used to define the footprint in which samples will be selected.
The user can also provide a raster mask, that will be used to discard pixel positions, using parameter -mask.
A simple use of the application PolygonClassStatistics could be as follows:
The -field parameter is the name of the field that corresponds to class labels in the input geometries.
The output XML file will look like this:
6.7. Classification 93
OTB CookBook Documentation, Release 6.6.0
Sample selection
Now, we know exactly how many samples are available in the image for each class and each geometry in the training
set. From these statistics, we can now compute the sampling rates to apply for each class, and perform the sample
selection. This will be done by the SampleSelection application.
There are several strategies to compute those sampling rates:
• Constant strategy: All classes will be sampled with the same number of samples, which is user-defined.
• Smallest class strategy: The class with the least number of samples will be fully sampled. All other classes
will be sampled with the same number of samples.
• Percent strategy: Each class will be sampled with a user-defined percentage (same value for all classes) of
samples available in this class.
• Total strategy: A global number of samples to select is divided proportionally among each class (class propor-
tions are enforced).
• Take all strategy: Take all the available samples.
• By class strategy: Set a target number of samples for each class. The number of samples for each class is read
from a CSV file.
To actually select the sample positions, there are two available sampling techniques:
• Random: Randomly select samples while respecting the sampling rate.
• Periodic: Sample periodically using the sampling rate.
The application will make sure that samples spans the whole training set extent by adjusting the sampling rate. De-
pending on the strategy to determine the sampling rate, some geometries of the training set may not be sampled.
The application will accept as input the input image and training geometries, as well class statistics XML file computed
during the previous step. It will output a vector file containing point geometries which indicate the location of the
samples.
The csv file written by the optional -outrates parameter sums-up what has been done during sample selection:
94 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
36 941 941 1
41 941 2630 0.357795
51 941 11221 0.0838606
Fig. 6.1: This image shows the polygons of the training with a color corresponding to their class. The red dot shows
the samples that have been selected.
Samples extraction
Now that the locations of the samples are selected, we will attach measurements to them. This is the purpose of the
SampleExtraction application. It will walk through the list of samples and extract the underlying pixel values.
If no -out parameter is given, the SampleExtraction application can work in update mode, thus allowing to
extract features from multiple images of the same location.
Features will be stored in fields attached to each sample. Field name can be generated from a prefix a sequence
of numbers (i.e. if prefix is feature_ then features will be named feature_0, feature_1, ...). This can be
achieved with the -outfield prefix option. Alternatively, one can set explicit names for all features using the
-outfield list option.
6.7. Classification 95
OTB CookBook Documentation, Release 6.6.0
If the training set spans several images, the MultiImageSamplingRate application allows to compute the appro-
priate sampling rates per image and per class, in order to get samples that span the entire extents of the images.
It is first required to run the PolygonClassStatistics application on each image of the set separately. The
MultiImageSamplingRate application will then read all the produced statistics XML files and derive the sam-
pling rates according the sampling strategy. For more information, please refer to the Samples statistics estimation
section.
There are 3 modes for the sampling rates estimation from multiple images:
• Proportional mode: For each class, the requested number of samples is divided proportionally among the
images.
• Equal mode: For each class, the requested number of samples is divided equally among the images.
• Custom mode: The user indicates the target number of samples for each image.
The different behaviors for each mode and strategy are described as follows.
𝑇𝑖 (𝑐) and 𝑁𝑖 (𝑐) refers resp. to the total number and needed number of samples in image 𝑖 for class 𝑐. Let’s call 𝐿 the
total number of image.
• Strategy = all
– Same behavior for all modes proportional, equal, custom: take all samples
• Strategy = constant (let’s call 𝑀 the global number of samples per class required)
𝑀 *𝑇𝑖 (𝑐)
– Mode = proportional: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝑠𝑢𝑚𝑘 (𝑇𝑘 (𝑐))
𝑀
– Mode = equal: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝐿
– Mode = custom: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝑀𝑖 where 𝑀𝑖 is the custom requested number
of samples for image i
96 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
• Strategy = byClass (let’s call 𝑀 (𝑐) the global number of samples for class c)
𝑇𝑖 (𝑐)
– Mode = proportional: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝑀 (𝑐) * 𝑠𝑢𝑚𝑘 (𝑇𝑘 (𝑐))
𝑀 (𝑐)
– Mode = equal: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝐿
– Mode = custom: For each image 𝑖 and each class 𝑐, 𝑁 𝑖(𝑐) = 𝑀𝑖 (𝑐) where 𝑀𝑖 (𝑐) is the custom requested
number of samples for each image 𝑖 and each class 𝑐
• Strategy = percent
– Mode = proportional: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝑝 * 𝑇𝑖 (𝑐) where 𝑝 is the user-defined
percentage
𝑠𝑢𝑚𝑘 (𝑇 𝑘(𝑐))
– Mode = equal: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝑝 * 𝐿 where 𝑝 is the user-defined
percentage
– Mode = custom: For each image 𝑖 and each class 𝑐, 𝑁 𝑖(𝑐) = 𝑝(𝑖) * 𝑇𝑖 (𝑐) where 𝑝(𝑖) is the user-defined
percentage for image 𝑖
• Strategy = total
𝑠𝑢𝑚𝑘 (𝑇 𝑖(𝑘))
– Mode = proportional: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = 𝑡𝑜𝑡𝑎𝑙 * ( 𝑠𝑢𝑚 𝑘 𝑙(𝑇 𝑙(𝑘))
) * ( 𝑠𝑢𝑚𝑇𝑘𝑖(𝑐)
(𝑇 𝑖(𝑘)) )
where 𝑡𝑜𝑡𝑎𝑙 is the total number of samples specified
– Mode = equal: For each image 𝑖 and each class 𝑐, 𝑁𝑖 (𝑐) = (𝑡𝑜𝑡𝑎𝑙/𝐿) * ( 𝑠𝑢𝑚𝑇𝑘𝑖(𝑐)
(𝑇 𝑖(𝑘)) ) where 𝑡𝑜𝑡𝑎𝑙 is the
total number of samples specified
– Mode = custom: For each image 𝑖 and each class 𝑐, 𝑁 𝑖(𝑐) = 𝑡𝑜𝑡𝑎𝑙(𝑖) * ( 𝑠𝑢𝑚𝑇𝑘𝑖(𝑐)
(𝑇 𝑖(𝑘)) ) where 𝑡𝑜𝑡𝑎𝑙(𝑖) is
the total number of samples specified for image 𝑖
• Strategy = smallest class
– Mode = proportional: the smallest class is computed globally, then this smallest size is used for the
strategy constant+proportional
– Mode = equal: the smallest class is computed globally, then this smallest size is used for the strategy
constant+equal
– Mode = custom: the smallest class is computed and used for each image separately
The MultiImageSamplingRate application can be used as follows:
The output filename from -out parameter will be used to generate as many filenames as necessary (e.g. one per input
filename), called rates_1.csv, rates_2.csv ...
Once rates are computed for each image, sample selection can be performed on each corresponding image using the
by class strategy:
6.7. Classification 97
OTB CookBook Documentation, Release 6.6.0
Samples extraction can then be performed on each image b y following the Samples extraction step. The learning
application can process several samples files.
Some machine learning algorithms converge faster if the range of features is [−1, 1] or [0, 1]. Other will be sensitive
to relative ranges between feature, e.g. a feature with a larger range might have more weight in the final decision. This
is for instance the case for machine learning algorithm using euclidean distance at some point to compare features. In
those cases, it is advised to normalize all features to the range [−1, 1] before performing the learning. For this purpose,
the ComputeImageStatistics application allows to compute and output to an XML file the mean and standard
deviation based on pooled variance of each band for one or several images.
The output statistics file can then be fed to the training and classification applications.
Now that the training samples are ready, we can perform the learning using the TrainVectorClassifier appli-
cation.
In case of multiple samples files, you can add them to the -io.vd parameter (see Working with several images
section).
For more information about the training process for features please refer to the Train a classifier with features section.
Once the classifier has been trained, one can apply the model to classify pixel inside defined classes on a new image
using the ImageClassifier application:
You can set an input mask to limit the classification to the mask area with value >0.
-imstat images_statistics.xml
The Orfeo ToolBox training applications provides information about the performance of the generated model (see
Validating classification ).
With the ConputeConfusionMatrix application, it is also possible to estimate the performance of a model from a clas-
sification map generated with the ImageClassifier application. This labeled image is compared to positive reference
98 Chapter 6. Recipes
OTB CookBook Documentation, Release 6.6.0
samples (either represented as a raster labeled image or as a vector data containing the reference classes). It will com-
pute the confusion matrix and precision, recall and F-score of each class too, based on the ConfusionMatrixCalculator
class.
If you have made an unsupervised classification, it must be specified to the ConputeConfusionMatrix applica-
tion. In this case, a contingency table have to be create rather than a confusion matrix. For further details, see format
parameter in the application help of ConputeConfusionMatrix.
Color mapping can be used to apply color transformations on the final gray level label image. It allows to get an RGB
classification map by re-mapping the image values to be suitable for display purposes. One can use the ColorMapping
application. This tool will replace each label with an 8-bits RGB color specified in a mapping file. The mapping file
should look like this:
In the previous example, 1 is the label and 255 0 0 is a RGB color (this one will be rendered as red). To use the
mapping tool, enter the following:
Other look-up tables (LUT) are available: standard continuous LUT, optimal LUT, and LUT computed over a support
image.
Example
We consider 4 classes: water, roads, vegetation and buildings with red roofs. Data is available in the OTB-Data reposi-
tory .
Figure 2: From left to right: Original image, result image with fusion (with monteverdi viewer) of original image and
fancy classification and input image with fancy color classification from labeled image.
6.7. Classification 99
OTB CookBook Documentation, Release 6.6.0
Unsupervised learning
Using the same machine learning framework, it is also possible to perform unsupervised classification. In this case,
the main difference is that the training samples don’t need a real class label. However, in order to use the same
TrainImagesClassifier application, you still need to provide a vector data file with a label field. This vector file will be
used to extract samples for the training. Each label value is can be considered as a source area for samples, the same
logic as in supervised learning is applied for the computation of extracted samples per area. Hence, for unsupervised
classification, the samples are selected based on classes that are not actually used during the training. For the moment,
only the KMeans algorithm is proposed in this framework.
otbcli_TrainImageClassifier
-io.il image.tif
-io.vd training_areas.shp
-io.out model.txt
-sample.vfn Class
-classifier sharkkm
-classifier.sharkkm.k 4
If your training samples are in a vector data file, you can use the application TrainVectorClassifier. In this case, you
don’t need a fake label field. You just need to specify which fields shall be used to do the training.
otbcli_TrainVectorClassifier
-io.vd training_samples.shp
-io.out model.txt
-feat perimeter area width red nir
-classifier sharkkm
-classifier.sharkkm.k 4
Once you have the model file, the actual classification step is the same as the supervised case. The model will predict
labels on your input data.
otbcli_ImageClassifier
-in input_image.tif
-model model.txt
-out kmeans_labels.tif
After having processed several classifications of the same input image but from different models or methods (SVM,
KNN, Random Forest,...), it is possible to make a fusion of these classification maps with the FusionOfClassifications
application which uses either majority voting or the Dempster-Shafer framework to handle this fusion. The Fusion of
Classifications generates a single more robust and precise classification map which combines the information extracted
from the input list of labeled images.
The FusionOfClassifications application has the following input parameters:
• -il list of input labeled classification images to fuse
• -out the output labeled image resulting from the fusion of the input classification images
• -method the fusion method (either by majority voting or by Dempster Shafer)
• -nodatalabel label for the no data class (default value = 0)
• -undecidedlabel label for the undecided class (default value = 0)
The input pixels with the no-data class label are simply ignored by the fusion process. Moreover, the output pixels for
which the fusion process does not result in a unique class label, are set to the undecided value.
In the Majority Voting method implemented in the FusionOfClassifications application, the value of each output pixel
is equal to the more frequent class label of the same pixel in the input classification maps. However, it may happen
that the more frequent class labels are not unique in individual pixels. In that case, the undecided label is attributed to
the output pixels.
The application can be used like this:
Let us consider 6 independent classification maps of the same input image (Cf. left image in Figure2) generated
from 6 different SVM models. The Figure3 represents them after a color mapping by the same LUT. Thus, 4
classes (water: blue, roads: gray,vegetation: green, buildings with red roofs: red) are observable on each of them.
Figure 3: Six fancy colored classified images to be fused, generated from 6 different SVM models.
As an example of the FusionOfClassifications application by majority voting, the fusion of the six input classification
maps represented in Figure3 leads to the classification map illustrated on the right in Figure4. Thus, it appears that
this fusion highlights the more relevant classes among the six different input classifications. The white parts of the
fused image correspond to the undecided class labels, i.e. to pixels for which there is not a unique majority voting.
Figure 4: From left to right: Original image, and fancy colored classified image obtained by a majority voting fusion
of the 6 classification maps represented in Fig. 4.13 (water: blue, roads: gray, vegetation: green, buildings with red
roofs: red, undecided: white)
The FusionOfClassifications application, handles another method to compute the fusion: the Dempster Shafer frame-
work. In the Dempster-Shafer theory , the performance of each classifier resulting in the classification maps to fuse are
evaluated with the help of the so-called belief function of each class label, which measures the degree of belief that the
corresponding label is correctly assigned to a pixel. For each classifier, and for each class label, these belief functions
are estimated from another parameter called the mass of belief of each class label, which measures the confidence that
the user can have in each classifier according to the resulting labels.
In the Dempster Shafer framework for the fusion of classification maps, the fused class label for each pixel is the one
with the maximal belief function. In case of multiple class labels maximizing the belief functions, the output fused
pixels are set to the undecided value.
In order to estimate the confidence level in each classification map, each of them should be confronted with a ground
truth. For this purpose, the masses of belief of the class labels resulting from a classifier are estimated from its
confusion matrix, which is itself exported as a *.CSV file with the help of the ComputeConfusionMatrix application.
Thus, using the Dempster-Shafer method to fuse classification maps needs an additional input list of such *.CSV files
corresponding to their respective confusion matrices.
The application can be used like this:
As an example of the FusionOfClassifications application by Dempster Shafer, the fusion of the six input classification
maps represented in Figure3 leads to the classification map illustrated on the right in Figure5. Thus, it appears that
this fusion gives access to a more precise and robust classification map based on the confidence level in each classifier.
Figure 5: From left to right: Original image, and fancy colored classified image obtained by a Dempster-Shafer fusion
of the 6 classification maps represented in Figure3 (water: blue, roads: gray, vegetation: green, buildings with red
roofs: red, undecided: white).
In order to properly use the FusionOfClassifications application, some points should be considered. First, the
list_of_input_images and OutputFusedClassificationImage are single band labeled images, which
means that the value of each pixel corresponds to the class label it belongs to, and labels in each classification map
must represent the same class. Secondly, the undecided label value must be different from existing labels in the input
images in order to avoid any ambiguity in the interpretation of the OutputFusedClassificationImage.
Resulting classification maps can be regularized in order to smooth irregular classes. Such a regularization process
improves classification results by making more homogeneous areas which are easier to handle.
The ClassificationMapRegularization application performs a regularization of a labeled input image based on the
Majority Voting method in a specified ball shaped neighborhood. For each center pixel, Majority Voting takes the
more representative value of all the pixels identified by the structuring element and then sets the output center pixel to
this majority label value. The ball shaped neighborhood is identified by its radius expressed in pixels.
Handling ambiguity and not classified pixels in the majority voting based regularization
Since, the Majority Voting regularization may lead to not unique majority labels in the neighborhood, it is important to
define which behaviour the filter must have in this case. For this purpose, a Boolean parameter (called ip.suvbool) is
used in the ClassificationMapRegularization application to choose whether pixels with more than one majority class
are set to Undecided (true), or to their Original labels (false = default value).
Moreover, it may happen that pixels in the input image do not belong to any of the considered class. Such pixels are
assumed to belong to the NoData class, the label of which is specified as an input parameter for the regularization.
Therefore, those NoData input pixels are invariant and keep their NoData label in the output regularized image.
The ClassificationMapRegularization application has the following input parameters:
• -io.in labeled input image resulting from a previous classification process
• -io.out output labeled image corresponding to the regularization of the input image
• -ip.radius integer corresponding to the radius of the ball shaped structuring element (default value = 1
pixel)
• -ip.suvbool boolean parameter used to choose whether pixels with more than one majority class are set to
Undecided (true), or to their Original labels (false = default value). Please note that the Undecided value must
be different from existing labels in the input image
• -ip.nodatalabel label for the NoData class. Such input pixels keep their NoData label in the output image
(default value = 0)
• -ip.undecidedlabel label for the Undecided class (default value = 0).
The application can be used like this:
In order to properly use the ClassificationMapRegularization application, some points should be considered. First,
both InputLabeledImage and OutputLabeledImage are single band labeled images, which means that the
value of each pixel corresponds to the class label it belongs to. The InputLabeledImage is commonly an image
generated with a classification algorithm such as the SVM classification. Remark: both InputLabeledImage and
OutputLabeledImage are not necessarily of the same type. Secondly, if ip.suvbool == true, the Undecided label
value must be different from existing labels in the input labeled image in order to avoid any ambiguity in the inter-
pretation of the regularized OutputLabeledImage. Finally, the structuring element radius must have a minimum
value equal to 1 pixel, which is its default value. Both NoData and Undecided labels have a default value equal to 0.
Example
Resulting from the application presented in section Fancy classification results and illustrated in Figure2, the Figure6
shows a regularization of a classification map composed of 4 classes: water, roads, vegetation and buildings with red
roofs. The radius of the ball shaped structuring element is equal to 3 pixels, which corresponds to a ball included in a
7 x 7 pixels square. Pixels with more than one majority class keep their original labels.
Regression
The machine learning models in OpenCV and LibSVM also support a regression mode: they can be used to predict
a numeric value (i.e. not a class index) from an input predictor. The workflow is the same as classification. First,
the regression model is trained, then it can be used to predict output values. The applications to do that are and .
Figure 6: From left to right: Original image, fancy colored classified image and regularized classification map with
radius equal to 3 pixels.
The input data set for training must have the following structure:
• n components for the input predictors
• one component for the corresponding output value
The application supports 2 input formats:
• An image list: each image should have components matching the structure detailed earlier (n feature components
+ 1 output value)
• A CSV file: the first n columns are the feature components and the last one is the output value
If you have separate images for predictors and output values, you can use the application.
Statistics estimation
As in classification, a statistics estimation step can be performed before training. It allows to normalize the dynamic of
the input predictors to a standard one: zero mean, unit standard deviation. The main difference with the classification
case is that with regression, the dynamic of output values can also be reduced.
The statistics file format is identical to the output file from application, for instance:
In the application, normalization of input predictors and output values is optional. There are 3 options:
• No statistic file: normalization disabled
• Statistic file with n components: normalization enabled for input predictors only
• Statistic file with n+1 components: normalization enabled for input predictors and output values
If you use an image list as training set, you can run application. It will produce a statistics file suitable for input and
output normalization (third option).
Training
Initially, the machine learning models in OTB only used classification. But since they come from external libraries
(OpenCV and LibSVM), the regression mode was already implemented in these external libraries. So the integration
of these models in OTB has been improved in order to allow the usage of regression mode. As a consequence , the
machine learning models have nearly the same set of parameters for classification and regression mode.
• Decision Trees
• Gradient Boosted Trees
• Neural Network
• Random Forests
• K-Nearest Neighbors
The behavior of application is very similar to . From the input data set, a portion of the samples is used for training,
whereas the other part is used for validation. The user may also set the model to train and its parameters. Once the
training is done, the model is stored in an output file.
Prediction
Once the model is trained, it can be used in application to perform the prediction on an entire image containing input
predictors (i.e. an image with only n feature components). If the model was trained with normalization, the same
statistic file must be used for prediction. The behavior of with respect to statistic file is identical to:
• no statistic file: normalization off
• n components: input only
• n+1 components: input and output
The model to use is read from file (the one produced during training).
Feature extraction
As described in the OTB Software Guide, the term Feature Extraction refers to techniques aiming at extracting added
value information from images. These extracted items named features can be local statistical moments, edges, radio-
metric indices, morphological and textural properties. For example, such features can be used as input data for other
image processing methods like Segmentation and Classification .
This application computes the 4 local statistical moments on every pixel in the selected channel of the input image,
over a specified neighborhood. The output image is multi band with one statistical moment (feature) per band. Thus,
the 4 output features are the Mean, the Variance, the Skewness and the Kurtosis. They are provided in this exact order
in the output image.
The LocalStatisticExtraction application has the following input parameters:
--in the input image to compute the features on
--channel the selected channel index in the input image to be processed (default value is 1)
--radius the computational window radius (default value is 3 pixels)
--out the output image containing the local statistical moments
The application can be used like this:
otbcli_LocalStatisticExtraction -in InputImage
-channel 1
-radius 3
-out OutputImage
Edge extraction
This application Computes edge features on every pixel in the selected channel of the input image.
The EdgeExtraction application has the following input parameters:
--in the input image to compute the features on
--channel the selected channel index in the input image to be processed (default value is 1)
• -filter the choice of edge detection method (gradient/sobel/touzi) (default value is gradient)
-(-filter.touzi.xradius) the X Radius of the Touzi processing neighborhood (only if fil-
ter==touzi) (default value is 1 pixel) __
• (-filter.touzi.yradius) the Y Radius of the Touzi processing neighborhood (only if fil-
ter==touzi) (default value is 1 pixel)
--out the output mono band image containing the edge features
The application can be used like this:
This application computes radiometric indices using the channels of the input image. The output is a multi band image
into which each channel is one of the selected indices.
The RadiometricIndices application has the following input parameters:
--in the input image to compute the features on
--out the output image containing the radiometric indices
--channels.blue the Blue channel index in the input image (default value is 1)
--channels.green the Green channel index in the input image (default value is 1)
--channels.red the Red channel index in the input image (default value is 1)
--channels.nir the Near Infrared channel index in the input image (default value is 1)
--channels.mir the Mid-Infrared channel index in the input image (default value is 1)
--list the list of available radiometric indices (default value is Vegetation:NDVI)
The available radiometric indices to be listed into -list with their relevant channels in brackets are:
The application can be used as follows, which would produce an output image containing 3 bands, respectively with
the Vegetation:NDVI, Vegetation:RVI and Vegetation:IPVI radiometric indices in this exact order:
or as follows, which would produce a single band output image with the Water:NDWI2 radiometric index:
Morphological features can be highlighted by using image filters based on mathematical morphology either on binary
or gray scale images.
This application performs binary morphological operations (dilation, erosion, opening and closing) on a mono band
image with a specific structuring element (a ball or a cross) having one radius along X and another one along Y. NB:
the cross shaped structuring element has a fixed radius equal to 1 pixel in both X and Y directions.
The BinaryMorphologicalOperation application has the following input parameters:
--in the input image to be filtered
--channel the selected channel index in the input image to be processed (default value is 1)
--structype the choice of the structuring element type (ball/cross) (default value is ball)
-(-structype.ball.xradius) the ball structuring element X Radius (only if structype==ball) (default
value is 5 pixels)
-(-structype.ball.yradius) the ball structuring element Y Radius (only if structype==ball) (default
value is 5 pixels)
--filter the choice of the morphological operation (dilate/erode/opening/closing) (default value is dilate)
-(-filter.dilate.foreval) the foreground value for the dilation (idem for filter.erode/opening/closing)
(default value is 1)
-(-filter.dilate.backval) the background value for the dilation (idem for filter.erode/opening/closing)
(default value is 0)
--out the output filtered image
The application can be used like this:
This application performs morphological operations (dilation, erosion, opening and closing) on a gray scale mono
band image with a specific structuring element (a ball or a cross) having one radius along X and another one along Y.
NB: the cross shaped structuring element has a fixed radius equal to 1 pixel in both X and Y directions.
The GrayScaleMorphologicalOperation application has the following input parameters:
--in the input image to be filtered
--channel the selected channel index in the input image to be processed (default value is 1)
--structype the choice of the structuring element type (ball/cross) (default value is ball)
-(-structype.ball.xradius) the ball structuring element X Radius (only if structype==ball) (default
value is 5 pixels)
-(-structype.ball.yradius) the ball structuring element Y Radius (only if structype==ball) (default
value is 5 pixels)
--filter the choice of the morphological operation (dilate/erode/opening/closing) (default value is dilate)
--out the output filtered image
The application can be used like this:
Texture features can be extracted with the help of image filters based on texture analysis methods like Haralick and
structural feature set (SFS).
This application computes Haralick, advanced and higher order texture features on every pixel in the selected channel
of the input image. The output image is multi band with a feature per band.
The HaralickTextureExtraction application has the following input parameters:
--in the input image to compute the features on
--channel the selected channel index in the input image to be processed (default value is 1)
--texture the texture set selection [simple/advanced/higher] (default value is simple)
--parameters.min the input image minimum (default value is 0)
--parameters.max the input image maximum (default value is 255)
--parameters.xrad the X Radius of the processing neighborhood (default value is 2 pixels)
--parameters.yrad the Y Radius of the processing neighborhood (default value is 2 pixels)
--parameters.xoff the ∆X Offset for the co-occurrence computation (default value is 1 pixel)
--parameters.yoff the ∆Y Offset for the co-occurrence computation (default value is 1 pixel)
--parameters.nbbin the number of bin per axis for histogram generation (default value is 8)
--out the output multi band image containing the selected texture features (one feature per band)
The available values for -texture with their relevant features are:
--texture=simple: In this case, 8 local Haralick textures features will be processed. The 8 output image
channels are: Energy, Entropy, Correlation, Inverse Difference Moment, Inertia, Cluster Shade, Cluster Promi-
nence and Haralick Correlation. They are provided in this exact order in the output image. Thus, this application
computes the following Haralick textures over a neighborhood with user defined radius. To improve the speed of
computation, a variant of Grey Level Co-occurrence Matrix(GLCM) called Grey Level Co-occurrence Indexed
List (GLCIL) is used. Given below is the mathematical explanation on the computation of each textures. Here
𝑔(𝑖, 𝑗) is the frequency of element in the GLCIL whose index is i, j. GLCIL stores a pair of frequency of two
pixels taken from the given offset and the cell index (i, j) of the pixel in the neighborhood window. :(where each
element in GLCIL is a pair of pixel index and it’s frequency, 𝑔(𝑖, 𝑗) is the frequency value of the pair having
index is i, j).
“Energy” = 𝑓1 = 𝑖,𝑗 𝑔(𝑖, 𝑗)2
∑︀
∑︀
“Entropy” = 𝑓2 = − 𝑖,𝑗 𝑔(𝑖, 𝑗) log2 𝑔(𝑖, 𝑗), or 0 if 𝑔(𝑖, 𝑗) = 0
(𝑖,𝑗)𝑔(𝑖,𝑗)−𝜇2
∑︀
𝑡
“Haralick’s Correlation” = 𝑓8 = 𝑖,𝑗 𝜎2 where 𝜇𝑡 and 𝜎𝑡 are the mean and standard deviation of the
𝑡 ∑︀ ∑︀
row (or column, due to symmetry) sums. Above, 𝜇 = (weighted pixel average) = 𝑖,𝑗 𝑖·𝑔(𝑖, 𝑗) = 𝑖,𝑗 𝑗·𝑔(𝑖, 𝑗)
(due to matrix symmetry), and 𝜎 = (weighted pixel variance) = 𝑖,𝑗 (𝑖 − 𝜇)2 · 𝑔(𝑖, 𝑗) = 𝑖,𝑗 (𝑗 − 𝜇)2 · 𝑔(𝑖, 𝑗)
∑︀ ∑︀
(due to matrix symmetry).
--texture=advanced: In this case, 10 advanced texture features will be processed. The 10 output image
channels are: Mean, Variance, Dissimilarity, Sum Average, Sum Variance, Sum Entropy, Difference of En-
tropies, Difference of Variances, IC1 and IC2. They are provided in this exact order in the output image. The
textures are computed over a sliding window with user defined radius.
To improve the speed of computation, a variant of Grey Level Co-occurrence Matrix(GLCM) called Grey Level
Co-occurrence Indexed List (GLCIL) is used. Given below is the mathematical explanation on the computation
of each textures. Here 𝑔(𝑖, 𝑗) is the frequency of element in the GLCIL whose index is i, j. GLCIL stores a pair
of frequency of two pixels taken from the given offset and the cell index (i, j) of the pixel in the neighborhood
window. :(where each element in GLCIL is a pair of pixel index and it’s frequency, 𝑔(𝑖, 𝑗) is the frequency value
of the pair having index is i, j).
∑︀
“Mean” = 𝑖,𝑗 𝑖𝑔(𝑖, 𝑗)
“Sum of squares: Variance” = 𝑓4 = 𝑖,𝑗 (𝑖 − 𝜇)2 𝑔(𝑖, 𝑗)
∑︀
∑︀ (︁∑︀ )︁2
“Grey-Level Nonuniformity” = 𝐺𝐿𝑁 = 𝑛1𝑟 𝑖 𝑗 𝑝(𝑖, 𝑗)
1
∑︀ ∑︀ 2
“Run Length Nonuniformity” = 𝑅𝐿𝑁 = 𝑛𝑟 𝑗( 𝑖 𝑝(𝑖, 𝑗))
𝑛𝑟
“Run Percentage” = 𝑅𝑃 = 𝑛𝑝
1
∑︀ 𝑝(𝑖,𝑗)
“Low Grey-Level Run Emphasis” = 𝐿𝐺𝑅𝐸 = 𝑛𝑟 𝑖,𝑗 𝑖2
1
𝑝(𝑖, 𝑗) * 𝑖2
∑︀
“High Grey-Level Run Emphasis” = 𝐻𝐺𝑅𝐸 = 𝑛𝑟 𝑖,𝑗
1
∑︀ 𝑝(𝑖,𝑗)
“Short Run Low Grey-Level Emphasis” = 𝑆𝑅𝐿𝐺𝐸 = 𝑛𝑟 𝑖,𝑗 𝑖2 𝑗 2
1
∑︀ 𝑝(𝑖,𝑗)*𝑖2
“Short Run High Grey-Level Emphasis” = 𝑆𝑅𝐻𝐺𝐸 = 𝑛𝑟 𝑖,𝑗 𝑗2
1
∑︀ 𝑝(𝑖,𝑗)*𝑗 2
“Long Run Low Grey-Level Emphasis” = 𝐿𝑅𝐿𝐺𝐸 = 𝑛𝑟 𝑖,𝑗 𝑖2
1
𝑝(𝑖, 𝑗)𝑖2 𝑗 2
∑︀
“Long Run High Grey-Level Emphasis” = 𝐿𝑅𝐻𝐺𝐸 = 𝑛𝑟 𝑖,𝑗
-parameters.max 255
-out OutputImage
This application computes Structural Feature Set textures on every pixel in the selected channel of the input image.
The output image is multi band with a feature per band. The 6 output texture features are SFS’Length, SFS’Width,
SFS’PSI, SFS’W-Mean, SFS’Ratio and SFS’SD. They are provided in this exact order in the output image.
It is based on line direction estimation and described in the following publication. Please refer to Xin Huang, Liangpei
Zhang and Pingxiang Li publication, Classification and Extraction of Spatial Features in Urban Areas Using High-
Resolution Multispectral Imagery. IEEE Geoscience and Remote Sensing Letters, vol. 4, n. 2, 2007, pp 260-264.
The texture is computed for each pixel using its neighborhood. User can set the spatial threshold that is the max line
length, the spectral threshold that is the max difference authorized between a pixel of the line and the center pixel
of the current neighborhood. The adjustement constant alpha and the ratio Maximum Consideration Number, which
describes the shape contour around the central pixel, are used to compute the 𝑤 − 𝑚𝑒𝑎𝑛 value.
The SFSTextureExtraction application has the following input parameters:
--in the input image to compute the features on
--channel the selected channel index in the input image to be processed (default value is 1)
--parameters.spethre the spectral threshold (default value is 50)
--parameters.spathre the spatial threshold (default value is 100 pixels)
--parameters.nbdir the number of directions (default value is 20)
--parameters.alpha the alpha value (default value is 1)
--parameters.maxcons the ratio Maximum Consideration Number (default value is 5)
--out the output multi band image containing the selected texture features (one feature per band)
The application can be used like this:
This section describes how to convert pair of stereo images into elevation information.
The standard problem of terrain reconstruction with available OTB Applications contains the following steps:
• Estimation of displacements grids for epipolar geometry transformation
• Epipolar resampling of the image pair using those grids
• Dense disparity map estimation
• Projection of the disparities on a Digital Surface Model (DSM)
Let’s go to the third dimension!
The aim of this step is to generate resampled grids to transform images into epipolar geometry. Epipolar geometry is
the geometry of stereo vision. The operation of stereo rectification determines transformations to apply to each image
such that pairs of conjugate epipolar lines become collinear, parallel to one of the image axes and aligned. In this
geometry, the objects present on a given row of the left image are also located on the same row in the right image.
Applying this transformation reduces the problem of elevation (or stereo correspondences determination) to a 1-D
problem. We have two sensor images 𝑖𝑚𝑎𝑔𝑒1 and 𝑖𝑚𝑎𝑔𝑒2 over the same area (the stereo pair) and we assume that we
know the localization functions (forward and inverse) associated with each images.
The forward function allows to go from the image referential to the geographic referential. For the first image, this
function will be noted:
where ℎ is the elevation hypothesis, (𝑖, 𝑗) are the pixel coordinates in image 1 and (𝑙𝑜𝑛𝑔, 𝑙𝑎𝑡) are geographic coordi-
nates. As you can imagine, the inverse function allows to go from geographic coordinates to the image geometry.
For the second image, in that case, the expression of the inverse function is:
Using jointly the forward and inverse functions from the image pair, we can construct a co-localization function 𝑔1→2
between the position of a pixel in the first and its position in the second one:
The expression is not really important, what you need to understand is that if we are able to determine for a given pixel
in image 1 the corresponding pixel in image 2, as we know the expression of the co-localization function between both
images, we can determine by identification the information about the elevation (variable h in the equation)!
We now have the mathematical basis to understand how 3-D information can be extracted by examination of the
relative positions of objects in the two 2-D epipolar images.
The construction of the two epipolar grids is a little bit more complicated in the case of VHR optical images. That is
because most of passive remote sensing from space use a push-broom sensor, which corresponds to a line of sensors
arranged perpendicularly to the flight direction of the spacecraft. This acquisition configuration implies a slightly
different strategy for stereo-rectification (see here ).
We will now explain how to use the StereoRectificationGridGenerator application to produce two images which are
deformation grids to resample the two images in epipolar geometry.
otbcli_StereoRectificationGridGenerator -io.inleft image1.tif
-io.inright image2.tif
-epi.elevation.default 50
-epi.step 10
-io.outleft grid_image1.tif
-io.outright grid_image2.tif
The application estimates the displacement to apply to each pixel in both input images to obtain epipolar geometry. The
application accepts a ‘step’ parameter to estimate displacements on a coarser grid. Here we estimate the displacements
every 10 pixels. This is because in most cases with a pair of VHR and a small angle between the two images, this grid
is very smooth. Moreover, the implementation is not streamable and uses potentially a lot of memory. Therefore it is
generally a good idea to estimate the displacement grid at a coarser resolution.
The application outputs the size of the output images in epipolar geometry. Note these values, we will use them in the
next step to resample the two images in epipolar geometry.
In our case, we have:
The epi.baseline parameter provides the mean value (in pixels per meters) of the baseline to sensor altitude ratio (also
called B/H in the litterature). It can be used to do an approximate conversion of disparities to physical elevation :
𝑑
ℎ = ℎ𝑅𝐸𝐹 +
𝐵/𝐻
where ℎ𝑅𝐸𝐹 is the reference altitude used to generate the epipolar grids (here: 50m), and 𝑑 is a disparity value (in
pixels) for a given object between images 1 and 2.
We can now move forward to the resampling in epipolar geometry.
The former application generates two grids of displacements. The GridBasedImageResampling allows to resample the
two input images in the epipolar geometry using these grids. These grids are intermediary results not really useful on
their own in most cases. This second step only consists in applying the transformation to resample both images. This
application can obviously be used in a lot of other contexts.
The two commands to generate epipolar images are:
As you can see, we set sizex and sizey parameters using output values given by the StereoRectificationGridGenerator
application to set the size of the output epipolar images. The two epipolar images should have the same size.
Figure 1: Extract of resample image1 and image2 in epipolar geometry over Pyramids of Cheops. ©CNES 2012
We obtain two images in epipolar geometry, as shown in Figure 1. Note that the application allows to resample only a
part of the image using the -out.ulx and -out.uly parameters.
The resampling of our images in epipolar geometry allows us to constrain the search along a 1-dimensional line as
opposed to both dimensions, but what is even more important is that the disparities along the lines, i.e. the offset along
the lines measured by the block-matching process can be directly linked to the local elevation
An almost complete spectrum of stereo correspondence algorithms has been published and it is still augmented at a
significant rate! The Orfeo ToolBox implements different local strategies for block matching:
• Sum of Square Distances block-matching (SSD)
• Normalized Cross-Correlation (NCC)
• Lp pseudo-norm (LP)
An other important parameter (mandatory in the application!) is the range of disparities. In theory, the block matching
can perform a blind exploration and search for a infinite range of disparities between the stereo pair. We need now to
evaluate a range of disparities where the block matching will be performed (in the general case from the deepest point
on Earth, the Challenger Deep . to the Everest summit!)
We deliberately exaggerated but you can imagine that without a smaller range the block matching algorithm can take a
lot of time. That is why these parameters are mandatory for the application and as a consequence we need to estimate
them manually. This is pretty simple using the two epipolar images.
In our case, we choose one point on a flat area. Its coordinates are [1525, 1970] in epipolar image 1 and [1526, 1970] in
epipolar image 2. We then select a second point on a higher region (in our case a point near the top of the Pyramid of
Cheops!). The image coordinates of this pixel are [1661, 1299] in image 1 and [1633, 1300] in image 2. We check the
difference between column coordinates in images 1 and 2 in order to derive the useful disparity interval for horizontal
exploration. In our case, this interval is at least [−28, 1] (the convention for the sign of the disparity range is from
image 1 to image 2).
Note that this exploration interval can be reduced using an external DEM in the StereoRectificationGridGenerator
application. Indeed, the disparities measured between the epipolar images are relative to the reference altitude used
when computing epipolar grids (hence, defining the epipolar geometry). Using an external DEM should produce
epipolar images where altitude deviations from the reference are smaller, and as a consequence, disparities closer to 0.
Regarding the vertical disparity, in the first step we said that we reduced the problem of 2D exploration to a 1D
problem, but this is not completely true in general cases. There might be small disparities in the vertical direction
which are due to parallax errors (i.e. epipolar lines exhibit a small shift in the vertical direction, around 1 pixel).
In fact, the exploration is typically smaller along the vertical direction than along the horizontal one. You can also
estimate them on the epipolar pair (in our case we use a range of −1 to 1).
One more time, take care of the sign for minimum and maximum disparities (always from image1 to image2).
The command line for the BlockMatching application is:
The application creates by default a two bands image: the horizontal and vertical disparities.
The BlockMatching application gives access to a lot of other powerful functionalities to improve the quality of the
output disparity map.
Here are a few of these functionalities:
• io.outmetric: if the optimal metric values image is activated, it will be concatenated to the output image (which
will then have three bands: horizontal disparity, vertical disparity and metric value)
• bm.subpixel: Perform sub-pixel estimation of disparities
• mask.inleft and mask.inright: you can specify a no-data value which will discard pixels with this value (for
example the epipolar geometry can generate large part of images with black pixels). This mask can be easily
generated using the BandMath application:
• mask.variancet: The block matching algorithm has difficulties to find matches on uniform areas. We can use
the variance threshold to discard those regions and speed-up computation time.
• bm.medianfilter.radius and bm.medianfilter.incoherence: Applies a median filter to the disparity map. The
median filter belongs to the family of nonlinear filters. It is used to smooth an image without being biased by
outliers or shot noise. The radius corresponds to the neighbourhood where the median value is computed. A
detection of incoherence between the input disparity map and the median-filtered one is performed (cases where
the absolute difference is greater than the threshold, whose default value is 1). Both parameters must be defined
in the application to activate the filter.
Of course all these parameters can be combined to improve the disparity map.
Figure 2: Horizontal disparity and optimal metric map
Using the previous application, we evaluated disparities between epipolar images. The next (and last!) step is now to
transform the disparity map into an elevation information to produce an elevation map. It uses as input the disparity
maps (horizontal and vertical) to produce a Digital Surface Model (DSM) with a regular sampling. The elevation
values are computed from the triangulation of the “left-right” lines of sight for each matched pixels. When several
elevations are available on a DSM cell, the highest one is kept.
First, an important point is that it is often a good idea to rework the disparity map given by the BlockMatching
application to only keep relevant disparities. For this purpose, we can use the output optimal metric image and filter
disparities with respect to this value.
For example, if we used Normalized Cross-Correlation (NCC), we can keep only disparities where optimal metric
value is superior to 0.9. Disparities below this value can be considered as inaccurate and will not be used to compute
elevation information (the -io.mask parameter can be used for this purpose).
This filtering can be easily done with OTB Applications .
We first use the BandMath application to filter disparities according to their optimal metric value:
Now, we can use the DisparityMapToElevationMap application to compute the elevation map from the filtered dispar-
ity maps.
It produces the elevation map projected in WGS84 (EPSG code:4326) over the ground area covered by the stereo pair.
Pixels values are expressed in meters.
An application has been created to fuse one or multiple stereo reconstruction(s) using all-in-one approach: Stere-
oFramework . It computes the DSM from one or several stereo pairs. First of all the user has to choose his input data
and defines stereo couples using -input.co string parameter. Each couple is defined by 2 image indexes “a b” (starting
at 0) separated by a space character. The different pairs are concatenated with coma. For instance “0 1,0 2” will
define the image pairs “first with second”, and “first with third”. If left blank, images are processed by pairs (which is
equivalent as using “ 0 1,2 3,4 5 ” . . . ). In addition to the usual elevation and projection parameters, main parameters
have been split in groups detailed below:
• output: Output parameters (DSM resolution, NoData value, Cell Fusion method)
– Output projection map selection.
The parameters for altitude offset are used inside the application to derive the minimum and maximum horizontal
disparity exploration, so they have a critical impact on computation time. It is advised to choose an elevation source
that is not too far from the DSM you want to produce (for instance, an SRTM elevation model). Therefore, the altitude
from your elevation source will be already taken into account in the epipolar geometry and the disparities will reveal
the elevation offsets (such as buildings). It allows you to use a smaller exploration range along the elevation axis,
causing a smaller exploration along horizontal disparities and faster computation.
To reduce time consumption it would be useful to crop all sensor images to the same extent. The easiest way to do
that is to choose an image as reference, and then apply ExtractROI application on the other sensor images using the fit
mode option.
Algorithm outline
The following algorithms are used in the application: For each sensor pair
• Compute the epipolar deformation grids from the stereo pair (direct and inverse)
Basics
# The smoothing algorithm can be set with the "type" parameter key
# and can take 3 values: 'mean', 'gaussian', 'anidif'
for type in ['mean', 'gaussian', 'anidif']:
# Set the output filename, using the algorithm type to differentiate the outputs
app.SetParameterString("out", argv[2] + type + ".tif")
# This will execute the application and save the output to argv[2]
app.ExecuteAndWriteOutput()
If you want to handle the parameters from a Python dictionary, you can use the functions SetParameters() and GetPa-
rameters().
Input and output images to any OTB application in the form of NumPy array is now possible in OTB Python wrap-
ping. The Python wrapping only exposes OTB Application engine module (called ApplicationEngine) which allows
to access existing C++ applications. Due to blissful nature of ApplicationEngine’s loading mechanism no specific
wrapping is required for each application.
NumPy extension to Python wrapping allows data exchange to application as an array rather than a disk file. Of course,
it is possible to load an image from file and then convert it to NumPy array or just provide a file as explained in the
previous section via Application.SetParameterString(...).
The bridge between NumPy and OTB makes it easy to plug OTB into any image processing chain via Python code
that uses GIS/Image processing tools such as GDAL, GRASS GIS, OSSIM that can deal with NumPy.
Below code reads an input image using Python Pillow library (fork of PIL) and convert it to NumPy array. The
NumPy array is used as an input to the application via SetImageFromNumpyArray(...) method. The application
used in this example is ExtractROI. After extracting a small area the output image is taken as NumPy array with
GetImageFromNumpyArray(...) method thus avoid writing output to a temporary file.
import sys
import os
import numpy as np
import otbApplication
from PIL import Image as PILImage
pilimage = PILImage.open('poupees.jpg')
npimage = np.asarray(pilimage)
inshow(pilimage)
ExtractROI = otbApplication.Registry.CreateApplication('ExtractROI')
ExtractROI.SetImageFromNumpyArray('in', npimage)
ExtractROI.SetParameterInt('startx', 140)
ExtractROI.SetParameterInt('starty', 120)
ExtractROI.SetParameterInt('sizex', 150)
ExtractROI.SetParameterInt('sizey', 150)
ExtractROI.Execute()
ExtractOutput = ExtractROI.GetImageAsNumpyArray('out')
output_pil_image = PILImage.fromarray(np.uint8(ExtractOutput))
imshow(output_pil_image)
In-memory connection
Applications are often use as parts of larger processing workflow. Chaining applications currently requires to
write/read back images between applications, resulting in heavy I/O operations and a significant amount of time
dedicated to writing temporary files.
Since OTB 5.8, it is possible to connect an output image parameter from one application to the input image parameter
of the next parameter. This results in the wiring of the internal ITK/OTB pipelines together, allowing to perform image
streaming between the applications. There is therefore no more writing of temporary images. The last application of
the processing chain is responsible for writing the final result images.
In-memory connection between applications is available both at the C++ API level and using the Python bindings.
Here is a Python code sample which connects several applications together:
app1 = otb.Registry.CreateApplication("Smoothing")
app2 = otb.Registry.CreateApplication("Smoothing")
app3 = otb.Registry.CreateApplication("Smoothing")
app4 = otb.Registry.CreateApplication("ConcatenateImages")
app1.IN = argv[1]
app1.Execute()
app3.IN = argv[1]
app4.OUT = argv[2]
Note: Streaming will only work properly if the application internal implementation does not break it, for instance by
using an internal writer to write intermediate data. In this case, execution should still be correct, but some intermediate
data will be read or written.
Q: What portion of the image is exported to Numpy array? A: By default, the whole image is exported.
If you had a non-empty requested region (the result of calling PropagateRequestedRegion()), then this
region is exported.
Q: What is the difference between ImportImage and ImportVectorImage? A: The first one is here for
Applications that expect a monoband otb::Image. In most cases, you will use the second one: ImportVec-
torImage.
Q: What kind of object are there in this dictionary export? A: The array is a numpy.ndarray. The other
fields are wrapped objects from the OTB library but you can interact with them in a Python way: they
support len() and str() operator, as well as bracket operator []. Some of them also have a keys()
function just like dictionaries.
This interface allows you to export OTB images (or extracts) to Numpy array, process them by other means, and
re-import them with preserved metadatas. Please note that this is different from an in-memory connection.
Here is a small example of what can be done:
# only call Execute() to setup the pipeline, not ExecuteAndWriteOutput() which would
# run it and write the output image
app.Execute()
# Only a portion of "out" was exported but ReadImageInfo is still able to detect the
# correct full size of the image
Corner cases
There are a few corner cases to be aware of when using Python wrappers. They are often limitations, that one day may
be solved in future versions. If it happens, this documentation will report the OTB version that fixes the issue.
Calling UpdateParameters()
These wrappers are made as a mirror of the C++ API, so there is a function UpdateParameters(). Its role is to
update parameters that depend on others. It is called at least once at the beginning of Execute().
In command line and GUI launchers, this functions gets called each time a parameter of the application is modified.
In Python, this mechanism is not automated: there are cases where you may have to call it yourself.
Let’s take an example with the application PolygonClassStatictics. In this application, the choices available
in the parameter field depend on the list of fields actually present in the vector file vec. If you try to set the
parameters vec and field, you will get an error:
import otbApplication as otb
app = otb.Registry.CreateApplication("PolygonClassStatistics")
app.SetParameterString("vec","../../src/OTB-Data/Input/Classification/variousVectors.
˓→sqlite")
app.SetParameterString("field", "label")
˓→otbWrapperListViewParameter.cxx:141:
The error says that the choice label is not recognized, because UpdateParameters() was not called after setting
the vector file. The solution is to call it before setting the field parameter:
app.UpdateParameters()
app.SetParameterString("field", "label")
With the NumPy module, it is possible to convert images between OTB and NumPy arrays. For instance, when
converting from OTB to NumPy array:
• An Update() of the underlying otb::VectorImage is requested. Be aware that the full image is gener-
ated.
• The pixel buffer is copied into a numpy.array
As you can see, there is no export of the metadata, such as origin, spacing, geographic projection. It means that if you
want to import back a NumPy array into OTB, the image won’t have any of these metadata. It can be a problem for
applications doing geometry, projections, and also calibration.
Future developments will probably offer a more adapted structure to import and export images between OTB and the
Python world.
Setting of EmptyParameter
Most of the parameters are set using functions SetParameterXXX(), except for one type of parameter: the
EmptyParameter. This class was the first implementation of a boolean. It is now deprecated, you should use
BoolParameter instead.
Let’s take an example with the application ReadImageInfo when it was still using an EmptyParameter for
parameter keywordlist:
If you want the get the state of parameter keywordlist, a boolean, use:
app.IsParameterEnabled("keywordlist")
app.EnableParameter("keywordlist")
app.DisableParameter("keywordlist")
Don’t try to use other functions to set the state of a boolean. For instance, try the following commands:
app.SetParameterInt("keywordlist", 0)
app.IsParameterEnabled("keywordlist")
You will get a state True even if you asked the opposite.
SEVEN
Miscellaneous
Outputs a monoband image which is the result of a mathematical operation on several multi-band images.
Detailed description
This application performs a mathematical operation on several multi-band images and outputs the result into a
monoband image. The given expression is computed at each pixel position. Evaluation of the mathematical formula
is done by the muParser libraries.
The formula can be written using:
• numerical values ( 2.3, -5, 3.1e4, ...)
• variables containing pixel values (e.g. : ‘im2b3’ is the pixel value in 2nd image, 3rd band)
• binary operators:
– ‘+’ addition, ‘-‘ subtraction, ‘*’ multiplication, ‘/’ division
– ‘^’ raise x to the power of y
– ‘<’ less than, ‘>’ greater than, ‘<=’ less or equal, ‘>=’ greater or equal
– ‘==’ equal, ‘!=’ not equal
– ‘||’ logical or, ‘&&’ logical and
• if-then-else operator: ‘(condition ? value_true : value_false)’
• functions : exp(), log(), sin(), cos(), min(), max(), ...
The full list of features and operators is available on the muParser website [1].
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
BandMath .
1 Table: Parameters table for Band Math.
129
OTB CookBook Documentation, Release 6.6.0
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
BandMath.SetParameterString("out", "apTvUtBandMathOutput.tif")
Limitations
None
Authors
See Also
Detailed description
This application performs a mathematical operation on several multi-band images and outputs the result into an image
(multi- or mono-band, as opposed to the BandMath OTB-application). The mathematical formula is done by the
muParserX libraries.
The list of features and the syntax of muParserX is available at [1].
As opposed to muParser (and thus the BandMath OTB-application [2]), muParserX supports vector expressions which
allows outputting multi-band images.
Hereafter is a brief reference of the muParserX syntax
Fundamentals
Another new feature is the possibility to perform operations that involve neighborhoods of pixels. Variables related to
such neighborhoods are always defined following the imIbJNKxP pattern, where:
• I is an number identifying the image input (remember, input #0 = im1, and so on)
• J is an number identifying the band (remember, first band is indexed by1)
• KxP are two numbers that represent the size of the neighborhood (first one is related to the horizontal direction)
NB: All neighborhood are centered, thus K and P must be odd numbers.
Many operators come with this new functionality:
• dotpr
• mean
• var
• median
• min
• max
• etc.
For instance, if im1 represents the pixel of 3 bands image:
could represent a high pass filter (note that by implying three neighborhoods, the operator mean returns a row vector
of three components. It is a typical behaviour for many operators of this application).
In addition to the previous operators, other operators are available:
• existing operators/functions from muParserX, that were not originally defined for vectors and matrices (e.g. cos,
sin). These new operators/functions keep the original names to which we added the prefix ‘v’ for vector (vcos,
vsin, etc.)
• mult, div and pow operators, that perform element-wise multiplication, division or exponentiation of vec-
tor/matrices (e.g. im1 div im2).
• mlt, dv and pw operators, that perform multiplication, division or exponentiation of vector/matrices by a scalar
(e.g. im1 dv 2.0).
• bands, which is a very useful operator. It allows selecting specific bands from an image, and/or to rearrange
them in a new vector (e.g.bands( im1, { 1, 2, 1, 1 } ) produces a vector of 4 components made of band 1, band
2, band 1 and band 1 values from the first input.
Note that curly brackets must be used in order to select the desired bandindices.
The application can use an expression supplied with the ‘exp’ parameter. It can also use an input context file, that
defines variables and expressions. An example of context file is given below:
#F expo 1.1
#M kernel1 { 0.1 , 0.2 , 0.3; 0.4 , 0.5 , 0.6; 0.7 , 0.8 , 0.9; 1 , 1.1, 1.2; 1.3 , 1.
˓→4 , 1.5 }
As we can see, #I/#F allows the definition of an integer/float constant, whereas #M allows the definition of a vec-
tor/matrix. In the latter case, elements of a row must be separated by commas, and rows must be separated by
semicolons. It is also possible to define expressions within the same txt file, with #E <expr> (see limitations, below).
Finally, we strongly recommend to read the OTB Cookbook which can be found at: http://www.orfeo-toolbox.org/
packages/OTBCookBook.pdf
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
BandMathX .
Parameter Key Parameter Name Parameter Type
il Input image-list Input image list
out Output Image Output image
ram Available RAM (Mb) Int
exp Expressions String
incontext Import context Input File name
outcontext Export context Output File name
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input image-list: Image-list to perform computation on.
• Output Image: Output image.
• Available RAM (Mb): Available memory for processing (in MB).
• Expressions: Mathematical expression to apply.
1 Table: Parameters table for Band Math X.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
BandMathX.SetParameterString("out", "apTvUtBandMathOutput.tif")
Limitations
The application is currently unable to produce one output image per expression, contrary to otbBandMathXImage-
Filter.
Separating expressions by semi-colons ‘;’ will concatenate their results into a unique multiband output image.
Authors
See Also
Detailed description
This application computes MSE (Mean Squared Error), MAE (Mean Absolute Error) and PSNR (Peak Signal to Noise
Ratio) between the channel of two images (reference and measurement). The user has to set the used channel and can
specify a ROI.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
CompareImages .
Parameter Key Parameter Name Parameter Type
ref Reference image properties Group
ref.in Reference image Input image
ref.channel Reference image channel Int
meas Measured image properties Group
meas.in Measured image Input image
meas.channel Measured image channel Int
roi Region Of Interest (relative to reference image) Group
roi.startx Start X Int
roi.starty Start Y Int
roi.sizex Size X Int
roi.sizey Size Y Int
mse MSE Float
mae MAE Float
psnr PSNR Float
count count Float
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
[Reference image properties]
• Reference image: Image used as reference in the comparison.
• Reference image channel: Used channel for the reference image.
[Measured image properties]
• Measured image: Image used as measured in the comparison.
• Measured image channel: Used channel for the measured image.
[Region Of Interest (relative to reference image)]
• Start X: ROI start x position.
• Start Y: ROI start y position.
• Size X: Size along x in pixels.
1 Table: Parameters table for Images comparison.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
CompareImages.SetParameterInt("ref.channel", 1)
CompareImages.SetParameterString("meas.in", "GomaAvant.png")
CompareImages.SetParameterInt("meas.channel", 2)
CompareImages.SetParameterInt("roi.startx", 20)
CompareImages.SetParameterInt("roi.starty", 30)
CompareImages.SetParameterInt("roi.sizex", 150)
CompareImages.SetParameterInt("roi.sizey", 200)
Limitations
None
Authors
See Also
Detailed description
The application applies a linear unmixing algorithmto an hyperspectral data cube. This method supposes that the
mixture betweenaterials in the scene is macroscopic and simulates a linear mixing model ofspectra.
The Linear Mixing Model (LMM) acknowledges that reflectancespectrum associated with each pixel is a linear com-
bination of purematerials in the recovery area, commonly known as endmembers. Endmembers canbe estimated using
the VertexComponentAnalysis application.
The application allows estimating the abundance maps with several algorithms :
• Unconstrained Least Square (ucls)
• Image Space Reconstruction Algorithm (isra)
• Non-negative constrained
• Least Square (ncls)
• Minimum Dispersion Constrained Non Negative Matrix Factorization (MDMDNMF).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
HyperspectralUnmixing .
Parameter Key Parameter Name Parameter Type
in Input Image Filename Input image
out Output Image Output image
ie Input endmembers Input image
ua Unmixing algorithm Choices
ua ucls UCLS Choice
ua ncls NCLS Choice
ua isra ISRA Choice
ua mdmdnmf MDMDNMF Choice
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image Filename: The hyperspectral data cube input.
1 Table: Parameters table for Hyperspectral data unmixing.
• Output Image: The output abundance map. The abundance fraction are stored in a multispectral image where
band N corresponds to the fraction of endmembers N in each pixel.
• Input endmembers: The endmembers (estimated pure pixels) to use for unmixing. Must be stored as a multi-
spectral image, where each pixel is interpreted as an endmember.
• Unmixing algorithm: The algorithm to use for unmixing. Available choices are:
• UCLS: Unconstrained Least Square.
• NCLS: Non-negative constrained Least Square.
• ISRA: Image Space Reconstruction Algorithm.
• MDMDNMF: Minimum Dispersion Constrained Non Negative Matrix Factorization.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
HyperspectralUnmixing.SetParameterString("ie", "cupriteEndmembers.tif")
HyperspectralUnmixing.SetParameterString("out", "HyperspectralUnmixing.tif")
HyperspectralUnmixing.SetParameterOutputImagePixelType("out", 7)
HyperspectralUnmixing.SetParameterString("ua","ucls")
Limitations
None
Authors
See Also
Detailed description
This application exports the input image in a kmz product that can be display in the Google Earth software. The user
can set the size of the product size, a logo and a legend to the product. Furthemore, to obtain a product that fits the
relief, a DEM can be used.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
KmzExport .
Parameter Key Parameter Name Parameter Type
in Input image Input image
out Output .kmz product Output File name
tilesize Tile Size Int
logo Image logo Input image
legend Image legend Input image
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input image: Input image.
Output .kmz product: Output Kmz product directory (with .kmz extension).
Tile Size: Size of the tiles in the kmz product, in number of pixels (default = 512).
Image logo: Path to the image logo to add to the KMZ product.
Image legend: Path to the image legend to add to the KMZ product.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
1 Table: Parameters table for Image to KMZ Export.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
KmzExport.SetParameterString("out", "otbKmzExport.kmz")
KmzExport.SetParameterString("logo", "otb_big.png")
Limitations
None
Authors
See Also
Conversion
Detailed description
The application connects to Open Street Map server, downloads the data corresponding to the spatial extent of the
support image, and filters the geometries based on OSM tags to produce a vector data file.
This application can be used to download reference data to perform the training of a machine learning model (see for
instance [1]).
By default, the entire layer is downloaded. The application has a special mode to provide the list of available classes
in the layers. The downloaded features are filtered by giving an OSM tag ‘key’. In addition, the user can also choose
what ‘value’ this key should have. More information about the OSM project at [2].
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
OSMDownloader .
Parameter Key Parameter Name Parameter Type
out Output vector data Output vector data
support Support image Input image
key OSM tag key String
value OSM tag value String
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
printclasses Displays available key/value classes Boolean
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Output vector data: Vector data file to store downloaded features.
Support image: Image used to derive the spatial extent to be requested from OSM server (the bounding box of the
extent is used). Be aware that a request with a large extent may be rejected by the server.
OSM tag key: OSM tag key to extract (highway, building...). It defines a category to select features.
OSM tag value: OSM tag value to extract (motorway, footway...). It defines the type of feature to select inside a
category.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
1 Table: Parameters table for Open Street Map layers import.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Displays available key/value classes: Print the key/value classes available for the selected support image. If enabled,
the OSM tag Key (-key) and the output (-out) become optional.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
OSMDownloader.SetParameterString("key", "highway")
OSMDownloader.SetParameterString("out", "apTvUtOSMDownloader.shp")
Limitations
Authors
See Also
[1] TrainImagesClassifier
[2] http://www.openstreetmap.fr/
Detailed description
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ObtainUTMZoneFromGeoPoint .
Parameter Key Parameter Name Parameter Type
lat Latitude Float
lon Longitude Float
utm UTMZone Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Latitude: Latitude value of desired point.
• Longitude: Longitude value of desired point.
• UTMZone: UTM Zone.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
Obtain a UTM ZoneTo run this example in command-line, use the following:
otbcli_ObtainUTMZoneFromGeoPoint -lat 10.0 -lon 124.0
To run this example from Python, use the following code snippet:
#!/usr/bin/python
1 Table: Parameters table for Obtain UTM Zone From Geo Point.
ObtainUTMZoneFromGeoPoint.SetParameterFloat("lon", 124.0)
Limitations
None
Authors
Detailed description
This application gives the value of a selected pixel. There are three ways to designate a pixel, with its index, its physical
coordinate (in the physical space attached to the image), and with geographical coordinate system. Coordinates will
be interpreted differently depending on which mode is chosen.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
PixelValue .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
coordx X coordinate Float
coordy Y coordinate Float
mode Coordinate system used to designate the pixel Choices
mode index Index Choice
mode physical Image physical space Choice
mode epsg EPSG coordinates Choice
mode.epsg.code EPSG code Int
cl Channels List
value Pixel Value String
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image.
X coordinate: This will be the X coordinate interpreted depending on the chosen mode.
Y coordinate: This will be the Y coordinate interpreted depending on the chosen mode.
1 Table: Parameters table for Pixel Value.
Coordinate system used to designate the pixel: Different modes can be selected, default mode is Index. Available
choices are:
• Index: This mode uses the given coordinates as index to locate the pixel.
• Image physical space: This mode interprets the given coordinates in the image physical space.
• EPSG coordinates: This mode interprets the given coordinates in the specified geographical coordinate system
by the EPSG code.
• EPSG code: This code is used to define a geographical coordinate system. If no system is specified, WGS84
(EPSG : 4326) is used by default.
Channels: Displayed channels.
Pixel Value: Pixel radiometric value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
PixelValue.SetParameterFloat("coordx", 50)
PixelValue.SetParameterFloat("coordy", 100)
Limitations
None
Authors
Given a set of mixed spectral vectors, estimatereference substances also known as endmembers using the VertexCom-
ponent Analysis algorithm.
Detailed description
Apply the Vertex Component Analysis [1] toan hyperspectral image to extract endmembers. Given a set of mixed-
spectral vectors (multispectral or hyperspectral), the applicationestimates the spectral signature of reference substances
also knownas endmembers.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VertexComponentAnalysis .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
ne Number of endmembers Int
outendm Output Endmembers Output image
rand set user defined seed Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: Input hyperspectral data cube.
• Number of endmembers: The number of endmembers to extract from the hyperspectral image.
• Output Endmembers: Endmembers, stored in aone-line multi-spectral image.Each pixel corresponds to
oneendmembers and each band values corresponds to the spectralsignature of the corresponding endmember.
• set user defined seed: Set specific seed. with integer value.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VertexComponentAnalysis.SetParameterInt("ne", 5)
VertexComponentAnalysis.SetParameterString("outendm", "VertexComponentAnalysis.tif")
VertexComponentAnalysis.SetParameterOutputImagePixelType("outendm", 7)
Limitations
None
Authors
See Also
Feature Extraction
Detailed description
This application performs binary morphological operations on a mono band image or a channel of the input.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
BinaryMorphologicalOperation .
1 Table: Parameters table for Binary Morphological Operation.
• Closing
• Foreground value: Set the foreground value, default is 1.0.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
BinaryMorphologicalOperation = otbApplication.Registry.CreateApplication(
˓→"BinaryMorphologicalOperation")
BinaryMorphologicalOperation.SetParameterString("out", "opened.tif")
BinaryMorphologicalOperation.SetParameterInt("channel", 1)
BinaryMorphologicalOperation.SetParameterInt("structype.ball.xradius", 5)
BinaryMorphologicalOperation.SetParameterInt("structype.ball.yradius", 5)
BinaryMorphologicalOperation.SetParameterString("filter","erode")
Limitations
None
Authors
See Also
This application compute for each studied polyline, contained in the input VectorData, the chosen descriptors.
Detailed description
The first step in the classifier fusion based validation is to compute, for each studied polyline, the chosen descriptors.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ComputePolylineFeatureFromImage .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
vd Vector Data Input vector data
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
expr Feature expression String
field Feature name String
out Output Vector Data Output vector data
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: An image to compute the descriptors on.
Vector Data: Vector data containing the polylines where the features will be computed.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Feature expression: The feature formula (b1 < 0.3) where b1 is the standard name of input image first band.
Feature name: The field name corresponding to the feature codename (NONDVI, ROADSA...).
Output Vector Data: The output vector data containing polylines with a new field.
1 Table: Parameters table for Compute Polyline Feature From Image.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ComputePolylineFeatureFromImage = otbApplication.Registry.CreateApplication(
˓→"ComputePolylineFeatureFromImage")
ComputePolylineFeatureFromImage.SetParameterString("vd", "roads_ground_truth.shp")
ComputePolylineFeatureFromImage.SetParameterString("field", "NONDVI")
ComputePolylineFeatureFromImage.SetParameterString("out", "PolylineFeatureFromImage_
˓→LI_NONDVI_gt.shp")
Limitations
Since it does not rely on streaming process, take care of the size of input image before launching application.
Authors
Estimate feature fuzzy model parameters using 2 vector data (ground truth samples and wrong samples).
Detailed description
Estimate feature fuzzy model parameters using 2 vector data (ground truth samples and wrong samples).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DSFuzzyModelEstimation .
Parameter Key Parameter Name Parameter Type
psin Input Positive Vector Data Input vector data
nsin Input Negative Vector Data Input vector data
belsup Belief Support String list
plasup Plausibility Support String list
cri Criterion String
wgt Weighting Float
initmod initialization model Input File name
desclist Descriptor list String list
maxnbit Maximum number of iterations Int
optobs Optimizer Observer Boolean
out Output filename Output File name
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Positive Vector Data: Ground truth vector data for positive samples.
• Input Negative Vector Data: Ground truth vector data for negative samples.
• Belief Support: Dempster Shafer study hypothesis to compute belief.
• Plausibility Support: Dempster Shafer study hypothesis to compute plausibility.
• Criterion: Dempster Shafer criterion (by default (belief+plausibility)/2).
• Weighting: Coefficient between 0 and 1 to promote undetection or false detections (default 0.5).
• initialization model: Initialization model (xml file) to be used. If the xml initialization model is set, the de-
scriptor list is not used (specified using the option -desclist).
• Descriptor list: List of the descriptors to be used in the model (must be specified to perform an automatic
initialization).
• Maximum number of iterations: Maximum number of optimizer iteration (default 200).
• Optimizer Observer: Activate the optimizer observer.
• Output filename: Output model file name (xml file) contains the optimal model to perform information fusion.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DSFuzzyModelEstimation.SetParameterString("nsin",
˓→"cdbTvComputePolylineFeatureFromImage_LI_NOBUIL_wr.shp")
DSFuzzyModelEstimation.SetParameterStringList("belsup", ['"ROADSA"'])
DSFuzzyModelEstimation.SetParameterString("initmod", "Dempster-Shafer/DSFuzzyModel_
˓→Init.xml")
DSFuzzyModelEstimation.SetParameterInt("maxnbit", 4)
DSFuzzyModelEstimation.SetParameterString("optobs","true")
DSFuzzyModelEstimation.SetParameterString("out", "DSFuzzyModelEstimation.xml")
Limitations
None.
Authors
This application computes edge features on every pixel of the input image selected channel
Detailed description
This application computes edge features on a selected channel of the input.It uses different filter such as gradient,
Sobel and Touzi
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
EdgeExtraction .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
channel Selected Channel Int
ram Available RAM (Mb) Int
filter Edge feature Choices
filter gradient Gradient Choice
filter sobel Sobel Choice
filter touzi Touzi Choice
filter.touzi.xradius The X radius of the neighborhood. Int
filter.touzi.yradius The Y radius of the neighborhood. Int
out Feature Output Image Output image
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: The input image on which the features are computed.
Selected Channel: The selected channel index.
Available RAM (Mb): Available memory for processing (in MB).
Edge feature: Choice of edge feature. Available choices are:
• Gradient: This filter computes the gradient magnitude of the image at each pixel.
• Sobel: This filter uses the Sobel operator to calculate the image gradient and then finds the magnitude of this
gradient vector.
• Touzi: This filter is more suited for radar images. It has a spatial parameter to avoid speckle noise perturbations.
The larger the radius is, less sensible to the speckle noise the filter is, but micro edge will be missed.
• The X radius of the neighborhood.
• The Y radius of the neighborhood.
Feature Output Image: Output image containing the edge features.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
EdgeExtraction.SetParameterInt("channel", 1)
EdgeExtraction.SetParameterString("out", "Edges.tif")
Limitations
None
Authors
See Also
Detailed description
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
GrayScaleMorphologicalOperation .
1 Table: Parameters table for Grayscale Morphological Operation.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
GrayScaleMorphologicalOperation = otbApplication.Registry.CreateApplication(
˓→"GrayScaleMorphologicalOperation")
GrayScaleMorphologicalOperation.SetParameterString("out", "opened.tif")
GrayScaleMorphologicalOperation.SetParameterInt("channel", 1)
GrayScaleMorphologicalOperation.SetParameterInt("structype.ball.xradius", 5)
GrayScaleMorphologicalOperation.SetParameterInt("structype.ball.yradius", 5)
GrayScaleMorphologicalOperation.SetParameterString("filter","erode")
Limitations
None
Authors
See Also
Computes Haralick textural features on the selected channel of the input image
Detailed description
(measures the texture homogeneity), Inertia (intensity contrast between a pixel and its neighborhood),
Cluster Shade, Cluster Prominence, Haralick Correlation;
• advanced: a set of 10 advanced Haralick features : Mean, Variance (measures the texture heterogeneity),
Dissimilarity, Sum Average, Sum Variance, Sum Entropy, Difference of Entropies, Difference of Vari-
ances, IC1, IC2;
• higher: a set of 11 higher Haralick features : Short Run Emphasis (measures the texture sharpness), Long
Run Emphasis (measures the texture roughness), Grey-Level Nonuniformity, Run Length Nonuniformity,
Run Percentage (measures the texture sharpness homogeneity), Low Grey-Level Run Emphasis, High
Grey-Level Run Emphasis, Short Run Low Grey-Level Emphasis, Short Run High Grey-Level Emphasis,
Long Run Low Grey-Level Emphasis and Long Run High Grey-Level Emphasis.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
HaralickTextureExtraction .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
channel Selected Channel Int
step Computation step Int
ram Available RAM (Mb) Int
parameters Texture feature parameters Group
parameters.xrad X Radius Int
parameters.yrad Y Radius Int
parameters.xoff X Offset Int
parameters.yoff Y Offset Int
parameters.min Image Minimum Float
parameters.max Image Maximum Float
parameters.nbbin Histogram number of bin Int
texture Texture Set Selection Choices
texture simple Simple Haralick Texture Features Choice
texture advanced Advanced Texture Features Choice
texture higher Higher Order Texture Features Choice
out Output Image Output image
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: The input image to compute the features on.
Selected Channel: The selected channel index.
Computation step: Step (in pixels) to compute output texture values. The first computed pixel position is shifted by
(step-1)/2 in both directions.
Available RAM (Mb): Available memory for processing (in MB).
[Texture feature parameters]: This group of parameters allows one to define texture parameters.
• X Radius: X Radius.
• Y Radius: Y Radius.
• X Offset: X Offset.
1 Table: Parameters table for Haralick Texture Extraction.
• Y Offset: Y Offset.
• Image Minimum: Image Minimum.
• Image Maximum: Image Maximum.
• Histogram number of bin: Histogram number of bin.
Texture Set Selection: Choice of The Texture Set. Available choices are:
• Simple Haralick Texture Features: This group of parameters defines the 8 local Haralick texture feature output
image. The image channels are: Energy, Entropy, Correlation, Inverse Difference Moment, Inertia, Cluster
Shade, Cluster Prominence and Haralick Correlation.
• Advanced Texture Features: This group of parameters defines the 10 advanced texture feature output image.
The image channels are: Mean, Variance, Dissimilarity, Sum Average, Sum Variance, Sum Entropy, Difference
of Entropies, Difference of Variances, IC1 and IC2.
• Higher Order Texture Features: This group of parameters defines the 11 higher order texture feature output
image. The image channels are: Short Run Emphasis, Long Run Emphasis, Grey-Level Nonuniformity, Run
Length Nonuniformity, Run Percentage, Low Grey-Level Run Emphasis, High Grey-Level Run Emphasis, Short
Run Low Grey-Level Emphasis, Short Run High Grey-Level Emphasis, Long Run Low Grey-Level Emphasis
and Long Run High Grey-Level Emphasis.
Output Image: Output image containing the selected texture features.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
HaralickTextureExtraction.SetParameterInt("channel", 2)
HaralickTextureExtraction.SetParameterInt("parameters.xrad", 3)
HaralickTextureExtraction.SetParameterInt("parameters.yrad", 3)
HaralickTextureExtraction.SetParameterString("texture","simple")
HaralickTextureExtraction.SetParameterString("out", "HaralickTextures.tif")
Limitations
The computation of the features is based on a Gray Level Co-occurrence matrix (GLCM) from the quantized input
image. Consequently the quantization parameters (min, max, nbbin) must be appropriate to the range of the pixel
values.
Authors
See Also
Detailed description
This application allows computing homologous points between images using keypoints. SIFT or SURF keypoints can
be used and the band on which keypoints are computed can be set independently for both images. The application
offers two modes : the first is the full mode where keypoints are extracted from the full extent of both images (please
note that in this mode large image file are not supported). The second mode, called geobins, allows one to set-up
spatial binning to get fewer points spread across the entire image. In this mode, the corresponding spatial bin in the
second image is estimated using geographical transform or sensor modelling, and is padded according to the user
defined precision. Last, in both modes the application can filter matches whose colocalisation in first image exceed
this precision. The elevation parameters are to deal more precisely with sensor modelling in case of sensor geometry
data. The outvector option allows creating a vector file with segments corresponding to the localisation error between
the matches. It can be useful to assess the precision of a registration for instance. The vector file is always reprojected
to EPSG:4326 to allow display in a GIS. This is done via reprojection or by applying the image sensor models.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
HomologousPointsExtraction .
1 Table: Parameters table for Homologous Points Extraction.
• Search keypoints in small spatial bins regularly spread across first image: This method allows retrieving a
set of tie points regulary spread across image 1. Corresponding bins in image 2 are retrieved using sensor and
geographical information if available. The first bin position takes into account the margin parameter. Bins are
cropped to the largest image region shrunk by the margin parameter for both in1 and in2 images.
• Size of bin: Radius of the spatial bin in pixels.
• Size of bin (y direction): Radius of the spatial bin in pixels (y direction). If not set, the mode.geobins.binsize
value is used.
• Steps between bins: Steps between bins in pixels.
• Steps between bins (y direction): Steps between bins in pixels (y direction). If not set, the
mode.geobins.binstep value is used.
• Margin from image border to start/end bins (in pixels): Margin from image border to start/end bins (in
pixels).
Estimated precision of the colocalisation function (in pixels).: Estimated precision of the colocalisation function in
pixels.
Filter points according to geographical or sensor based colocalisation: If enabled, this option allows one to filter
matches according to colocalisation from sensor or geographical information, using the given tolerancy expressed in
pixels.
If enabled, points from second image will be exported in WGS84
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Output file with tie points: File containing the list of tie points.
Output vector file with tie points: File containing segments representing matches .
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
HomologousPointsExtraction.SetParameterString("in2", "sensor_stereo_right.tif")
HomologousPointsExtraction.SetParameterString("mode","full")
HomologousPointsExtraction.SetParameterString("out", "homologous.txt")
Limitations
Authors
See Also
Detailed description
This application detects locally straight contours in a image. It is based on Burns, Hanson, and Riseman method
and use an a contrario validation approach (Desolneux, Moisan, and Morel). The algorithm was published by Rafael
Gromponevon Gioi, Jérémie Jakubowicz, Jean-Michel Morel and Gregory Randall. The given approach computes
gradient and level lines of the image and detects aligned points in line support region. The application allows exporting
the detected lines in a vector data.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
LineSegmentDetection .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Detected lines Output vector data
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
norescale No rescaling in [0, 255] Boolean
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image on which lines will be detected.
Output Detected lines: Output detected line segments (vector data).
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
No rescaling in [0, 255]: By default, the input image amplitude is rescaled between [0,255]. Turn on this parameter
to skip rescaling.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
LineSegmentDetection.SetParameterString("out", "LineSegmentDetection.shp")
Limitations
None
Authors
See Also
Computes local statistical moments on every pixel in the selected channel of the input image
Detailed description
This application computes the 4 local statistical moments on every pixel in the selected channel of the input image,
over a specified neighborhood. The output image is multi band with one statistical moment (feature) per band. Thus,
the 4 output features are the Mean, the Variance, the Skewness and the Kurtosis. They are provided in this exact order
in the output image.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
LocalStatisticExtraction .
1 Table: Parameters table for Local Statistic Extraction.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
LocalStatisticExtraction.SetParameterInt("channel", 1)
LocalStatisticExtraction.SetParameterInt("radius", 3)
LocalStatisticExtraction.SetParameterString("out", "Statistics.tif")
Limitations
None
Authors
See Also
Performs morphological convex, concave and flat classification on an input image channel
Detailed description
This algorithm is based on the following publication: Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE:
A new approach for the morphological segmentation of high resolution satellite imagery. IEEE Transactions on geo-
science and remote sensing, vol. 39, NO. 2, February 2001, p. 309-320.
This application perform the following decision rule to classify a pixel between the three classes Convex, Concave
and Flat. Let 𝑓 denote the input image and 𝜓𝑁 (𝑓 ) the geodesic leveling of 𝑓 with a structuring element of size 𝑁 .
⌣ ⌢
¯
One can derive the following decision rule to classify 𝑓 into Convex (label 𝑘 ), Concave (label 𝑘 ) and Flat (label 𝑘):
⎧⌣
⎪ 𝑘 : 𝑓 − 𝜓𝑁 (𝑓 ) > 𝜎
⎨
⌢
𝑓 (𝑛) = 𝑘 : 𝜓𝑁 (𝑓 ) − 𝑓 > 𝜎
⎪
⎩¯
𝑘 :| 𝑓 − 𝜓𝑁 (𝑓 ) |≤ 𝜎
The output is a labeled image (0 : Flat, 1 : Convex, 2 : Concave)
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MorphologicalClassification .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
channel Selected Channel Int
ram Available RAM (Mb) Int
structype Structuring Element Type Choices
structype ball Ball Choice
structype cross Cross Choice
radius Radius Int
sigma Sigma value for leveling tolerance Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: The input image to be classified.
• Output Image: The output classified image with 3 different values (0 : Flat, 1 : Convex, 2 : Concave).
1 Table: Parameters table for Morphological Classification.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MorphologicalClassification = otbApplication.Registry.CreateApplication(
˓→"MorphologicalClassification")
MorphologicalClassification.SetParameterInt("channel", 1)
MorphologicalClassification.SetParameterString("structype","ball")
MorphologicalClassification.SetParameterInt("radius", 5)
MorphologicalClassification.SetParameterFloat("sigma", 0.5)
MorphologicalClassification.SetParameterString("out", "output.tif")
Limitations
Generation of the morphological classification is not streamable, pay attention to this fact when setting the radius size
of the structuring element.
Authors
See Also
Detailed description
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MorphologicalMultiScaleDecomposition .
1 Table: Parameters table for Morphological Multi Scale Decomposition.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MorphologicalMultiScaleDecomposition = otbApplication.Registry.CreateApplication(
˓→"MorphologicalMultiScaleDecomposition")
MorphologicalMultiScaleDecomposition.SetParameterString("structype","ball")
MorphologicalMultiScaleDecomposition.SetParameterInt("channel", 1)
MorphologicalMultiScaleDecomposition.SetParameterInt("radius", 2)
MorphologicalMultiScaleDecomposition.SetParameterInt("levels", 2)
MorphologicalMultiScaleDecomposition.SetParameterInt("step", 3)
MorphologicalMultiScaleDecomposition.SetParameterString("outconvex", "convex.tif")
MorphologicalMultiScaleDecomposition.SetParameterString("outconcave", "concave.tif")
MorphologicalMultiScaleDecomposition.SetParameterString("outleveling", "leveling.tif")
Limitations
Generation of the multi scale decomposition is not streamable, pay attention to this fact when setting the number of
iterating levels.
Authors
See Also
Detailed description
- The multi scale geodesic morphological opening or closing profile of the input
˓→image.
The output image can be :- A 𝑁 multi band image for the opening/closing normal or derivative profiles. - A mono
band image for the opening/closing characteristics. - A labeled image for the classification.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MorphologicalProfilesAnalysis .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
channel Selected Channel Int
ram Available RAM (Mb) Int
structype Structuring Element Type Choices
structype ball Ball Choice
structype cross Cross Choice
size Profile Size Int
radius Initial radius Int
step Radius step. Int
profile Profile Choices
profile opening opening Choice
profile closing closing Choice
profile derivativeopening derivativeopening Choice
profile derivativeclosing derivativeclosing Choice
profile openingcharacteristics openingcharacteristics Choice
profile closingcharacteristics closingcharacteristics Choice
profile classification classification Choice
profile.classification.sigma Sigma value for leveling tolerance Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: The input image.
Output Image: The output image.
Selected Channel: The selected channel index for input image.
1 Table: Parameters table for Morphological Profiles Analysis.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MorphologicalProfilesAnalysis = otbApplication.Registry.CreateApplication(
˓→"MorphologicalProfilesAnalysis")
MorphologicalProfilesAnalysis.SetParameterInt("channel", 1)
MorphologicalProfilesAnalysis.SetParameterString("structype","ball")
MorphologicalProfilesAnalysis.SetParameterString("profile","classification")
MorphologicalProfilesAnalysis.SetParameterInt("size", 5)
MorphologicalProfilesAnalysis.SetParameterInt("radius", 1)
MorphologicalProfilesAnalysis.SetParameterInt("step", 1)
MorphologicalProfilesAnalysis.SetParameterFloat("profile.classification.sigma", 1)
MorphologicalProfilesAnalysis.SetParameterString("out", "output.tif")
Limitations
Generation of the morphological profile is not streamable, pay attention to this fact when setting the radius initial size
and step of the structuring element.
Authors
See Also
Detailed description
This application computes radiometric indices using the relevant channels of the input image. The output is a multi
band image into which each channel is one of the selected indices.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
RadiometricIndices .
1 Table: Parameters table for Radiometric Indices.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Limitations
None
Authors
See Also
Computes Structural Feature Set textures on every pixel of the input image selected channel
Detailed description
Structural Feature Set [1] are based on the histograms of the pixels in multiple directions of the image. The SFS-
TextureExtraction application computes the 6 following features: SFS’Length, SFS’Width, SFS’PSI, SFS’W-Mean,
SFS’Ratio and SFS’SD (Standard Deviation). The texture indices are computed from the neighborhood of each pixel.
It is possible to change the length of the calculation line (spatial threshold), as well as the maximum difference between
a pixel of the line and the pixel at the center of the neighborhood (spectral threshold) [2].
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SFSTextureExtraction .
1 Table: Parameters table for SFS Texture Extraction.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SFSTextureExtraction.SetParameterInt("channel", 1)
SFSTextureExtraction.SetParameterFloat("parameters.spethre", 50.0)
SFSTextureExtraction.SetParameterInt("parameters.spathre", 100)
SFSTextureExtraction.SetParameterString("out", "SFSTextures.tif")
Limitations
None
Authors
See Also
Vector data validation based on the fusion of features using Dempster-Shafer evidence theory framework.
Detailed description
This application validates or unvalidate the studied samples using the Dempster-Shafer theory.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VectorDataDSValidation .
1 Table: Parameters table for Vector Data validation.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorDataDSValidation.SetParameterStringList("belsup", [
˓→'cdbTvComputePolylineFeatureFromImage_LI_NOBUIL_gt.shp'])
VectorDataDSValidation.SetParameterString("descmod", "DSFuzzyModel.xml")
VectorDataDSValidation.SetParameterString("out", "VectorDataDSValidation.shp")
Limitations
None.
Authors
See Also
Stereo
Detailed description
This application allows one to performs block-matching to estimate pixel-wise disparities for a pair of images in
epipolar geometry.
This application is part of the stereovision pipeline. It can be used after having computed epipolar grids (with Stere-
oRectificationGridGenerator) and resampled each input image into epipolar geometry (with GridBasedImageResam-
pling).
The application searches locally for the displacement between a reference image and a secondary image. The correspondence is
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
BlockMatching .
[Input and output data]: This group of parameters allows setting the input and output images.
• Left input image: The left input image (reference). It should have the same size and same physical space as the
right input. This image can be generated by GridBasedImageResampling.
• Right input image: The right input (secondary). It should have the same size and same physical space as the
left input. This image can be generated by GridBasedImageResampling.
• The output disparity map: An image containing the estimated disparities as well as the metric values if the
option is used. If no metric is output and no sub-pixel interpolation is done, pixel type canbe a signed integer.
In the other cases, floating point pixel is advised.
• The output mask corresponding to all criterions: An output mask image corresponding to all citerions (see
masking parameters). Only required if variance threshold or nodata criterions are set. Output pixel type is
unsigned 8bit by default.
• Flag to output optimal metric values as well: If enabled, the output image will have a third component with
metric optimal values.
[Image masking parameters]: This group of parameters allows determining the masking parameters to prevent
disparities estimation for some pixels of the left image.
• Mask to discard left pixels: This parameter allows providing a custom mask for the left image. Block matching
will be only perform on pixels inside the mask (non-zero values).
• Mask to discard right pixels: This parameter allows providing a custom mask for the right image. Block
matching will be perform only on pixels inside the mask (non-zero values).
• Discard pixels with no-data value: This parameter allows discarding pixels whose value is equal to the user-
defined no-data value.
• Discard pixels with low local variance: This parameter allows discarding pixels whose local variance is too
small (the size of the neighborhood is given by the radius parameter).
[Block matching parameters]: This group of parameters allow tuning the block-matching behaviour.
• Block-matching metric: Metric to evaluate matching between two local windows. Available choices are:
• Sum of Squared Distances: Sum of squared distances between pixels value in the metric window.
• Normalized Cross-Correlation: Normalized Cross-Correlation between the left and right windows.
• Lp pseudo-norm: Lp pseudo-norm between the left and right windows.
• p value: Value of the p parameter in Lp pseudo-norm (must be positive).
• Radius of blocks: The radius (in pixels) of blocks in Block-Matching.
• Minimum horizontal disparity: Minimum horizontal disparity to explore (can be negative).
• Maximum horizontal disparity: Maximum horizontal disparity to explore (can be negative).
• Minimum vertical disparity: Minimum vertical disparity to explore (can be negative).
• Maximum vertical disparity: Maximum vertical disparity to explore (can be negative).
• Sub-pixel interpolation: Estimate disparities with sub-pixel precision. Available choices are:
• None: No sub-pixel search.
• Parabolic fit: The metric values closest to the best match are used in order to fit a parabola to the local extremum
of the metric surface. The peak position of this parabola is output.
• Triangular fit: The metric values closest to the best match are used in order to fit a triangular peak to the local
extremum of the metric surface. The peak position of this triangle is output.
• Dichotomy search: An iterative dichotomic search is performed to find the best sub-pixel position. The window
in the right image is resampled at sub-pixel positions to estimate the match.
• Computation step: Location step between computed disparities. Disparities will be computed every ‘step’
pixels in the left image (step for both rows and columns). For instance, a value of 1 corresponds to the classic
dense disparity map.
• X start index: X start index of the subsampled grid (wrt the input image grid). See parameter bm.step.
• Y start index: Y start index of the subsampled grid (wrt the input image grid). See parameter bm.step.
• Median filtering of disparity map: Use a median filter to get a smooth disparity map.
• Radius: Radius (in pixels) for median filter.
• Incoherence threshold: Incoherence threshold between original and filtered disparity.
• Initial disparities Available choices are:
• None: No initial disparity used.
• Uniform initial disparity: Use an uniform initial disparity estimate.
• Horizontal initial disparity: Value of the uniform horizontal disparity initial estimate (in pixels).
• Vertical initial disparity: Value of the uniform vertical disparity initial estimate (in pixels).
• Horizontal exploration radius: Horizontal exploration radius around the initial disparity estimate
(in pixels).
• Vertical exploration radius: Vertical exploration radius around the initial disparity estimate (in
pixels).
• Initial disparity maps: Use initial disparity maps to define the exploration area. This area in the
right image is centered on the current position shifted by the initial disparity estimate, and has a
given exploration radius in horizontal and vertical directions.
• Horizontal initial disparity map: Map of the initial horizontal disparities.
• Vertical initial disparity map: Map of the initial vertical disparities.
• Horizontal exploration radius: Horizontal exploration radius around the initial disparity estimate
(in pixels).
• Vertical exploration radius: Vertical exploration radius around the initial disparity estimate (in
pixels).
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
BlockMatching.SetParameterString("io.inright", "StereoMoving.png")
BlockMatching.SetParameterInt("bm.minhd", -10)
BlockMatching.SetParameterInt("bm.maxhd", 10)
BlockMatching.SetParameterFloat("mask.variancet", 10)
BlockMatching.SetParameterString("io.out", "MyDisparity.tif")
Limitations
None
Authors
See Also
Detailed description
This application uses a disparity map computed from a stereo image pair to produce an elevation map on the ground
area covered by the stereo pair.
This application is part of the stereo reconstruction pipeline. It can be used after having computed the disparity map
with BlockMatching.
The needed inputs are [the disparity map, the stereo pair (in original geometry) and the epipolar deformation grids.
These grids (computed by StereoRectificationGridGenerator) have to contain the transform between the origi-
nal geometry (stereo pair) and the epipolar geometry (disparity map). The algorithm for each disparity is the
following :]
• skip if position is discarded by the disparity mask
• compute left ray : transform the current position from epipolar geometry to left sensor geometry (left
rectification grid)
• compute right ray : shift the current position with current disparity and transform from epipolar geometry
to right sensor (right rectification grid)
• estimate best 3D intersection between left and right rays
• for the ground cell of the obtained 3D point, keep its elevation if greater than current elevation (keeps the
maximum of elevations of all 3D points in each cell)
Minimum and maximum elevations settings are here to bound the reconstructed DEM.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DisparityMapToElevationMap .
Parameter Key Parameter Name Parameter Type
io Input and output data Group
io.in Input disparity map Input image
io.left Left sensor image Input image
io.right Right sensor image Input image
io.lgrid Left Grid Input image
io.rgrid Right Grid Input image
io.out Output elevation map Output image
io.mask Disparity mask Input image
step DEM step Float
hmin Minimum elevation expected Float
hmax Maximum elevation expected Float
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
[Input and output data]: This group of parameters allows one to set input images, output images and grids.
1 Table: Parameters table for Disparity map to elevation map.
• Input disparity map: The input disparity map (horizontal disparity in first band, vertical in second). This map
can be computed by BlockMatching application.
• Left sensor image: Left image in original (sensor) geometry. Only the geometric model of this image will be
used, not the pixel values.
• Right sensor image: Right image in original (sensor) geometry. Only the geometric model of this image will
be used, not the pixel values.
• Left Grid: Left epipolar grid (deformation grid between left sensor et disparity spaces).
• Right Grid: Right epipolar grid (deformation grid between right sensor et disparity spaces).
• Output elevation map: Output elevation map in ground projection. Elevation values are in meters. Floating
point pixel type are expected.
• Disparity mask: Masked disparity pixels won’t be projected (mask values equal to zero).
DEM step: Spacing of the output elevation map (in meters).
Minimum elevation expected: Minimum elevation expected (in meters).
Maximum elevation expected: Maximum elevation expected (in meters).
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
˓→out dem.tif
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DisparityMapToElevationMap = otbApplication.Registry.CreateApplication(
˓→"DisparityMapToElevationMap")
DisparityMapToElevationMap.SetParameterString("io.left", "sensor_left.tif")
DisparityMapToElevationMap.SetParameterString("io.right", "sensor_right.tif")
DisparityMapToElevationMap.SetParameterString("io.lgrid", "grid_epi_left.tif")
DisparityMapToElevationMap.SetParameterString("io.rgrid", "grid_epi_right.tif")
DisparityMapToElevationMap.SetParameterString("io.out", "dem.tif")
Limitations
Authors
See Also
Detailed description
This application computes a disparity map between two images that correspond to the same scene. It is intended for
case where small misregistration between images should be estimated and fixed. The search is performed in 2D.
The algorithm uses an iterative approach to estimate a best match between local patches. The typical use case is
registration betwween similar bands, or between two acquisitions. The output image contains X and Y offsets, as well
as the metric value. A sub-pixel accuracy can be expected. The input images should have the same size and same
physical space.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
FineRegistration .
Parameter Key Parameter Name Parameter Type
ref Reference Image Input image
sec Secondary Image Input image
out Output Image Output image
erx Exploration Radius X Int
ery Exploration Radius Y Int
mrx Metric Radius X Int
mry Metric Radius Y Int
w Image To Warp Input image
wo Output Warped Image Output image
cox Coarse Offset X Float
coy Coarse Offset Y Float
ssrx Sub-Sampling Rate X Float
ssry Sub-Sampling Rate Y Float
rgsx Reference Gaussian Smoothing X Float
rgsy Reference Gaussian Smoothing Y Float
sgsx Secondary Gaussian Smoothing X Float
sgsy Secondary Gaussian Smoothing Y Float
m Metric String
spa SubPixelAccuracy Float
cva ConvergenceAccuracy Float
vmlt Validity Mask Lower Threshold Float
vmut Validity Mask Upper Threshold Float
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Reference Image: The reference image.
• Secondary Image: The secondary image.
• Output Image: The output image contains 3 bands, for X offset, Y offset and the metric value. It may contain
a 4th one with the validity mask (if used).
• Exploration Radius X: The exploration radius along x (in pixels).
• Exploration Radius Y: The exploration radius along y (in pixels).
• Metric Radius X: Radius along x (in pixels) of the metric computation window.
• Metric Radius Y: Radius along y (in pixels) of the metric computation window.
• Image To Warp: The image to warp after disparity estimation is completed.
• Output Warped Image: The output warped image.
• Coarse Offset X: Coarse offset along x (in physical space) between the two images, used as an initial offset for
all pixels.
• Coarse Offset Y: Coarse offset along y (in physical space) between the two images, used as an initial offset for
all pixels.
1 Table: Parameters table for Fine Registration.
• Sub-Sampling Rate X: Generates a result at a coarser resolution with a given sub-sampling rate along X.
• Sub-Sampling Rate Y: Generates a result at a coarser resolution with a given sub-sampling rate along Y.
• Reference Gaussian Smoothing X: Performs a gaussian smoothing of the reference image. Parameter is gaus-
sian sigma (in pixels) in X direction.
• Reference Gaussian Smoothing Y: Performs a gaussian smoothing of the reference image. Parameter is gaus-
sian sigma (in pixels) in Y direction.
• Secondary Gaussian Smoothing X: Performs a gaussian smoothing of the secondary image. Parameter is
gaussian sigma (in pixels) in X direction.
• Secondary Gaussian Smoothing Y: Performs a gaussian smoothing of the secondary image. Parameter is
gaussian sigma (in pixels) in Y direction.
• Metric: Choose the metric used for block matching. Available metrics are cross-correlation (CC), cross-
correlation with subtracted mean (CCSM), mean-square difference (MSD), mean reciprocal square difference
(MRSD) and mutual information (MI). Default is cross-correlation.
• SubPixelAccuracy: Metric extrema location will be refined up to the given accuracy. Default is 0.01.
• ConvergenceAccuracy: Metric extrema will be refined up to the given accuracy. Default is 0.01.
• Validity Mask Lower Threshold: Lower threshold to compute the validity mask. This mask will be the 4th
output band.
• Validity Mask Upper Threshold: Upper threshold to obtain a validity mask. This mask will be the 4th output
band.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
FineRegistration.SetParameterString("sec", "StereoMoving.png")
FineRegistration.SetParameterString("out", "FineRegistration.tif")
FineRegistration.SetParameterInt("erx", 2)
FineRegistration.SetParameterInt("ery", 2)
FineRegistration.SetParameterInt("mrx", 3)
FineRegistration.SetParameterInt("mry", 3)
Limitations
None
Authors
Detailed description
Compute the ground elevation with a stereo block matching algorithm between one or multiple stereo pair in sensor
geometry. The output is projected in desired geographic or cartographic map projection (WGS84 by default).
This application is chaining different processing steps. Some of them are also performed by other applications in the stereo-reco
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
StereoFramework .
[Input parameters]: This group of parameters allows one to set input data.
• Input images list: List of images corresponding to multiple views on a single scene, in sensor geometry.
• Couples list: List of index of couples im image list. Couples must be separated by a comma (index start at 0).
For example : 0 1,1 2 will process a first couple composed of the first and the second image in image list, then
the second and the third image . Note that images are handled by pairs. If left empty, couples are created from
input index i.e. a first couple will be composed of the first and second image, a second couple with third and
fourth image etc. (in this case image list must be even).
• Input Image channel: Channel used for block matching (the same for all images).
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
[Output parameters]: This group of parameters allows one to choose the DSM resolution, nodata value, and projec-
tion parameters.
• Output resolution: Spatial sampling distance of the output elevation : the cell size (in m).
• NoData value: DSM empty cells are filled with this value (optional -32768 by default).
• Method to fuse measures in each DSM cell: This parameter allows one to choose the method used to fuse
elevation measurements in each output DSM cell. Available choices are:
• Maximum: The cell is filled with the maximum measured elevation values.
• Minimum: The cell is filled with the minimum measured elevation values.
• Mean: The cell is filled with the mean of measured elevation values.
• Accumulator: Accumulator mode. The cell is filled with the the number of values (for debugging purposes).
• Output DSM: Output elevation image.
• Parameters estimation modes Available choices are:
• Fit to sensor image: Fit the size, origin and spacing to an existing ortho image (uses the value of
outputs.ortho).
• User Defined: This mode allows you to fully modify default values.
• Upper Left X: Cartographic X coordinate of upper-left corner (meters for cartographic projections,
degrees for geographic ones).
• Upper Left Y: Cartographic Y coordinate of the upper-left corner (meters for cartographic projec-
tions, degrees for geographic ones).
• Size X: Size of projected image along X (in pixels).
• Size Y: Size of projected image along Y (in pixels).
• Pixel Size X: Size of each pixel along X axis (meters for cartographic projections, degrees for
geographic ones).
• Pixel Size Y: Size of each pixel along Y axis (meters for cartographic projections, degrees for
geographic ones).
Map Projection: Defines the map projection to be used. Available choices are:
• Universal Trans-Mercator (UTM): A system of transverse mercator projections dividing the surface of Earth
between 80S and 84N latitude.
• Zone number: The zone number ranges from 1 to 60 and allows defining the transverse mercator projection
(along with the hemisphere).
• Northern Hemisphere: The transverse mercator projections are defined by their zone number as well as the
hemisphere. Activate this parameter if your image is in the northern hemisphere.
• Lambert II Etendu: This is a Lambert Conformal Conic projection mainly used in France.
• Lambert93: This is a Lambert 93 projection mainly used in France.
• WGS 84: This is a Geographical projection.
• EPSG Code: This code is a generic way of identifying map projections, and allows specifying a large amount
of them. See www.spatialreference.org to find which EPSG code is associated to your projection;.
• EPSG Code: See www.spatialreference.org to find which EPSG code is associated to your projection.
[Stereorectification Grid parameters]: This group of parameters allows one to choose direct and inverse grid sub-
sampling. These parameters are very useful to tune time and memory consumption.
• Step of the displacement grid (in pixels): Stereo-rectification displacement grid only varies slowly. Therefore,
it is recommended to use a coarser grid (higher step value) in case of large images.
• Sub-sampling rate for epipolar grid inversion: Grid inversion is an heavy process that implies spline regres-
sion on control points. To avoid eating to much memory, this parameter allows one to first sub-sample the field
to invert.
[Block matching parameters]: This group of parameters allow tuning the block-matching behavior.
• Block-matching metric: Metric used to compute matching score. Available choices are:
• Sum of Squared Distances divided by mean of block: derived version of Sum of Squared Dis-
tances between pixels value in the metric window (SSD divided by mean over window).
• Sum of Squared Distances: Sum of squared distances between pixels value in the metric window.
• Normalized Cross-Correlation: Normalized Cross-Correlation between the left and right windows.
• Lp pseudo-norm: Lp pseudo-norm between the left and right windows.
• p value: Value of the p parameter in Lp pseudo-norm (must be positive).
• Correlation window radius (in pixels): The radius of blocks in Block-Matching (in pixels).
• Minimum altitude offset (in meters): Minimum altitude below the selected elevation source (in meters).
• Maximum altitude offset (in meters): Maximum altitude above the selected elevation source (in meters).
[Postprocessing parameters]: This group of parameters allow use optional filters.
• Use bijection consistency in block matching strategy: Use bijection consistency. Right to Left correlation is
computed to validate Left to Right disparities. If bijection is not found, the disparity is rejected.
• Use median disparities filtering: Disparity map can be filtered using median post filtering (disabled by default).
• Correlation metric threshold: Use block matching metric output to discard pixels with low correlation value
(disabled by default, float value).
[Masks]
• Input left mask: Mask for left input image. Pixel with a null mask value are discarded.
• Input right mask: Mask for right input image. Pixel with a null mask value are discarded.
• Discard pixels with low local variance: This parameter allows one to discard pixels whose local variance is
too small (the size of the neighborhood is given by the correlation window radius).
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
StereoFramework.SetParameterFloat("elev.default", 200)
StereoFramework.SetParameterInt("stereorect.fwdgridstep", 8)
StereoFramework.SetParameterInt("stereorect.invgridssrate", 4)
StereoFramework.SetParameterString("postproc.med","1")
StereoFramework.SetParameterFloat("output.res", 2.5)
StereoFramework.SetParameterString("output.out", "dem.tif")
Authors
See Also
Generates two deformation fields to resample in epipolar geometry, a pair of stereo images up to the sensor model
precision
Detailed description
This application generates a pair of deformation grid to stereo-rectify a pair of stereo images according to sensor
modelling and a mean elevation hypothesis.
This application is the first part of the stereo reconstruction framework. The output deformation grids can be passed
to the GridBasedImageResampling application for actual resampling into epipolar geometry.
There are several ways to set the elevation source:
• An arbitrary constant elevation
• A DEM directory
• Compute an average elevation from a DEM
If needed, the application can compute inverse resampling grids (from epipolar to original sensor geometry). Don’t
forget to check the other outputs from the application. For instance, the application gives the X and Y size of the
rectified images, along with an estimated baseline ratio.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
StereoRectificationGridGenerator .
Parameter Key Parameter Name Parameter Type
io Input and output data Group
io.inleft Left input image Input image
io.inright Right input image Input image
io.outleft Left output deformation grid Output image
io.outright Right output deformation grid Output image
epi Epipolar geometry and grid parameters Group
epi.elevation Elevation management Group
epi.elevation.dem DEM directory Directory
epi.elevation.geoid Geoid File Input File name
epi.elevation.default Default elevation Float
epi.elevation.avgdem Average elevation computed from DEM Group
epi.elevation.avgdem.step Sub-sampling step Int
epi.elevation.avgdem.value Average elevation value Float
epi.elevation.avgdem.mindisp Minimum disparity from DEM Float
epi.elevation.avgdem.maxdisp Maximum disparity from DEM Float
epi.scale Scale of epipolar images Float
epi.step Step of the deformation grid (in nb. of pixels) Int
epi.rectsizex Rectified image size X Int
epi.rectsizey Rectified image size Y Int
epi.baseline Mean baseline ratio Float
inverse Write inverse fields Group
inverse.outleft Left inverse deformation grid Output image
inverse.outright Right inverse deformation grid Output image
inverse.ssrate Sub-sampling rate for inversion Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
[Input and output data]: This group of parameters allows setting the input and output images.
• Left input image: The left image from the stereo pair, in sensor geometry.
• Right input image: The right image from the stereo pair, in sensor geometry.
• Left output deformation grid: The deformation grid to resample the left image from sensor geometry to
epipolar geometry.
• Right output deformation grid: The deformation grid to resample the right image from sensor geometry to
epipolar geometry.
[Epipolar geometry and grid parameters]: Parameters of the epipolar geometry and output grids.
• Elevation management: This group of parameters allows managing elevation values. Supported formats are
SRTM, DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles
related to a product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model
files. Note that this directory should contain only DEM files. Unexpected behaviour might occurs if
other images are found in this directory.
1 Table: Parameters table for Stereo-rectification deformation grid generator.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available,
no coverage for some points or pixels with no_data in the DEM tiles. A version of the geoid can be
found on the OTB website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/
DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no
DEM available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid
file has been set. This is also used by some application as an average elevation value.
• Average elevation computed from DEM: Average elevation computed from the provided DEM.
• Sub-sampling step: Step of sub-sampling for average elevation estimation.
• Average elevation value: Average elevation value estimated from DEM.
• Minimum disparity from DEM: Disparity corresponding to estimated minimum elevation over the
left image.
• Maximum disparity from DEM: Disparity corresponding to estimated maximum elevation over
the left image.
• Scale of epipolar images: The scale parameter allows generating zoomed-in (scale < 1) or zoomed-out (scale
> 1) epipolar images.
• Step of the deformation grid (in nb. of pixels): Stereo-rectification deformation grid only varies slowly.
Therefore, it is recommended to use a coarser grid (higher step value) in case of large images.
• Rectified image size X: The application computes the optimal rectified image size so that the whole left input
image fits into the rectified area. However, due to the scale and step parameter, this size may not match the size
of the deformation field output. In this case, one can use these output values.
• Rectified image size Y: The application computes the optimal rectified image size so that the whole left input
image fits into the rectified area. However, due to the scale and step parameter, this size may not match the size
of the deformation field output. In this case, one can use these output values.
• Mean baseline ratio: This parameter is the mean value, in pixels.meters^-1, of the baseline to sensor altitude
ratio. It can be used to convert disparities to physical elevation, since a disparity of one pixel will correspond to
an elevation offset of the invert of this value with respect to the mean elevation.
[Write inverse fields]: This group of parameter allows generating the inverse fields as well.
• Left inverse deformation grid: The deformation grid to resample the left image from the epipolar geometry
back into its original sensor geometry.
• Right inverse deformation grid: The output deformation grid to resample the right image from the epipolar
geometry back into its original sensor geometry.
• Sub-sampling rate for inversion: Grid inversion is an heavy process that implies spline regression on control
points. To avoid eating to much memory, this parameter allows one to first sub-sample the field to invert.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
StereoRectificationGridGenerator = otbApplication.Registry.CreateApplication(
˓→"StereoRectificationGridGenerator")
StereoRectificationGridGenerator.SetParameterString("io.inright", "wv2_xs_left.tif")
StereoRectificationGridGenerator.SetParameterString("io.outleft", "wv2_xs_left_epi_
˓→field.tif")
StereoRectificationGridGenerator.SetParameterString("io.outright", "wv2_xs_right_epi_
˓→field.tif")
StereoRectificationGridGenerator.SetParameterFloat("epi.elevation.default", 400)
Limitations
Generation of the deformation grid is not streamable, pay attention to this fact when setting the grid step.
Authors
See Also
Geometry
Detailed description
This application performs P+XS pansharpening. The default mode use Pan and XS sensor models to estimate the
transformation to superimpose XS over Pan before the fusion (“default mode”). The application provides also a PHR
mode for Pleiades images which does not use sensor models as Pan and XS products are already coregistered but only
estimate an affine transformation to superimpose XS over the Pan.Note that this option is automatically activated in
case Pleiades images are detected as input.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
BundleToPerfectSensor .
Parameter Key Parameter Name Parameter Type
inp Input PAN Image Input image
inxs Input XS Image Input image
out Output image Output image
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
mode Mode Choices
mode default Default mode Choice
mode phr Pleiades mode Choice
method Algorithm Choices
method rcs RCS Choice
method lmvm LMVM Choice
method bayes Bayesian Choice
method.lmvm.radiusx X radius Int
method.lmvm.radiusy Y radius Int
method.bayes.lambda Weight Float
method.bayes.s S coefficient Float
lms Spacing of the deformation field Float
interpolator Interpolation Choices
interpolator bco Bicubic interpolation Choice
interpolator nn Nearest Neighbor interpolation Choice
interpolator linear Linear interpolation Choice
interpolator.bco.radius Radius for bicubic interpolation Int
fv Fill Value Float
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input PAN Image: Input panchromatic image.
Input XS Image: Input XS image.
Output image: Output image.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
1 Table: Parameters table for Bundle to perfect sensor.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Mode: Superimposition mode. Available choices are:
• Default mode: Default superimposition mode : uses any projection reference or sensor model found in the
images.
• Pleiades mode: Pleiades superimposition mode, designed for the case of a P+XS bundle in SENSOR geometry.
It uses a simple transform on the XS image : a scaling and a residual translation.
Algorithm: Selection of the pan-sharpening method. Available choices are:
• RCS: Simple RCS Pan sharpening operation.
• LMVM: Local Mean and Variance Matching (LMVM) Pan sharpening.
• X radius: Set the x radius of the sliding window.
• Y radius: Set the y radius of the sliding window.
• Bayesian: Bayesian fusion.
• Weight: Set the weighting value.
• S coefficient: Set the S coefficient.
Spacing of the deformation field: Spacing of the deformation field. Default is 10 times the PAN image spacing.
Interpolation: This group of parameters allows defining how the input image will be interpolated during resampling.
Available choices are:
• Bicubic interpolation: Bicubic interpolation leads to very good image quality but is slow.
• Radius for bicubic interpolation: This parameter allows controlling the size of the bicubic interpolation filter.
If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts.
• Nearest Neighbor interpolation: Nearest neighbor interpolation leads to poor image quality, but it is very fast.
• Linear interpolation: Linear interpolation leads to average image quality but is quite fast.
Fill Value: Fill value for area outside the reprojected image.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
BundleToPerfectSensor.SetParameterString("inxs", "QB_Toulouse_Ortho_XS.tif")
BundleToPerfectSensor.SetParameterString("out", "BundleToPerfectSensor.png")
BundleToPerfectSensor.SetParameterOutputImagePixelType("out", 1)
Limitations
None
Authors
Detailed description
This application computes the geographic coordinates from cartographic ones. User has to give the X and Y coordinate
and the cartographic projection (see mapproj parameter for details).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ConvertCartoToGeoPoint .
1 Table: Parameters table for Cartographic to geographic coordinates conversion.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ConvertCartoToGeoPoint.SetParameterFloat("carto.y", 4835740)
ConvertCartoToGeoPoint.SetParameterString("mapproj","utm")
ConvertCartoToGeoPoint.SetParameterString("mapproj.utm.northhem","true")
ConvertCartoToGeoPoint.SetParameterInt("mapproj.utm.zone", 31)
Limitations
None
Authors
Detailed description
This Application converts a sensor point of an input image to a geographic point using the Forward Sensor Model of
the input image.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ConvertSensorToGeoPoint .
1 Table: Parameters table for Convert Sensor Point To Geographic Point.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ConvertSensorToGeoPoint.SetParameterFloat("input.idx", 200)
ConvertSensorToGeoPoint.SetParameterFloat("input.idy", 200)
Limitations
None
Authors
See Also
Detailed description
The application converts an image containing elevations into a PLY file, which is a file format to store 3D models.
This format is adpated for visualization on software such as MeshLab [2] or CloudCompare [3]
This application is part of the stereo reconstruction framework. The input data can be produced by the application
DisparityMapToElevationMap.
There are two types of supported input images:
• A DEM image, with a ground projection, containing elevation values. Each elevation value can be consid-
ered as a 3D point.
• A 3D grid image, containing 5 bands (the first 3 are the 3D coordinates of each point, the 5th is a validity
mask where valid values are larger or equal to 1)
The user shall also give a support image that contains color values for each 3D point. The color values will be
embedded in the PLY file.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
GeneratePlyFile .
1 Table: Parameters table for Ply 3D files generation.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
GeneratePlyFile.SetParameterString("out", "out.ply")
GeneratePlyFile.SetParameterString("incolor", "image_color.tif")
Limitations
Authors
See Also
Detailed description
This application generates a RPC sensor model from a list of Ground Control Points. At least 20 points are required
for estimation without elevation support, and 40 points for estimation with elevation support. Elevation support will
be automatically deactivated if an insufficient amount of points is provided. The application can optionally output a
file containing accuracy statistics for each point, and a vector file containing segments representing points residues.
The map projection parameter allows defining a map projection in which the accuracy is evaluated.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
GenerateRPCSensorModel .
Parameter Key Parameter Name Parameter Type
outgeom Output geom file Output File name
inpoints Input file containing tie points Input File name
outstat Output file containing output precision statistics Output File name
outvector Output vector file with residues Output File name
map Map Projection Choices
map utm Universal Trans-Mercator (UTM) Choice
map lambert2 Lambert II Etendu Choice
map lambert93 Lambert93 Choice
map wgs WGS 84 Choice
map epsg EPSG Code Choice
map.utm.zone Zone number Int
map.utm.northhem Northern Hemisphere Boolean
map.epsg.code EPSG Code Int
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Output geom file: Geom file containing the generated RPC sensor model.
Input file containing tie points: Input file containing tie points. Points are stored in following format: col row lon
lat. Spaced by a space or tab character. Line beginning with # are ignored.
Output file containing output precision statistics: Output file containing the following info: ref_lon ref_lat ele-
vation predicted_lon predicted_lat x_error_ref(meters) y_error_ref(meters) global_error_ref(meters) x_error(meters)
y_error(meters) overall_error(meters).
Output vector file with residues: File containing segments representing residues.
Map Projection: Defines the map projection to be used. Available choices are:
• Universal Trans-Mercator (UTM): A system of transverse mercator projections dividing the surface of Earth
between 80S and 84N latitude.
• Zone number: The zone number ranges from 1 to 60 and allows defining the transverse mercator projection
(along with the hemisphere).
• Northern Hemisphere: The transverse mercator projections are defined by their zone number as well as the
hemisphere. Activate this parameter if your image is in the northern hemisphere.
• Lambert II Etendu: This is a Lambert Conformal Conic projection mainly used in France.
• Lambert93: This is a Lambert 93 projection mainly used in France.
• WGS 84: This is a Geographical projection.
1 Table: Parameters table for Generate a RPC sensor model.
• EPSG Code: This code is a generic way of identifying map projections, and allows specifying a large amount
of them. See www.spatialreference.org to find which EPSG code is associated to your projection;.
• EPSG Code: See www.spatialreference.org to find which EPSG code is associated to your projection.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
GenerateRPCSensorModel.SetParameterString("inpoints", "points.txt")
GenerateRPCSensorModel.SetParameterString("map","epsg")
GenerateRPCSensorModel.SetParameterInt("map.epsg.code", 32631)
Limitations
None
Authors
See Also
Detailed description
This application allows performing image resampling from an input resampling grid.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
GridBasedImageResampling .
1 Table: Parameters table for Grid Based Image Resampling.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
GridBasedImageResampling.SetParameterString("io.out", "ROI_IKO_PAN_LesHalles_sub_
˓→resampled.tif")
GridBasedImageResampling.SetParameterOutputImagePixelType("io.out", 1)
GridBasedImageResampling.SetParameterString("grid.in", "ROI_IKO_PAN_LesHalles_sub_
˓→deformation_field.tif")
GridBasedImageResampling.SetParameterInt("out.sizex", 256)
GridBasedImageResampling.SetParameterInt("out.sizey", 256)
GridBasedImageResampling.SetParameterString("grid.type","def")
Limitations
None
Authors
See Also
Detailed description
Build a vector data containing the image envelope polygon. Useful for some projection, you can set the polygon with
more points with the sr parameter. This filter supports user-specified output projection. If no projection is defined, the
standard WGS84 projection will be used.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ImageEnvelope .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Vector Data Output vector data
sr Sampling Rate Int
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
proj Projection String
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image filename.
Output Vector Data: Vector data file containing the envelope.
Sampling Rate: Sampling rate for image edges (in pixel).
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
1 Table: Parameters table for Image Envelope.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Projection: Projection to be used to compute the envelope (default is WGS84).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ImageEnvelope.SetParameterString("out", "ImageEnvelope.shp")
Limitations
None
Authors
OrthoRectification - Ortho-rectification
This application allows ortho-rectifying optical and radar images from supported sensors.
Detailed description
This application uses inverse sensor modelling combined with a choice of interpolation functions to resample a sensor
geometry image into a ground geometry regular grid. The ground geometry regular grid is defined with respect to
a map projection (see map parameter). The application offers several modes to estimate the output grid parameters
(origin and ground sampling distance), including automatic estimation of image size, ground sampling distance, or
both, from image metadata, user-defined ROI corners, or another ortho-image.A digital Elevation Model along with
a geoid file can be specified to account for terrain deformations.In case of SPOT5 images, the sensor model can be
approximated by an RPC model in order to speed-up computation.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
OrthoRectification .
[Input and output data]: This group of parameters allows setting the input and output images.
• Input Image: The input image to ortho-rectify.
• Output Image: The ortho-rectified output image.
Map Projection: Defines the map projection to be used. Available choices are:
• Universal Trans-Mercator (UTM): A system of transverse mercator projections dividing the surface of Earth
between 80S and 84N latitude.
• Zone number: The zone number ranges from 1 to 60 and allows defining the transverse mercator projection
(along with the hemisphere).
• Northern Hemisphere: The transverse mercator projections are defined by their zone number as well as the
hemisphere. Activate this parameter if your image is in the northern hemisphere.
• Lambert II Etendu: This is a Lambert Conformal Conic projection mainly used in France.
• Lambert93: This is a Lambert 93 projection mainly used in France.
• WGS 84: This is a Geographical projection.
• EPSG Code: This code is a generic way of identifying map projections, and allows specifying a large amount
of them. See www.spatialreference.org to find which EPSG code is associated to your projection;.
• EPSG Code: See www.spatialreference.org to find which EPSG code is associated to your projection.
[Output Image Grid]: This group of parameters allows one to define the grid on which the input image will be
resampled.
• Parameters estimation modes Available choices are:
• User Defined: This mode allows you to fully modify default values.
• Automatic Size from Spacing: This mode allows you to automatically compute the optimal image size from
given spacing (pixel size) values.
• Automatic Spacing from Size: This mode allows you to automatically compute the optimal image spacing
(pixel size) from the given size.
• Automatic Size from Spacing and output corners: This mode allows you to automatically compute the opti-
mal image size from spacing (pixel size) and output corners.
• Fit to ortho: Fit the size, origin and spacing to an existing ortho image (uses the value of outputs.ortho).
• Upper Left X: Cartographic X coordinate of upper-left corner (meters for cartographic projections, degrees for
geographic ones).
• Upper Left Y: Cartographic Y coordinate of the upper-left corner (meters for cartographic projections, degrees
for geographic ones).
• Size X: Size of projected image along X (in pixels).
• Size Y: Size of projected image along Y (in pixels).
• Pixel Size X: Size of each pixel along X axis (meters for cartographic projections, degrees for geographic ones).
• Pixel Size Y: Size of each pixel along Y axis (meters for cartographic projections, degrees for geographic ones).
• Lower right X: Cartographic X coordinate of the lower-right corner (meters for cartographic projections, de-
grees for geographic ones).
• Lower right Y: Cartographic Y coordinate of the lower-right corner (meters for cartographic projections, de-
grees for geographic ones).
• Model ortho-image: A model ortho-image that can be used to compute size, origin and spacing of the output.
• Force isotropic spacing by default: Default spacing (pixel size) values are estimated from the sensor modeling
of the image. It can therefore result in a non-isotropic spacing. This option allows you to force default values
to be isotropic (in this case, the minimum of spacing in both direction is applied. Values overridden by user are
not affected by this option.
• Default pixel value: Default value to write when outside of input image.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Interpolation: This group of parameters allows one to define how the input image will be interpolated during resam-
pling. Available choices are:
• Bicubic interpolation
• Radius for bicubic interpolation: This parameter allows one to control the size of the bicubic interpolation
filter. If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing
artifacts.
• Nearest Neighbor interpolation: Nearest neighbor interpolation leads to poor image quality, but it is very fast.
• Linear interpolation: Linear interpolation leads to average image quality but is quite fast.
[Speed optimization parameters]: This group of parameters allows optimization of processing time.
• RPC modeling (points per axis): Enabling RPC modeling allows one to speed-up SPOT5 ortho-rectification.
Value is the number of control points per axis for RPC estimation.
• Available RAM (Mb): This allows setting the maximum amount of RAM available for processing. As the
writing task is time consuming, it is better to write large pieces of data, which can be achieved by increasing
this parameter (pay attention to your system capabilities).
• Resampling grid spacing: Resampling is done according to a coordinate mapping deformation grid, whose
pixel size is set by this parameter, and expressed in the coordinate system of the output image The closer to the
output spacing this parameter is, the more precise will be the ortho-rectified image,but increasing this parameter
will reduce processing time.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
OrthoRectification.SetParameterString("io.out", "QB_Toulouse_ortho.tif")
Limitations
Supported sensors (both optical and radar) are: GeoEye, Ikonos, Pleiades, Quickbird, RadarSat, Sentinel-1, SPOT5 (TIF forma
Also note that the opt.gridspacing default value may not be suitable for all sensors. In particular, if this value is
lower than the target ground sampling distance, the processing time may increase a lot. A warning is issued in
this case. Typical values should be half the DEM ground sampling distance.
Authors
See Also
Pansharpening - Pansharpening
Detailed description
This application performs P+XS pansharpening. Pansharpening is a process of merging high-resolution panchromatic
and lower resolution multispectral imagery to create a single high-resolution color image. Algorithms available in the
applications are: RCS, bayesian fusion and Local Mean and Variance Matching(LMVM).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Pansharpening .
Parameter Key Parameter Name Parameter Type
inp Input PAN Image Input image
inxs Input XS Image Input image
out Output image Output image
method Algorithm Choices
method rcs RCS Choice
method lmvm LMVM Choice
method bayes Bayesian Choice
method.lmvm.radiusx X radius Int
method.lmvm.radiusy Y radius Int
method.bayes.lambda Weight Float
method.bayes.s S coefficient Float
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input PAN Image: Input panchromatic image.
Input XS Image: Input XS image.
Output image: Output image.
Algorithm: Selection of the pan-sharpening method. Available choices are:
• RCS: Simple RCS Pan sharpening operation.
• LMVM: Local Mean and Variance Matching (LMVM) Pan sharpening.
• X radius: Set the x radius of the sliding window.
• Y radius: Set the y radius of the sliding window.
• Bayesian: Bayesian fusion.
• Weight: Set the weighting value.
• S coefficient: Set the S coefficient.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
1 Table: Parameters table for Pansharpening.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Pansharpening.SetParameterString("inxs", "QB_Toulouse_Ortho_XS.tif")
Pansharpening.SetParameterString("out", "Pansharpening.tif")
Pansharpening.SetParameterOutputImagePixelType("out", 3)
Limitations
None
Authors
Detailed description
This application reads a geom file containing a sensor model and a text file containing a list of ground control point, and
performs a least-square fit of the sensor model adjustable parameters to these tie points. It produces an updated geom
file as output, as well as an optional ground control points based statistics file and a vector file containing residues.
The output geom file can then be used to ortho-rectify the data more accurately. Plaease note that for a proper use of
the application, elevation must be correctly set (including DEM and geoid file). The map parameters allows one to
choose a map projection in which the accuracy will be estimated in meters.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
RefineSensorModel .
Parameter Key Parameter Name Parameter Type
ingeom Input geom file Input File name
outgeom Output geom file Output File name
inpoints Input file containing tie points Input File name
outstat Output file containing output precision statistics Output File name
outvector Output vector file with residues Output File name
map Map Projection Choices
map utm Universal Trans-Mercator (UTM) Choice
map lambert2 Lambert II Etendu Choice
map lambert93 Lambert93 Choice
map wgs WGS 84 Choice
map epsg EPSG Code Choice
map.utm.zone Zone number Int
map.utm.northhem Northern Hemisphere Boolean
map.epsg.code EPSG Code Int
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input geom file: Geom file containing the sensor model to refine.
Output geom file: Geom file containing the refined sensor model.
Input file containing tie points: Input file containing tie points. Points are stored in following format: row col lon
lat. Line beginning with # are ignored.
Output file containing output precision statistics: Output file containing the following info: ref_lon ref_lat ele-
vation predicted_lon predicted_lat x_error_ref(meters) y_error_ref(meters) global_error_ref(meters) x_error(meters)
y_error(meters) overall_error(meters).
Output vector file with residues: File containing segments representing residues.
Map Projection: Defines the map projection to be used. Available choices are:
• Universal Trans-Mercator (UTM): A system of transverse mercator projections dividing the surface of Earth
between 80S and 84N latitude.
• Zone number: The zone number ranges from 1 to 60 and allows defining the transverse mercator projection
(along with the hemisphere).
• Northern Hemisphere: The transverse mercator projections are defined by their zone number as well as the
hemisphere. Activate this parameter if your image is in the northern hemisphere.
• Lambert II Etendu: This is a Lambert Conformal Conic projection mainly used in France.
• Lambert93: This is a Lambert 93 projection mainly used in France.
• WGS 84: This is a Geographical projection.
1 Table: Parameters table for Refine Sensor Model.
• EPSG Code: This code is a generic way of identifying map projections, and allows specifying a large amount
of them. See www.spatialreference.org to find which EPSG code is associated to your projection;.
• EPSG Code: See www.spatialreference.org to find which EPSG code is associated to your projection.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
RefineSensorModel.SetParameterString("outgeom", "output.geom")
RefineSensorModel.SetParameterString("inpoints", "points.txt")
RefineSensorModel.SetParameterString("map","epsg")
RefineSensorModel.SetParameterInt("map.epsg.code", 32631)
Limitations
None
Authors
See Also
Detailed description
This application performs a parametric transform on the input image. Scaling, translation and rotation with scaling
factor are handled. Parameters of the transform is expressed in physical units, thus particular attention must be paid on
pixel size (value, and sign). Moreover transform is expressed from input space to output space (on the contrary ITK
Transforms are expressed form output space to input space).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
RigidTransformResample .
1 Table: Parameters table for Image resampling with a rigid transform.
Interpolation: This group of parameters allows one to define how the input image will be interpolated during resam-
pling. Available choices are:
• Nearest Neighbor interpolation: Nearest neighbor interpolation leads to poor image quality, but it is very fast.
• Linear interpolation: Linear interpolation leads to average image quality but is quite fast.
• Bicubic interpolation
• Radius for bicubic interpolation: This parameter allows controlling the size of the bicubic interpolation filter.
If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts.
Available RAM (Mb): This allows setting the maximum amount of RAM available for processing. As the writing
task is time consuming, it is better to write large pieces of data, which can be achieved by increasing this parameter
(pay attention to your system capabilities).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
˓→scalex 2. -transform.type.rotation.scaley 2.
To run this example from Python, use the following code snippet:
#!/usr/bin/python
RigidTransformResample.SetParameterString("out", "rigitTransformImage.tif")
RigidTransformResample.SetParameterString("transform.type","rotation")
RigidTransformResample.SetParameterFloat("transform.type.rotation.angle", 20)
RigidTransformResample.SetParameterFloat("transform.type.rotation.scalex", 2.)
RigidTransformResample.SetParameterFloat("transform.type.rotation.scaley", 2.)
Limitations
None
Authors
See Also
Using available image metadata, project one image onto another one
Detailed description
This application performs the projection of an image into the geometry of another one.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Superimpose .
Parameter Key Parameter Name Parameter Type
inr Reference input Input image
inm The image to reproject Input image
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
lms Spacing of the deformation field Float
fv Fill Value Float
out Output image Output image
mode Mode Choices
mode default Default mode Choice
mode phr Pleiades mode Choice
interpolator Interpolation Choices
interpolator bco Bicubic interpolation Choice
interpolator nn Nearest Neighbor interpolation Choice
interpolator linear Linear interpolation Choice
interpolator.bco.radius Radius for bicubic interpolation Int
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Reference input: The input reference image.
The image to reproject: The image to reproject into the geometry of the reference input.
1 Table: Parameters table for Superimpose sensor.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Spacing of the deformation field: Generate a coarser deformation field with the given spacing.
Fill Value: Fill value for area outside the reprojected image.
Output image: Output reprojected image.
Mode: Superimposition mode. Available choices are:
• Default mode: Default superimposition mode : uses any projection reference or sensor model found in the
images.
• Pleiades mode: Pleiades superimposition mode, designed for the case of a P+XS bundle in SENSOR geometry.
It uses a simple transform on the XS image : a scaling and a residual translation.
Interpolation: This group of parameters allows defining how the input image will be interpolated during resampling.
Available choices are:
• Bicubic interpolation: Bicubic interpolation leads to very good image quality but is slow.
• Radius for bicubic interpolation: This parameter allows controlling the size of the bicubic interpolation filter.
If the target pixel size is higher than the input pixel size, increasing this parameter will reduce aliasing artifacts.
• Nearest Neighbor interpolation: Nearest neighbor interpolation leads to poor image quality, but it is very fast.
• Linear interpolation: Linear interpolation leads to average image quality but is quite fast.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Superimpose = otbApplication.Registry.CreateApplication("Superimpose")
Superimpose.SetParameterString("inm", "QB_Toulouse_Ortho_XS.tif")
Superimpose.SetParameterString("out", "SuperimposedXS_to_PAN.tif")
Limitations
None
Authors
Learning
Filters the input labeled image using Majority Voting in a ball shaped neighbordhood.
Detailed description
This application filters the input labeled image (with a maximal class label = 65535) using Majority Voting in a ball shaped neigh
-NoData is the label of the NOT classified pixels in the input image. These input pixels keep their NoData
label in the output image. -Pixels with more than 1 majority class are marked as Undecided if the parameter
‘ip.suvbool == true’, or keep their Original labels otherwise.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ClassificationMapRegularization .
1 Table: Parameters table for Classification Map Regularization.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ClassificationMapRegularization = otbApplication.Registry.CreateApplication(
˓→"ClassificationMapRegularization")
ClassificationMapRegularization.SetParameterString("io.out", "clLabeledImageQB123_1_
˓→CMR_r2_nodl_10_undl_7.tif")
ClassificationMapRegularization.SetParameterInt("ip.radius", 2)
ClassificationMapRegularization.SetParameterString("ip.suvbool","true")
ClassificationMapRegularization.SetParameterString("ip.onlyisolatedpixels","true")
ClassificationMapRegularization.SetParameterInt("ip.nodatalabel", 10)
ClassificationMapRegularization.SetParameterInt("ip.undecidedlabel", 7)
Limitations
The input image must be a single band labeled image (with a maximal class label = 65535). The structuring element
radius must have a minimum value equal to 1 pixel. Please note that the Undecided value must be different from
existing labels in the input labeled image.
Authors
See Also
Detailed description
This application computes the confusion matrix of a classification map relatively to a ground truth. This ground truth
can be given as a raster or a vector data. Only reference and produced pixels with values different from NoData are
handled in the calculation of the confusion matrix. The confusion matrix is organized the following way: rows =
reference labels, columns = produced labels. In the header of the output file, the reference and produced class labels
are ordered according to the rows/columns of the confusion matrix.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ComputeConfusionMatrix .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Matrix output Output File name
format set the output format to contingency table or confusion Choices
matrix
format Choice of a confusion matrix as output. Choice
confusionmatrix
format Choice of a contingency table as output. Choice
contingencytable
ref Ground truth Choices
ref raster Ground truth as a raster image Choice
ref vector Ground truth as a vector data file Choice
ref.raster.in Input reference image Input image
ref.raster.nodata Value for nodata pixels in ref raster Int
ref.vector.in Input reference vector data Input File name
ref.vector.field Field name List
ref.vector.nodata Value for nodata pixels in ref vector Int
nodatalabel Value for nodata pixels in input image Int
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters
file
outxml Save otb application to xml file XML output parameters
file
Input Image: The input classification image.
Matrix output: Filename to store the output matrix (csv format).
set the output format to contingency table or confusion matrix: Choice of the output format as a contingency table
for unsupervised algorithmsor confusion matrix for supervised ones. Available choices are:
• Choice of a confusion matrix as output.
• Choice of a contingency table as output.
Ground truth: Choice of ground truth format. Available choices are:
• Ground truth as a raster image
• Input reference image: Input image containing the ground truth labels.
• Value for nodata pixels in ref raster: Label to be treated as no data in ref raster.
1 Table: Parameters table for Confusion matrix Computation.
Example
˓→nodata 255
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ComputeConfusionMatrix.SetParameterString("out", "ConfusionMatrix.csv")
ComputeConfusionMatrix.SetParameterString("ref","vector")
ComputeConfusionMatrix.SetParameterString("ref.vector.in", "VectorData_QB1_bis.shp")
Limitations
None
Authors
Computes global mean and standard deviation for each band from a set of images and optionally saves the results in
an XML file.
Detailed description
This application computes a global mean and standard deviation for each band of a set of images and optionally saves
the results in an XML file. The output XML is intended to be used an input for the TrainImagesClassifier application
to normalize samples before learning. You can also normalize the image with the XML file in the ImageClassifier
application.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ComputeImagesStatistics .
Parameter Key Parameter Name Parameter Type
il Input images Input image list
bv Background Value Float
out Output XML file Output File name
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input images: List of input images filenames.
• Background Value: Background value to ignore in statistics computation.
• Output XML file: XML filename where the statistics are saved for future reuse.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ComputeImagesStatistics.SetParameterString("out", "EstimateImageStatisticsQB1.xml")
Limitations
Each image of the set must contain the same bands as the others (i.e. same types, in the same order).
Authors
See Also
Fuses several classifications maps of the same image on the basis of class labels.
Detailed description
This application allows you to fuse several classification maps and produces a single more robust classification map.
Fusion is done either by mean of Majority Voting, or with the Dempster Shafer combination method on class labels.
• MAJORITY VOTING: for each pixel, the class with the highest number of votes is selected.
• DEMPSTER SHAFER: for each pixel, the class label for which the Belief Function is maximal is selected. This
Belief Function is calculated by mean of the Dempster Shafer combination of Masses of Belief, and indicates
the belief that each input classification map presents for each label value. Moreover, the Masses of Belief are
based on the input confusion matrices of each classification map, either by using the PRECISION or RECALL
rates, or the OVERALL ACCURACY, or the KAPPA coefficient. Thus, each input classification map needs to
be associated with its corresponding input confusion matrix file for the Dempster Shafer fusion.
• Input pixels with the NODATA label are not handled in the fusion of classification maps. Moreover, pixels for
which all the input classifiers are set to NODATA keep this value in the output fused image.
• In case of number of votes equality, the UNDECIDED label is attributed to the pixel.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
FusionOfClassifications .
1 Table: Parameters table for Fusion of Classifications.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
FusionOfClassifications.SetParameterString("method","dempstershafer")
FusionOfClassifications.SetParameterString("method.dempstershafer.mob","precision")
FusionOfClassifications.SetParameterInt("nodatalabel", 0)
FusionOfClassifications.SetParameterInt("undecidedlabel", 10)
FusionOfClassifications.SetParameterString("out", "classification_fused.tif")
Limitations
None
Authors
See Also
Detailed description
This application performs an image classification based on a model file produced by the TrainImagesClassifier appli-
cation. Pixels of the output image will contain the class labels decided by the classifier (maximal class label = 65535).
The input pixels can be optionally centered and reduced according to the statistics file produced by the ComputeIm-
agesStatistics application. An optional input mask can be provided, in which case only input image pixels whose
corresponding mask value is greater than 0 will be classified. By default, the remaining of pixels will be given the
label 0 in the output image.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ImageClassifier .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
mask Input Mask Input image
model Model file Input File name
imstat Statistics file Input File name
nodatalabel Label mask value Int
out Output Image Output image
confmap Confidence map Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: The input image to classify.
• Input Mask: The mask allows restricting classification of the input image to the area where mask pixel values
are greater than 0.
• Model file: A model file (produced by TrainImagesClassifier application, maximal class label = 65535).
• Statistics file: A XML file containing mean and standard deviation to center and reduce samples before classi-
fication (produced by ComputeImagesStatistics application).
• Label mask value: By default, hidden pixels will have the assigned label 0 in the output image. It’s possible to
define the label mask by another value, but be careful to not take a label from another class (max. 65535).
• Output Image: Output image containing class labels.
• Confidence map: Confidence map of the produced classification. The confidence index depends on the model
: - LibSVM : difference between the two highest probabilities (needs a model with probability estimates, so
that classes probabilities can be computed for each sample) - OpenCV * Boost : sum of votes * DecisionTree :
(not supported) * GradientBoostedTree : (not supported) * KNearestNeighbors : number of neighbors with the
same label * NeuralNetwork : difference between the two highest responses * NormalBayes : (not supported) *
RandomForest : Confidence (proportion of votes for the majority class). Margin (normalized difference of the
votes of the 2 majority classes) is not available for now. * SVM : distance to margin (only works for 2-class
models) .
1 Table: Parameters table for Image Classification.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ImageClassifier.SetParameterString("imstat", "EstimateImageStatisticsQB1.xml")
ImageClassifier.SetParameterString("model", "clsvmModelQB1.svm")
ImageClassifier.SetParameterString("out", "clLabeledImageQB1.tif")
Limitations
The input image must have the same type, order and number of bands than the images used to produce the statistics
file and the SVM model file. If a statistics file was used during training by the TrainImagesClassifier, it is mandatory
to use the same statistics file for classification. If an input mask is used, its size must match the input image size.
Authors
See Also
Performs dimensionality reduction of the input image according to a dimensionality reduction model file.
Detailed description
This application reduces the dimension of an input image, based on a machine learning model file produced by the
TrainDimensionalityReduction application. Pixels of the output image will contain the reduced values fromthe model.
The input pixels can be optionally centered and reduced according to the statistics file produced by the ComputeIm-
agesStatistics application.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ImageDimensionalityReduction .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
mask Input Mask Input image
model Model file Input File name
imstat Statistics file Input File name
out Output Image Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: The input image to predict.
• Input Mask: The mask allow restricting classification of the input image to the area where mask pixel values
are greater than 0.
• Model file: A dimensionality reduction model file (produced by TrainRegression application).
• Statistics file: A XML file containing mean and standard deviation to center and reduce samples before predic-
tion (produced by ComputeImagesStatistics application). If this file containsone more bands than the sample
size, the last stat of last band will beapplied to expand the output predicted value.
• Output Image: Output image containing reduced values.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
1 Table: Parameters table for Image Dimensionality Reduction.
#!/usr/bin/python
ImageDimensionalityReduction = otbApplication.Registry.CreateApplication(
˓→"ImageDimensionalityReduction")
ImageDimensionalityReduction.SetParameterString("imstat", "EstimateImageStatisticsQB1.
˓→xml")
ImageDimensionalityReduction.SetParameterString("model", "clsvmModelQB1.model")
ImageDimensionalityReduction.SetParameterString("out", "ReducedImageQB1.tif")
Limitations
The input image must contain the feature bands used for the model training. If a statistics file was used during training
by the Training application, it is mandatory to use the same statistics file for reduction.
Authors
See Also
Detailed description
images second order statistics, 6) TrainVectorClassifier : train the SharkKMeans model, 7) ImageClassifier : performs
the classification of the input image according to a model file.
It’s possible to choice random/periodic modes of the SampleSelection application. If you want keep the temporary
files (sample selected, model file, ...), initialize cleanup parameter. For more information on shark KMeans algorithm
[1].
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
KMeansClassification .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
nc Number of classes Int
ts Training set size Int
maxit Maximum number of iterations Int
outmeans Centroid filename Output File name
ram Available RAM (Mb) Int
sampler Sampler type Choices
sampler periodic Periodic sampler Choice
sampler random Random sampler Choice
sampler.periodic.jitter Jitter amplitude Int
vm Validity Mask Input image
nodatalabel Label mask value Int
cleanup Temporary files cleaning Boolean
rand set user defined seed Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image filename.
Output Image: Output image containing class labels.
Number of classes: Number of modes, which will be used to generate class membership.
Training set size: Size of the training set (in pixels).
Maximum number of iterations: Maximum number of iterations for the learning step.
Centroid filename: Output text file containing centroid positions.
Available RAM (Mb): Available memory for processing (in MB).
Sampler type: Type of sampling (periodic, pattern based, random). Available choices are:
• Periodic sampler: Takes samples regularly spaced.
• Jitter amplitude: Jitter amplitude added during sample selection (0 = no jitter).
• Random sampler: The positions to select are randomly shuffled.
Validity Mask: Validity mask, only non-zero pixels will be used to estimate KMeans modes.
Label mask value: By default, hidden pixels will have the assigned label 0 in the output image. It’s possible to define
the label mask by another value, but be careful to not take a label from another class. This application initialize the
labels from 0 to N-1, N is the number of class (defined by ‘nc’ parameter).
1 Table: Parameters table for Unsupervised KMeans image classification.
Temporary files cleaning: If activated, the application will try to clean all temporary files it created.
set user defined seed: Set specific seed. with integer value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
KMeansClassification.SetParameterInt("ts", 1000)
KMeansClassification.SetParameterInt("nc", 5)
KMeansClassification.SetParameterInt("maxit", 1000)
KMeansClassification.SetParameterString("out", "ClassificationFilterOutput.tif")
KMeansClassification.SetParameterOutputImagePixelType("out", 1)
Limitations
None
Authors
See Also
Detailed description
The application computes sampling rates for a set of input images. Before calling this application, each pair of image
and training vectors has to be analysed with the application PolygonClassStatistics. The statistics file is then used to
compute the sampling rates for each class in each image. Several types of sampling are implemented. Each one is a
combination of a mono-image strategy and a multi-image mode. The mono-image strategies are :
• smallest (default) : select the same number of sample in each class so that the smallest one is fully sampled.
• constant : select the same number of samples N in each class (with N below or equal to the size of the smallest
class).
• byclass : set the required number for each class manually, with an input CSV file (first column is class name,
second one is the required samples number).
The multi-image modes (mim) are proportional, equal and custom. The custom mode lets the users choose the distribution of sa
• strategy = all
– Same behaviour for all modes : take all samples
• strategy = constant : let’s call M the global number of samples required per class. For each image i and
each class c:
– if mim = proportional, then Ni( c ) = M * Ti( c ) / sum_k( Tk(c) )
– if mim = equal , then Ni( c ) = M / L
– if mim = custom , then Ni( c ) = Mi where Mi is the custom requested number of samples for image i
• strategy = byClass : let’s call M(c) the global number of samples for class c). For each image i and each
class c:
– if mim = proportional, then Ni( c ) = M(c) * Ti( c ) / sum_k( Tk(c) )
– if mim = equal , then Ni( c ) = M(c) / L
– if mim = custom , then Ni( c ) = Mi(c) where Mi(c) is the custom requested number of samples for
image i and class c
• strategy = percent : For each image i and each class c:
– if mim = proportional, then Ni( c ) = p * Ti( c ) where p is the global percentage of samples
– if mim = equal , then Ni( c ) = p * sum_k(Tk(c)]/L where p is the global percentage of samples
– if mim = custom , then Ni( c ) = p(i) * Ti(c) where p(i) is the percentage of samples for image i. c
• strategy = total : For each image i and each class c:
– if mim = proportional, then Ni( c ) = total * (sum_k(Ti(k))/sum_kl(Tl(k))) * (Ti(c)/sum_k(Ti(k)))
where total is the total number of samples specified.
– if mim = equal , then Ni( c ) = (total / L) * (Ti(c)/sum_k(Ti(k))) where total is the total number of
samples specified.
– if mim = custom , then Ni( c ) = total(i) * (Ti(c)/sum_k(Ti(k))) where total(i) is the total number of
samples specified for image i.
• strategy = smallest class
– if mim = proportional, then the smallest class size (computed globally) is used for the strategy con-
stant+proportional.
– if mim = equal , then the smallest class size (computed globally) is used for the strategy con-
stant+equal.
– if mim = custom , then the smallest class is computed and used for each image separately.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MultiImageSamplingRate .
Parameter Key Parameter Name Parameter Type
il Input statistics Input File name list
out Output sampling rates Output File name
strategy Sampling strategy Choices
strategy byclass Set samples count for each class Choice
strategy Set the same samples counts for all classes Choice
constant
strategy smallest Set same number of samples for all classes, with the smallest class Choice
fully sampled
strategy percent Use a percentage of the samples available for each class Choice
strategy total Set the total number of samples to generate, and use class Choice
proportions.
strategy all Take all samples Choice
strat- Number of samples by class Input File name list
egy.byclass.in
strat- Number of samples for all classes String
egy.constant.nb
strat- The percentage(s) to use String
egy.percent.p
strategy.total.v The number of samples to generate String
mim Multi-Image Mode Choices
mim Proportional Choice
proportional
mim equal equal Choice
mim custom Custom Choice
inxml Load otb application from xml file XML input parameters
file
outxml Save otb application to xml file XML output
parameters file
Input statistics: List of statistics files for each input image.
1 Table: Parameters table for Multi-image sampling rate estimation.
Output sampling rates: 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 Available choices are:
• Set samples count for each class: Set samples count for each class.
• Number of samples by class: 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.
• Set the same samples counts for all classes: Set the same samples counts for all classes.
• Number of samples for all classes: Number of samples for all classes.In the case of the custom multi-image
mode, several values can be given for each image.
• 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.
• The percentage(s) to use: The percentage(s) to use In the case of the custom multi-image mode, several values
can be given for each image.
• Set the total number of samples to generate, and use class proportions.: Set the total number of samples to
generate, and use class proportions.
• The number of samples to generate: The number of samples to generateIn the case of the custom multi-image
mode, several values can be given for each image.
• Take all samples: Take all samples.
Multi-Image Mode Available choices are:
• Proportional: Split proportionally the required number of samples.
• equal: Split equally the required number of samples.
• Custom: Split the required number of samples following user choice.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MultiImageSamplingRate.SetParameterString("out", "rates.csv")
MultiImageSamplingRate.SetParameterString("strategy","smallest")
MultiImageSamplingRate.SetParameterString("mim","proportional")
Limitations
None
Authors
Detailed description
The application processes a set of geometries intended for training (they should have a field giving the associated class). The geo
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
PolygonClassStatistics .
1 Table: Parameters table for Polygon Class Statistics.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
PolygonClassStatistics.SetParameterString("vec", "variousVectors.sqlite")
Limitations
None
Authors
Detailed description
This application predict output values from an input image, based on a regression model file produced by the Train-
Regression application. Pixels of the output image will contain the predicted values fromthe regression model (single
band). The input pixels can be optionally centered and reduced according to the statistics file produced by the Com-
puteImagesStatistics application. An optional input mask can be provided, in which case only input image pixels
whose corresponding mask value is greater than 0 will be processed. The remaining of pixels will be given the value
0 in the output image.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
PredictRegression .
1 Table: Parameters table for Predict Regression.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
PredictRegression.SetParameterString("imstat", "EstimateImageStatisticsQB1.xml")
PredictRegression.SetParameterString("model", "clsvmModelQB1.svm")
PredictRegression.SetParameterString("out", "clLabeledImageQB1.tif")
Limitations
The input image must contain the feature bands used for the model training (without the predicted value). If a statistics
file was used during training by the TrainRegression, it is mandatory to use the same statistics file for prediction. If an
input mask is used, its size must match the input image size.
Authors
See Also
Detailed description
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SOMClassification .
Parameter Key Parameter Name Parameter Type
in InputImage Input image
out OutputImage Output image
vm ValidityMask Input image
tp TrainingProbability Float
ts TrainingSetSize Int
som SOM Map Output image
sx SizeX Int
sy SizeY Int
nx NeighborhoodX Int
ny NeighborhoodY Int
ni NumberIteration Int
bi BetaInit Float
bf BetaFinal Float
iv InitialValue Float
ram Available RAM (Mb) Int
rand set user defined seed Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
1 Table: Parameters table for SOM Classification.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SOMClassification.SetParameterString("out", "SOMClassification.tif")
SOMClassification.SetParameterFloat("tp", 1.0)
SOMClassification.SetParameterInt("ts", 16384)
SOMClassification.SetParameterInt("sx", 32)
SOMClassification.SetParameterInt("sy", 32)
SOMClassification.SetParameterInt("nx", 10)
SOMClassification.SetParameterInt("ny", 10)
SOMClassification.SetParameterInt("ni", 5)
SOMClassification.SetParameterFloat("bi", 1.0)
SOMClassification.SetParameterFloat("bf", 0.1)
SOMClassification.SetParameterFloat("iv", 0)
Limitations
None
Authors
Detailed description
The application takes a sample data file as generated by the SampleExtraction application and generates synthetic
samples to increase the number of available samples.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SampleAugmentation .
1 Table: Parameters table for Sample Augmentation.
Example
˓→strategy.smote.neighbors 5
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Limitations
None
Authors
Detailed description
The application extracts samples values from animage using positions contained in a vector data file.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SampleExtraction .
1 Table: Parameters table for Sample Extraction.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SampleExtraction.SetParameterString("vec", "sample_positions.sqlite")
SampleExtraction.SetParameterString("outfield","prefix")
SampleExtraction.SetParameterString("outfield.prefix.name", "band_")
Limitations
None
Authors
Detailed description
The application selects a set of samples from geometries intended for training (they should have a field giving the
associated class).
First of all, the geometries must be analyzed by the PolygonClassStatistics application to compute statistics about
the geometries, which are summarized in an xml file. Then, this xml file must be given as input to this application
(parameter instats).
The input support image and the input training vectors shall be given in parameters ‘in’ and ‘vec’ respectively. Only
the sampling grid (origin, size, spacing)will be read in the input image. There are several strategies to select samples
(parameter strategy) :
• smallest (default) : select the same number of sample in each class so that the smallest one is fully sampled.
• constant : select the same number of samples N in each class (with N below or equal to the size of the smallest
class).
• byclass : set the required number for each class manually, with an input CSV file (first column is class name,
second one is the required samples number).
• percent: set a target global percentage of samples to use. Class proportions will be respected.
• total: set a target total number of samples to use. Class proportions will be respected.
There is also a choice on the sampling type to performs :
• periodic : select samples uniformly distributed
• random : select samples randomly distributed
Once the strategy and type are selected, the application outputs samples positions(parameter out).
The other parameters to look at are :
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SampleSelection .
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Available RAM (Mb): Available memory for processing (in MB).
set user defined seed: Set specific seed. with integer value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SampleSelection.SetParameterString("vec", "variousVectors.sqlite")
Limitations
None
Authors
Detailed description
Trainer for dimensionality reduction algorithms (autoencoders, PCA, SOM). All input samples are used to compute
the model, like other machine learning models. The model can be used in the ImageDimensionalityReduction and
VectorDimensionalityReduction applications.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
TrainDimensionalityReduction .
Parameter Key Parameter Name Parameter Type
io Input and output data Group
io.vd Input Vector Data Input vector data
io.out Output model Output File name
io.stats Input XML image statistics file Input File name
feat Field names to be used for training. String list
algorithm algorithm to use for the training Choices
algorithm som OTB SOM Choice
algorithm autoencoder Shark Autoencoder Choice
algorithm pca Shark PCA Choice
algorithm.som.s Map size String list
algorithm.som.n Neighborhood sizes String list
algorithm.som.ni NumberIteration Int
algorithm.som.bi BetaInit Float
algorithm.som.bf BetaFinal Float
algorithm.som.iv InitialValue Float
algorithm.autoencoder.nbiter Maximum number of iterations during Int
training
algo- Maximum number of iterations during Int
rithm.autoencoder.nbiterfinetuning training
algorithm.autoencoder.epsilon Epsilon Float
algorithm.autoencoder.initfactor Weight initialization factor Float
algorithm.autoencoder.nbneuron Size String list
algo- Strength of the regularization String list
rithm.autoencoder.regularization
algorithm.autoencoder.noise Strength of the noise String list
algorithm.autoencoder.rho Sparsity parameter String list
algorithm.autoencoder.beta Sparsity regularization strength String list
algo- Learning curve Output File name
rithm.autoencoder.learningcurve
algorithm.pca.dim Dimension of the output of the pca Int
transformation
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters
file
outxml Save otb application to xml file XML output parameters
file
[Input and output data]: This group of parameters allows setting input and output data.
1 Table: Parameters table for Train Dimensionality Reduction.
• Input Vector Data: Input geometries used for training (note : all geometries from the layer will be used).
• Output model: Output file containing the estimated model (.txt format).
• Input XML image statistics file: XML file containing mean and variance of each feature.
Field names to be used for training.: List of field names in the input vector data used as features for training.
algorithm to use for the training: Choice of the dimensionality reduction algorithm to use for the training. Available
choices are:
• OTB SOM: This group of parameters allows setting SOM parameters. .
• Map size: Sizes of the SOM map (one per dimension). For instance, [12;15] means a 2D map of size 12x15.
Support2D to 5D maps.
• Neighborhood sizes: Sizes of the initial neighborhood in the SOM map (one per dimension). The number of
sizes should be the same as the map sizes.
• NumberIteration: Number of iterations for SOM learning.
• BetaInit: Initial learning coefficient.
• BetaFinal: Final learning coefficient.
• InitialValue: Maximum initial neuron weight.
• Shark Autoencoder: This group of parameters allows setting Shark autoencoder parameters. .
• Maximum number of iterations during training: The maximum number of iterations used during training.
• Maximum number of iterations during training: The maximum number of iterations used during fine tuning
of the whole network.
• Epsilon: Epsilon.
• Weight initialization factor: Parameter that control the weight initialization of the autoencoder.
• Size: The number of neurons in each hidden layer.
• Strength of the regularization: Strength of the L2 regularization used during training.
• Strength of the noise: Strength of the noise.
• Sparsity parameter: Sparsity parameter.
• Sparsity regularization strength: Sparsity regularization strength.
• Learning curve: Learning error values.
• Shark PCA: This group of parameters allows setting Shark PCA parameters. .
• Dimension of the output of the pca transformation: Dimension of the output of the pca transformation.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
TrainDimensionalityReduction = otbApplication.Registry.CreateApplication(
˓→"TrainDimensionalityReduction")
TrainDimensionalityReduction.SetParameterString("io.out", "mode.ae")
TrainDimensionalityReduction.SetParameterString("algorithm","pca")
TrainDimensionalityReduction.SetParameterInt("algorithm.pca.dim", 8)
˓→9'])
Limitations
None
Authors
See Also
Train a classifier from multiple pairs of images and training vector data.
Detailed description
This application performs a classifier training from multiple pairs of input images and training vector data. Samples are compo
The training vector data must contain polygons with a positive integer field representing the class label. The
name of this field can be set using the “Class label field” parameter. Training and validation sample lists are
built such that each class is equally represented in both lists. One parameter allows controlling the ratio between
the number of samples in training and validation sets. Two parameters allow managing the size of the training
and validation sets per class and per image. Several classifier parameters can be set depending on the chosen
classifier. In the validation process, the confusion matrix is organized the following way: rows = reference
labels, columns = produced labels. In the header of the optional confusion matrix output file, the validation
(reference) and predicted (produced) class labels are ordered according to the rows/columns of the confusion
matrix. This application is based on LibSVM and OpenCV Machine Learning (2.3.1 and later).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
TrainImagesClassifier .
[Input and output data]: This group of parameters allows setting input and output data.
• Input Image List: A list of input images.
• Input Vector Data List: A list of vector data to select the training samples.
• Validation Vector Data List: A list of vector data to select the validation samples.
• Input XML image statistics file: XML file containing mean and variance of each feature.
• Output model: Output file containing the model estimated (.txt format).
• Output confusion matrix or contingency table: Output file containing the confusion matrix or contingency
table (.csv format).The contingency table is output when we unsupervised algorithms is used otherwise the
confusion matrix is output.
Temporary files cleaning: If activated, the application will try to clean all temporary files it created.
[Training and validation samples parameters]: This group of parameters allows you to set training and validation
sample lists parameters.
• Maximum training sample size per class: Maximum size per class (in pixels) of the training sample list
(default = 1000) (no limit = -1). If equal to -1, then the maximal size of the available training sample list per
class will be equal to the surface area of the smallest class multiplied by the training sample ratio.
• Maximum validation sample size per class: Maximum size per class (in pixels) of the validation sample list
(default = 1000) (no limit = -1). If equal to -1, then the maximal size of the available validation sample list per
class will be equal to the surface area of the smallest class multiplied by the validation sample ratio.
• Bound sample number by minimum: Bound the number of samples for each class by the number of available
samples by the smaller class. Proportions between training and validation are respected. Default is true (=1).
• Training and validation sample ratio: Ratio between training and validation samples (0.0 = all training, 1.0 =
all validation) (default = 0.5).
• Field containing the class integer label for supervision: Field containing the class id for supervision. The
values in this field shall be cast into integers.
Available RAM (Mb): Available memory for processing (in MB).
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Classifier to use for the training: Choice of the classifier to use for the training. Available choices are:
• LibSVM classifier: This group of parameters allows setting SVM classifier parameters.
• SVM Kernel Type: SVM Kernel Type. Available choices are:
• Linear: Linear Kernel, no mapping is done, this is the fastest option.
• Gaussian radial basis function: This kernel is a good choice in most of the case. It is an exponential
function of the euclidian distance between the vectors.
• Polynomial: Polynomial Kernel, the mapping is a polynomial function.
• Sigmoid: The kernel is a hyperbolic tangente function of the vectors.
• SVM Model Type: Type of SVM formulation. Available choices are:
• C support vector classification: This formulation allows imperfect separation of classes. The
penalty is set through the cost parameter C.
• Nu support vector classification: This formulation allows imperfect separation of classes. The
penalty is set through the cost parameter Nu. As compared to C, Nu is harder to optimize, and may
not be as fast.
• Distribution estimation (One Class SVM): All the training data are from the same class, SVM
builds a boundary that separates the class from the rest of the feature space.
• Cost parameter C: SVM models have a cost parameter C (1 by default) to control the trade-off
between training errors and forcing rigid margins.
• Cost parameter Nu: Cost parameter Nu, in the range 0..1, the larger the value, the smoother the
decision.
• Parameters optimization: SVM parameters optimization flag.
• Probability estimation: Probability estimation flag.
• Boost classifier: This group of parameters allows setting Boost classifier parameters. See complete documen-
tation here url{http://docs.opencv.org/modules/ml/doc/boosting.html}.
• Boost Type: Type of Boosting algorithm. Available choices are:
• Discrete AdaBoost: This procedure trains the classifiers on weighted versions of the training sam-
ple, giving higher weight to cases that are currently misclassified. This is done for a sequence of
weighter samples, and then the final classifier is defined as a linear combination of the classifier from
each stage.
• Real AdaBoost (technique using confidence-rated predictions and working well with categori-
cal data): Adaptation of the Discrete Adaboost algorithm with Real value.
• LogitBoost (technique producing good regression fits): This procedure is an adaptive Newton
algorithm for fitting an additive logistic regression model. Beware it can produce numeric instability.
• Gentle AdaBoost (technique setting less weight on outlier data points and, for that reason,
being often good with regression data): A modified version of the Real Adaboost algorithm, using
Newton stepping rather than exact optimization at each step.
• Weak count: The number of weak classifiers.
• Weight Trim Rate: A threshold between 0 and 1 used to save computational time. Samples with
summary weight <= (1 - weight_trim_rate) do not participate in the next iteration of training. Set
this parameter to 0 to turn off this functionality.
• Maximum depth of the tree: Maximum depth of the tree.
• Decision Tree classifier: This group of parameters allows setting Decision Tree classifier parameters. See
complete documentation here url{http://docs.opencv.org/modules/ml/doc/decision_trees.html}.
• Maximum depth of the tree: The training algorithm attempts to split each node while its depth is smaller than
the maximum possible depth of the tree. The actual depth may be smaller if the other termination criteria are
met, and/or if the tree is pruned.
• Minimum number of samples in each node: If the number of samples in a node is smaller than this parameter,
then this node will not be split.
• Termination criteria for regression tree: If all absolute differences between an estimated value in a node and
the values of the train samples in this node are smaller than this regression accuracy parameter, then the node
will not be split further.
• Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split: Cluster
possible values of a categorical variable into K <= cat clusters to find a suboptimal split.
• K-fold cross-validations: If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K is equal to
cv_folds.
• Set Use1seRule flag to false: If true, then a pruning will be harsher. This will make a tree more compact and
more resistant to the training data noise but a bit less accurate.
• Set TruncatePrunedTree flag to false: If true, then pruned branches are physically removed from the tree.
• Gradient Boosted Tree classifier: This group of parameters allows setting Gradient Boosted Tree classifier
parameters. See complete documentation here url{http://docs.opencv.org/modules/ml/doc/gradient_boosted_
trees.html}.
• Number of boosting algorithm iterations: Number “w” of boosting algorithm iterations, with w*K being the
total number of trees in the GBT model, where K is the output number of classes.
• Regularization parameter: Regularization parameter.
• Portion of the whole training set used for each algorithm iteration: Portion of the whole training set used
for each algorithm iteration. The subset is generated randomly.
• Maximum depth of the tree: The training algorithm attempts to split each node while its depth is smaller than
the maximum possible depth of the tree. The actual depth may be smaller if the other termination criteria are
met, and/or if the tree is pruned.
• Artificial Neural Network classifier: This group of parameters allows setting Artificial Neural Network classi-
fier parameters. See complete documentation here url{http://docs.opencv.org/modules/ml/doc/neural_networks.
html}.
• Train Method Type: Type of training method for the multilayer perceptron (MLP) neural network.
Available choices are:
• Back-propagation algorithm: Method to compute the gradient of the loss function and adjust
weights in the network to optimize the result.
• Resilient Back-propagation algorithm: Almost the same as the Back-prop algorithm except that
it does not take into account the magnitude of the partial derivative (coordinate of the gradient) but
only its sign.
• Number of neurons in each intermediate layer: The number of neurons in each intermediate layer
(excluding input and output layers).
• Neuron activation function type: This function determine whether the output of the node is positive
or not depending on the output of the transfert function. Available choices are:
• Identity function
• Symmetrical Sigmoid function
• Gaussian function (Not completely supported)
• Alpha parameter of the activation function: Alpha parameter of the activation function (used only
with sigmoid and gaussian functions).
• Beta parameter of the activation function: Beta parameter of the activation function (used only
with sigmoid and gaussian functions).
• Strength of the weight gradient term in the BACKPROP method: Strength of the weight gradient
term in the BACKPROP method. The recommended value is about 0.1.
• Strength of the momentum term (the difference between weights on the 2 previous iterations):
Strength of the momentum term (the difference between weights on the 2 previous iterations). This
parameter provides some inertia to smooth the random fluctuations of the weights. It can vary from
0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough.
• Initial value Delta_0 of update-values Delta_{ij} in RPROP method: Initial value Delta_0 of
update-values Delta_{ij} in RPROP method (default = 0.1).
• Update-values lower limit Delta_{min} in RPROP method: Update-values lower limit
Delta_{min} in RPROP method. It must be positive (default = 1e-7).
• Termination criteria: Termination criteria. Available choices are:
• Maximum number of iterations: Set the number of iterations allowed to the network for its train-
ing. Training will stop regardless of the result when this number is reached.
• Epsilon: Training will focus on result and will stop once the precision isat most epsilon.
• Max. iterations + Epsilon: Both termination criteria are used. Training stop at the first reached.
• Epsilon value used in the Termination criteria: Epsilon value used in the Termination criteria.
• Maximum number of iterations used in the Termination criteria: Maximum number of iterations
used in the Termination criteria.
• Normal Bayes classifier: Use a Normal Bayes Classifier. See complete documentation here url{http://docs.
opencv.org/modules/ml/doc/normal_bayes_classifier.html}.
• Random forests classifier: This group of parameters allows setting Random Forests classifier parameters. See
complete documentation here url{http://docs.opencv.org/modules/ml/doc/random_trees.html}.
• Maximum depth of the tree: The depth of the tree. A low value will likely underfit and conversely a high value
will likely overfit. The optimal value can be obtained using cross validation or other suitable methods.
• Minimum number of samples in each node: If the number of samples in a node is smaller than this parameter,
then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.
• Termination Criteria for regression tree: If all absolute differences between an estimated value in a node and
the values of the train samples in this node are smaller than this regression accuracy parameter, then the node
will not be split.
• Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split: Cluster
possible values of a categorical variable into K <= cat clusters to find a suboptimal split.
• Size of the randomly selected subset of features at each tree node: The size of the subset of features, ran-
domly selected at each tree node, that are used to find the best split(s). If you set it to 0, then the size will be set
to the square root of the total number of features.
• Maximum number of trees in the forest: The maximum number of trees in the forest. Typically, the more
trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches
an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the
prediction time linearly.
• Sufficient accuracy (OOB error): Sufficient accuracy (OOB error).
• KNN classifier: This group of parameters allows setting KNN classifier parameters. See complete documenta-
tion here url{http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html}.
• Number of Neighbors: The number of neighbors to use.
• Shark Random forests classifier: This group of parameters allows setting Shark Random Forests classifier
parameters. See complete documentation here url{http://image.diku.dk/shark/doxygen_pages/html/classshark_
1_1_r_f_trainer.html}. It is noteworthy that training is parallel.
• Maximum number of trees in the forest: The maximum number of trees in the forest. Typically, the more
trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches
an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the
prediction time linearly.
• Min size of the node for a split: If the number of samples in a node is smaller than this parameter, then the
node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.
• Number of features tested at each node: The number of features (variables) which will be tested at each node
in order to compute the split. If set to zero, the square root of the number of features is used.
• Out of bound ratio: Set the fraction of the original training dataset to use as the out of bag sample.A good
default value is 0.66. .
• Shark kmeans classifier: This group of parameters allows setting Shark kMeans classifier parameters. See
complete documentation here url{http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/
algorithms/kmeans.html}. .
• Maximum number of iteration for the kmeans algorithm.: The maximum number of iteration for the kmeans
algorithm. 0=unlimited.
• The number of class used for the kmeans algorithm.: The number of class used for the kmeans algorithm.
Default set to 2 class.
set user defined seed: Set specific seed. with integer value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
˓→svmConfusionMatrixQB1.csv
To run this example from Python, use the following code snippet:
#!/usr/bin/python
TrainImagesClassifier.SetParameterStringList("io.vd", ['VectorData_QB1.shp'])
TrainImagesClassifier.SetParameterString("io.imstat", "EstimateImageStatisticsQB1.xml
˓→")
TrainImagesClassifier.SetParameterInt("sample.mv", 100)
TrainImagesClassifier.SetParameterInt("sample.mt", 100)
TrainImagesClassifier.SetParameterFloat("sample.vtr", 0.5)
Limitations
None
Authors
See Also
Detailed description
This application trains a classifier from multiple input images or a csv file, in order to perform regression. Predictors are compo
The output value for each predictor is assumed to be the last band (or the last column for CSV files). Training
and validation predictor lists are built such that their size is inferior to maximum bounds given by the user, and
the proportion corresponds to the balance parameter. Several classifier parameters can be set depending on the
chosen classifier. In the validation process, the mean square error is computed between the ground truth and the
estimated model. This application is based on LibSVM and on OpenCV Machine Learning classifiers, and is
compatible with OpenCV 2.3.1 and later.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
TrainRegression .
[Input and output data]: This group of parameters allows setting input and output data.
• Input Image List: A list of input images. First (n-1) bands should contain the predictor. The last band should
contain the output value to predict.
• Input CSV file: Input CSV file containing the predictors, and the output values in last column. Only used when
no input image is given.
• Input XML image statistics file: Input XML file containing the mean and the standard deviation of the input
images.
• Output regression model: Output file containing the model estimated (.txt format).
• Mean Square Error: Mean square error computed with the validation predictors.
[Training and validation samples parameters]: This group of parameters allows you to set training and validation
sample lists parameters.
• Maximum training predictors: Maximum number of training predictors (default = 1000) (no limit = -1).
• Maximum validation predictors: Maximum number of validation predictors (default = 1000) (no limit = -1).
• Training and validation sample ratio: Ratio between training and validation samples (0.0 = all training, 1.0 =
all validation) (default = 0.5).
Classifier to use for the training: Choice of the classifier to use for the training. Available choices are:
• LibSVM classifier: This group of parameters allows setting SVM classifier parameters.
• SVM Kernel Type: SVM Kernel Type. Available choices are:
• Linear: Linear Kernel, no mapping is done, this is the fastest option.
• Gaussian radial basis function: This kernel is a good choice in most of the case. It is an exponential
function of the euclidian distance between the vectors.
• Polynomial: Polynomial Kernel, the mapping is a polynomial function.
• Sigmoid: The kernel is a hyperbolic tangente function of the vectors.
• SVM Model Type: Type of SVM formulation. Available choices are:
• Epsilon Support Vector Regression: The distance between feature vectors from the training set
and the fitting hyper-plane must be less than Epsilon. For outliers the penalty multiplier C is used .
• Nu Support Vector Regression: Same as the epsilon regression except that this time the bounded
parameter nu is used instead of epsilon.
• Cost parameter C: SVM models have a cost parameter C (1 by default) to control the trade-off
between training errors and forcing rigid margins.
• Cost parameter Nu: Cost parameter Nu, in the range 0..1, the larger the value, the smoother the
decision.
• Parameters optimization: SVM parameters optimization flag.
• Resilient Back-propagation algorithm: Almost the same as the Back-prop algorithm except that
it does not take into account the magnitude of the partial derivative (coordinate of the gradient) but
only its sign.
• Number of neurons in each intermediate layer: The number of neurons in each intermediate layer
(excluding input and output layers).
• Neuron activation function type: This function determine whether the output of the node is positive
or not depending on the output of the transfert function. Available choices are:
• Identity function
• Symmetrical Sigmoid function
• Gaussian function (Not completely supported)
• Alpha parameter of the activation function: Alpha parameter of the activation function (used only
with sigmoid and gaussian functions).
• Beta parameter of the activation function: Beta parameter of the activation function (used only
with sigmoid and gaussian functions).
• Strength of the weight gradient term in the BACKPROP method: Strength of the weight gradient
term in the BACKPROP method. The recommended value is about 0.1.
• Strength of the momentum term (the difference between weights on the 2 previous iterations):
Strength of the momentum term (the difference between weights on the 2 previous iterations). This
parameter provides some inertia to smooth the random fluctuations of the weights. It can vary from
0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough.
• Initial value Delta_0 of update-values Delta_{ij} in RPROP method: Initial value Delta_0 of
update-values Delta_{ij} in RPROP method (default = 0.1).
• Update-values lower limit Delta_{min} in RPROP method: Update-values lower limit
Delta_{min} in RPROP method. It must be positive (default = 1e-7).
• Termination criteria: Termination criteria. Available choices are:
• Maximum number of iterations: Set the number of iterations allowed to the network for its train-
ing. Training will stop regardless of the result when this number is reached.
• Epsilon: Training will focus on result and will stop once the precision isat most epsilon.
• Max. iterations + Epsilon: Both termination criteria are used. Training stop at the first reached.
• Epsilon value used in the Termination criteria: Epsilon value used in the Termination criteria.
• Maximum number of iterations used in the Termination criteria: Maximum number of iterations
used in the Termination criteria.
• Random forests classifier: This group of parameters allows setting Random Forests classifier parameters. See
complete documentation here url{http://docs.opencv.org/modules/ml/doc/random_trees.html}.
• Maximum depth of the tree: The depth of the tree. A low value will likely underfit and conversely a high value
will likely overfit. The optimal value can be obtained using cross validation or other suitable methods.
• Minimum number of samples in each node: If the number of samples in a node is smaller than this parameter,
then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.
• Termination Criteria for regression tree: If all absolute differences between an estimated value in a node and
the values of the train samples in this node are smaller than this regression accuracy parameter, then the node
will not be split.
• Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split: Cluster
possible values of a categorical variable into K <= cat clusters to find a suboptimal split.
• Size of the randomly selected subset of features at each tree node: The size of the subset of features, ran-
domly selected at each tree node, that are used to find the best split(s). If you set it to 0, then the size will be set
to the square root of the total number of features.
• Maximum number of trees in the forest: The maximum number of trees in the forest. Typically, the more
trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches
an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the
prediction time linearly.
• Sufficient accuracy (OOB error): Sufficient accuracy (OOB error).
• KNN classifier: This group of parameters allows setting KNN classifier parameters. See complete documenta-
tion here url{http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html}.
• Number of Neighbors: The number of neighbors to use.
• Decision rule: Decision rule for regression output. Available choices are:
• Mean of neighbors values: Returns the mean of neighbors values.
• Median of neighbors values: Returns the median of neighbors values.
• Shark Random forests classifier: This group of parameters allows setting Shark Random Forests classifier
parameters. See complete documentation here url{http://image.diku.dk/shark/doxygen_pages/html/classshark_
1_1_r_f_trainer.html}. It is noteworthy that training is parallel.
• Maximum number of trees in the forest: The maximum number of trees in the forest. Typically, the more
trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches
an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the
prediction time linearly.
• Min size of the node for a split: If the number of samples in a node is smaller than this parameter, then the
node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.
• Number of features tested at each node: The number of features (variables) which will be tested at each node
in order to compute the split. If set to zero, the square root of the number of features is used.
• Out of bound ratio: Set the fraction of the original training dataset to use as the out of bag sample.A good
default value is 0.66. .
• Shark kmeans classifier: This group of parameters allows setting Shark kMeans classifier parameters. See
complete documentation here url{http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/
algorithms/kmeans.html}. .
• Maximum number of iteration for the kmeans algorithm.: The maximum number of iteration for the kmeans
algorithm. 0=unlimited.
• The number of class used for the kmeans algorithm.: The number of class used for the kmeans algorithm.
Default set to 2 class.
set user defined seed: Set specific seed. with integer value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
TrainRegression.SetParameterString("io.out", "regression_model.txt")
TrainRegression.SetParameterString("io.imstat", "training_statistics.xml")
TrainRegression.SetParameterString("classifier","libsvm")
Limitations
None
Authors
See Also
Detailed description
This application trains a classifier based on labeled geometries and a list of features to consider for classification.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
TrainVectorClassifier .
[Input and output data]: This group of parameters allows setting input and output data.
• Input Vector Data: Input geometries used for training (note : all geometries from the layer will be used).
• Input XML image statistics file: XML file containing mean and variance of each feature.
• Output model: Output file containing the model estimated (.txt format).
• Output confusion matrix or contingency table: Output file containing the confusion matrix or contingency
table (.csv format).The contingency table is output when we unsupervised algorithms is used otherwise the
confusion matrix is output.
Layer Index: Index of the layer to use in the input vector file.
Field names for training features.: List of field names in the input vector data to be used as features for training.
[Validation data]: This group of parameters defines validation data.
• Validation Vector Data: Geometries used for validation (must contain the same fields used for training, all
geometries from the layer will be used).
• Layer Index: Index of the layer to use in the validation vector file.
Field containing the class integer label for supervision: Field containing the class id for supervision. The values in
this field shall be cast into integers. Only geometries with this field available will be taken into account.
Verbose mode: Verbose mode, display the contingency table result.
• Validation Vector Data: Geometries used for validation (must contain the same fields used for training, all
geometries from the layer will be used).
• Layer Index: Index of the layer to use in the validation vector file.
Classifier to use for the training: Choice of the classifier to use for the training. Available choices are:
• LibSVM classifier: This group of parameters allows setting SVM classifier parameters.
• SVM Kernel Type: SVM Kernel Type. Available choices are:
• Linear: Linear Kernel, no mapping is done, this is the fastest option.
• Gaussian radial basis function: This kernel is a good choice in most of the case. It is an exponential
function of the euclidian distance between the vectors.
• Polynomial: Polynomial Kernel, the mapping is a polynomial function.
• Sigmoid: The kernel is a hyperbolic tangente function of the vectors.
• SVM Model Type: Type of SVM formulation. Available choices are:
• C support vector classification: This formulation allows imperfect separation of classes. The
penalty is set through the cost parameter C.
• Nu support vector classification: This formulation allows imperfect separation of classes. The
penalty is set through the cost parameter Nu. As compared to C, Nu is harder to optimize, and may
not be as fast.
• Distribution estimation (One Class SVM): All the training data are from the same class, SVM
builds a boundary that separates the class from the rest of the feature space.
• Cost parameter C: SVM models have a cost parameter C (1 by default) to control the trade-off
between training errors and forcing rigid margins.
• Cost parameter Nu: Cost parameter Nu, in the range 0..1, the larger the value, the smoother the
decision.
• Parameters optimization: SVM parameters optimization flag.
• Probability estimation: Probability estimation flag.
• Boost classifier: This group of parameters allows setting Boost classifier parameters. See complete documen-
tation here url{http://docs.opencv.org/modules/ml/doc/boosting.html}.
• Boost Type: Type of Boosting algorithm. Available choices are:
• Discrete AdaBoost: This procedure trains the classifiers on weighted versions of the training sam-
ple, giving higher weight to cases that are currently misclassified. This is done for a sequence of
weighter samples, and then the final classifier is defined as a linear combination of the classifier from
each stage.
• Real AdaBoost (technique using confidence-rated predictions and working well with categori-
cal data): Adaptation of the Discrete Adaboost algorithm with Real value.
• LogitBoost (technique producing good regression fits): This procedure is an adaptive Newton
algorithm for fitting an additive logistic regression model. Beware it can produce numeric instability.
• Gentle AdaBoost (technique setting less weight on outlier data points and, for that reason,
being often good with regression data): A modified version of the Real Adaboost algorithm, using
Newton stepping rather than exact optimization at each step.
• Weak count: The number of weak classifiers.
• Weight Trim Rate: A threshold between 0 and 1 used to save computational time. Samples with
summary weight <= (1 - weight_trim_rate) do not participate in the next iteration of training. Set
this parameter to 0 to turn off this functionality.
• Maximum depth of the tree: Maximum depth of the tree.
• Decision Tree classifier: This group of parameters allows setting Decision Tree classifier parameters. See
complete documentation here url{http://docs.opencv.org/modules/ml/doc/decision_trees.html}.
• Maximum depth of the tree: The training algorithm attempts to split each node while its depth is smaller than
the maximum possible depth of the tree. The actual depth may be smaller if the other termination criteria are
met, and/or if the tree is pruned.
• Minimum number of samples in each node: If the number of samples in a node is smaller than this parameter,
then this node will not be split.
• Termination criteria for regression tree: If all absolute differences between an estimated value in a node and
the values of the train samples in this node are smaller than this regression accuracy parameter, then the node
will not be split further.
• Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split: Cluster
possible values of a categorical variable into K <= cat clusters to find a suboptimal split.
• K-fold cross-validations: If cv_folds > 1, then it prunes a tree with K-fold cross-validation where K is equal to
cv_folds.
• Set Use1seRule flag to false: If true, then a pruning will be harsher. This will make a tree more compact and
more resistant to the training data noise but a bit less accurate.
• Set TruncatePrunedTree flag to false: If true, then pruned branches are physically removed from the tree.
• Gradient Boosted Tree classifier: This group of parameters allows setting Gradient Boosted Tree classifier
parameters. See complete documentation here url{http://docs.opencv.org/modules/ml/doc/gradient_boosted_
trees.html}.
• Number of boosting algorithm iterations: Number “w” of boosting algorithm iterations, with w*K being the
total number of trees in the GBT model, where K is the output number of classes.
• Regularization parameter: Regularization parameter.
• Portion of the whole training set used for each algorithm iteration: Portion of the whole training set used
for each algorithm iteration. The subset is generated randomly.
• Maximum depth of the tree: The training algorithm attempts to split each node while its depth is smaller than
the maximum possible depth of the tree. The actual depth may be smaller if the other termination criteria are
met, and/or if the tree is pruned.
• Artificial Neural Network classifier: This group of parameters allows setting Artificial Neural Network classi-
fier parameters. See complete documentation here url{http://docs.opencv.org/modules/ml/doc/neural_networks.
html}.
• Train Method Type: Type of training method for the multilayer perceptron (MLP) neural network.
Available choices are:
• Back-propagation algorithm: Method to compute the gradient of the loss function and adjust
weights in the network to optimize the result.
• Resilient Back-propagation algorithm: Almost the same as the Back-prop algorithm except that
it does not take into account the magnitude of the partial derivative (coordinate of the gradient) but
only its sign.
• Number of neurons in each intermediate layer: The number of neurons in each intermediate layer
(excluding input and output layers).
• Neuron activation function type: This function determine whether the output of the node is positive
or not depending on the output of the transfert function. Available choices are:
• Identity function
• Symmetrical Sigmoid function
• Gaussian function (Not completely supported)
• Alpha parameter of the activation function: Alpha parameter of the activation function (used only
with sigmoid and gaussian functions).
• Beta parameter of the activation function: Beta parameter of the activation function (used only
with sigmoid and gaussian functions).
• Strength of the weight gradient term in the BACKPROP method: Strength of the weight gradient
term in the BACKPROP method. The recommended value is about 0.1.
• Strength of the momentum term (the difference between weights on the 2 previous iterations):
Strength of the momentum term (the difference between weights on the 2 previous iterations). This
parameter provides some inertia to smooth the random fluctuations of the weights. It can vary from
0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough.
• Initial value Delta_0 of update-values Delta_{ij} in RPROP method: Initial value Delta_0 of
update-values Delta_{ij} in RPROP method (default = 0.1).
• Update-values lower limit Delta_{min} in RPROP method: Update-values lower limit
Delta_{min} in RPROP method. It must be positive (default = 1e-7).
• Termination criteria: Termination criteria. Available choices are:
• Maximum number of iterations: Set the number of iterations allowed to the network for its train-
ing. Training will stop regardless of the result when this number is reached.
• Epsilon: Training will focus on result and will stop once the precision isat most epsilon.
• Max. iterations + Epsilon: Both termination criteria are used. Training stop at the first reached.
• Epsilon value used in the Termination criteria: Epsilon value used in the Termination criteria.
• Maximum number of iterations used in the Termination criteria: Maximum number of iterations
used in the Termination criteria.
• Normal Bayes classifier: Use a Normal Bayes Classifier. See complete documentation here url{http://docs.
opencv.org/modules/ml/doc/normal_bayes_classifier.html}.
• Random forests classifier: This group of parameters allows setting Random Forests classifier parameters. See
complete documentation here url{http://docs.opencv.org/modules/ml/doc/random_trees.html}.
• Maximum depth of the tree: The depth of the tree. A low value will likely underfit and conversely a high value
will likely overfit. The optimal value can be obtained using cross validation or other suitable methods.
• Minimum number of samples in each node: If the number of samples in a node is smaller than this parameter,
then the node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.
• Termination Criteria for regression tree: If all absolute differences between an estimated value in a node and
the values of the train samples in this node are smaller than this regression accuracy parameter, then the node
will not be split.
• Cluster possible values of a categorical variable into K <= cat clusters to find a suboptimal split: Cluster
possible values of a categorical variable into K <= cat clusters to find a suboptimal split.
• Size of the randomly selected subset of features at each tree node: The size of the subset of features, ran-
domly selected at each tree node, that are used to find the best split(s). If you set it to 0, then the size will be set
to the square root of the total number of features.
• Maximum number of trees in the forest: The maximum number of trees in the forest. Typically, the more
trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches
an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the
prediction time linearly.
• Sufficient accuracy (OOB error): Sufficient accuracy (OOB error).
• KNN classifier: This group of parameters allows setting KNN classifier parameters. See complete documenta-
tion here url{http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html}.
• Number of Neighbors: The number of neighbors to use.
• Shark Random forests classifier: This group of parameters allows setting Shark Random Forests classifier
parameters. See complete documentation here url{http://image.diku.dk/shark/doxygen_pages/html/classshark_
1_1_r_f_trainer.html}. It is noteworthy that training is parallel.
• Maximum number of trees in the forest: The maximum number of trees in the forest. Typically, the more
trees you have, the better the accuracy. However, the improvement in accuracy generally diminishes and reaches
an asymptote for a certain number of trees. Also to keep in mind, increasing the number of trees increases the
prediction time linearly.
• Min size of the node for a split: If the number of samples in a node is smaller than this parameter, then the
node will not be split. A reasonable value is a small percentage of the total data e.g. 1 percent.
• Number of features tested at each node: The number of features (variables) which will be tested at each node
in order to compute the split. If set to zero, the square root of the number of features is used.
• Out of bound ratio: Set the fraction of the original training dataset to use as the out of bag sample.A good
default value is 0.66. .
• Shark kmeans classifier: This group of parameters allows setting Shark kMeans classifier parameters. See
complete documentation here url{http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/
algorithms/kmeans.html}. .
• Maximum number of iteration for the kmeans algorithm.: The maximum number of iteration for the kmeans
algorithm. 0=unlimited.
• The number of class used for the kmeans algorithm.: The number of class used for the kmeans algorithm.
Default set to 2 class.
set user defined seed: Set specific seed. with integer value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
TrainVectorClassifier.SetParameterString("io.stats", "meanVar.xml")
TrainVectorClassifier.SetParameterString("io.out", "svmModel.svm")
Authors
Detailed description
This application performs a vector data classification based on a model file produced by the TrainVectorClassifier
application.Features of the vector data output will contain the class labels decided by the classifier (maximal class
label = 65535). There are two modes: 1) Update mode: add of the ‘cfield’ field containing the predicted class in
the input file. 2) Write mode: copies the existing fields of the input file in the output file and add the ‘cfield’ field
containing the predicted class. If you have declared the output file, the write mode applies. Otherwise, the input file
update mode will be applied.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VectorClassifier .
1 Table: Parameters table for Vector Classification.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorClassifier.SetParameterString("in", "vectorData.shp")
VectorClassifier.SetParameterString("instat", "meanVar.xml")
VectorClassifier.SetParameterString("model", "svmModel.svm")
VectorClassifier.SetParameterString("out", "vectorDataLabeledVector.shp")
Limitations
Shapefiles are supported. But the SQLite format is only supported in update mode.
Authors
See Also
Performs dimensionality reduction of the input vector data according to a model file.
Detailed description
This application performs a vector data dimensionality reduction based on a model file produced by the TrainDimen-
sionalityReduction application.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VectorDimensionalityReduction .
1 Table: Parameters table for Vector Dimensionality Reduction.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorDimensionalityReduction = otbApplication.Registry.CreateApplication(
˓→"VectorDimensionalityReduction")
VectorDimensionalityReduction.SetParameterString("instat", "meanVar.xml")
VectorDimensionalityReduction.SetParameterString("model", "model.txt")
VectorDimensionalityReduction.SetParameterString("out", "vectorDataOut.shp")
Limitations
None
Authors
See Also
Image Manipulation
Detailed description
This application allows one to map a label image to a 8-bits RGB image (in both ways) using different methods.
-The custom method allows one to use a custom look-up table. The look-up table is loaded from a text file where
each line describes an entry. The typical use of this method is to colorise a classification map. -The continuous
method allows mapping a range of values in a scalar input image to a colored image using continuous look-up
table, in order to enhance image interpretation. Several look-up tables can been chosen with different color
ranges.
-The optimal method computes an optimal look-up table. When processing a segmentation label image (label to color), the color
• The support image method uses a color support image to associate an average color to each region.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ColorMapping .
• Compute an optimized look-up table: [label to color] Compute an optimal look-up table such that neighboring
labels in a segmentation are mapped to highly contrasted colors. [color to label] Searching all the colors present
in the image to compute a continuous label list.
• Background label: Value of the background label.
• Color mapping with look-up table calculated on support image
• Support Image: Support image filename. For each label, the LUT is calculated from the mean pixel value in the
support image, over the corresponding labeled areas. First of all, the support image is normalized with extrema
rejection.
• NoData value: NoData value for each channel of the support image, which will not be handled in the LUT
estimation. If NOT checked, ALL the pixel values of the support image will be handled in the LUT estimation.
• lower quantile: lower quantile for image normalization.
• upper quantile: upper quantile for image normalization.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
˓→MUL_1_SVN_CLASS_MULTI.tif
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ColorMapping.SetParameterString("method","custom")
ColorMapping.SetParameterString("method.custom.lut", "ROI_QB_MUL_1_SVN_CLASS_MULTI_
˓→PNG_ColorTable.txt")
ColorMapping.SetParameterString("out", "Colorized_ROI_QB_MUL_1_SVN_CLASS_MULTI.tif")
Limitations
The segmentation optimal method does not support streaming, and thus large images. The operation color to label is not implem
ColorMapping using support image is not threaded.
Authors
See Also
Concatenate a list of images of the same size into a single multi-channel one.
Detailed description
This application performs images channels concatenation. It reads the input image list (single or multi-channel) and
generates a single multi-channel image. The channel order is the same as the list.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ConcatenateImages .
Parameter Key Parameter Name Parameter Type
il Input images list Input image list
out Output Image Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input images list: The list of images to concatenate, must have the same size.
• Output Image: The concatenated output image.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for Images Concatenation.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ConcatenateImages.SetParameterString("out", "otbConcatenateImages.tif")
Limitations
Authors
See Also
Converts a geo-referenced DEM image into a general raster file compatible with OTB DEM handling.
Detailed description
In order to be understood by the Orfeo ToolBox and the underlying OSSIM library, a geo-referenced Digital Elevation
Model image can be converted into a general raster image, which consists in 3 files with the following extensions:
.ras, .geom and .omd. Once converted, you have to place these files in a separate directory, and you can then use this
directory to set the “DEM Directory” parameter of a DEM based OTB application or filter.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DEMConvert .
Parameter Key Parameter Name Parameter Type
in Input geo-referenced DEM Input image
out Prefix of the output files Output File name
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input geo-referenced DEM: Input geo-referenced DEM to convert to general raster format.
• Prefix of the output files: will be used to get the prefix (name withtout extensions) of the files to write. Three
files - prefix.geom, prefix.omd and prefix.ras - will be generated.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DEMConvert.SetParameterString("out", "outputDEM")
Limitations
None
Authors
Detailed description
This application allows selecting the appropriate SRTM tiles that covers a list of images. It builds a list of the required
tiles. Two modes are available: the first one download those tiles from the USGS SRTM3 website (http://dds.cr.usgs.
gov/srtm/version2_1/SRTM3/), the second one list those tiles in a local directory. In both cases, you need to indicate
the directory in which directory tiles will be download or the location of local SRTM files.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DownloadSRTMTiles .
Parameter Key Parameter Name Parameter Type
il Input images list Input image list
vl Input vector data list Input vector data list
names Input tile names String list
tiledir Tiles directory Directory
mode Download/List corresponding SRTM tiles. Choices
mode download Download Choice
mode list List tiles Choice
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input images list: List of images on which you want to determine corresponding SRTM tiles.
• Input vector data list: List of vector data files on which you want to determine corresponding SRTM tiles.
• Input tile names: List of SRTM tile names to download. This list is added to the tiles derived from input images
or vectors.The names should follow the SRTM tile naming convention, for instance N43E001.
• Tiles directory: Directory where SRTM tiles are stored. In download mode, the zipped archives will be down-
loaded to this directory. You’ll need to unzip all tile files before using them in your application. In any case, this
directory will be inspected to check which tiles are already downloaded.
• Download/List corresponding SRTM tiles. Available choices are:
• Download: Download corresponding tiles on USGE server.
• List tiles: List tiles in an existing local directory.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
1 Table: Parameters table for Download or list SRTM tiles related to a set of images.
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DownloadSRTMTiles.SetParameterString("mode","list")
DownloadSRTMTiles.SetParameterString("tiledir", "/home/user/srtm_dir/")
Limitations
None
Authors
Detailed description
This application performs an image pixel type conversion (short, ushort, uchar, int, uint, float and double types are handled). Th
The conversion can include a rescale of the data range, by default it’s set between the 2nd to the 98th percentile.
The rescale can be linear or log2. The choice of the output channels can be done with the extended filename,
but less easy to handle. To do this, a ‘channels’ parameter allows you to select the desired bands at the output.
There are 3 modes, the available choices are: * grayscale : to display mono image as standard color image *
rgb : select 3 bands in the input image (multi-bands) * all : keep all bands.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DynamicConvert .
1 Table: Parameters table for Dynamic Conversion.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DynamicConvert.SetParameterString("out", "otbConvertWithScalingOutput.png")
DynamicConvert.SetParameterString("type","linear")
DynamicConvert.SetParameterString("channels","rgb")
DynamicConvert.SetParameterFloat("outmin", 0)
DynamicConvert.SetParameterFloat("outmax", 255)
Limitations
None
Authors
See Also
Detailed description
This application extracts a Region Of Interest with user parameters. There are four mode of extraction. The standard
mode allows the user to enter one point (upper left corner of the region to extract) and a size. The extent mode needs
two points (upper left corner and lower right) and the radius mode need the center of the region and the radius : it will
extract the rectangle containing the circle defined and limited by the image dimension. The fit mode needs a reference
image or vector and the dimension of the extracted region will be the same as the extent of the reference. Different
units are available such as pixel, image physical space or longitude and latitude.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ExtractROI .
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ExtractROI.SetParameterString("mode","extent")
ExtractROI.SetParameterFloat("mode.extent.ulx", 40)
ExtractROI.SetParameterFloat("mode.extent.uly", 40)
ExtractROI.SetParameterFloat("mode.extent.lrx", 150)
ExtractROI.SetParameterFloat("mode.extent.lry", 150)
ExtractROI.SetParameterString("out", "ExtractROI.tif")
Limitations
None
Authors
Manage No-Data
Detailed description
This application has two modes. The first allows building a mask of no-data pixels from the no-data flags read from
the image file. The second allows updating the change the no-data value of an image (pixels value and metadata). This
last mode also allows replacing NaN in images with a proper no-data value. To do so, one should activate the NaN is
no-data option.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ManageNoData .
1 Table: Parameters table for No Data management.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ManageNoData.SetParameterString("out", "QB_Toulouse_Ortho_XS_nodatamask.tif")
ManageNoData.SetParameterOutputImagePixelType("out", 1)
ManageNoData.SetParameterFloat("mode.buildmask.inv", 255)
ManageNoData.SetParameterFloat("mode.buildmask.outv", 0)
Limitations
None
Authors
See Also
Detailed description
This application builds a multi-resolution pyramid of the input image. User can specified the number of levels of the
pyramid and the subsampling factor. To speed up the process, you can use the fast scheme option
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MultiResolutionPyramid .
1 Table: Parameters table for Multi Resolution Pyramid.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MultiResolutionPyramid.SetParameterString("out", "multiResolutionImage.tif")
MultiResolutionPyramid.SetParameterInt("level", 1)
MultiResolutionPyramid.SetParameterInt("sfactor", 2)
MultiResolutionPyramid.SetParameterFloat("vfactor", 0.6)
MultiResolutionPyramid.SetParameterString("fast","false")
Limitations
None
Authors
Detailed description
Generates a subsampled version of an extract of an image defined by ROIStart and ROISize. This extract is
subsampled using the ratio OR the output image Size.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Quicklook .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
cl Channel List List
rox ROI Origin X Int
roy ROI Origin Y Int
rsx ROI Size X Int
rsy ROI Size Y Int
sr Sampling ratio Int
sx Size X Int
sy Size Y Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: The image to read.
• Output Image: The subsampled image.
• Channel List: Selected channels.
• ROI Origin X: first point of ROI in x-direction.
1 Table: Parameters table for Quick Look.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Quicklook.SetParameterString("out", "quicklookImage.tif")
Limitations
This application does not provide yet the optimal way to decode coarser level of resolution from JPEG2000 images
(like in Monteverdi). Trying to subsampled huge JPEG200 image with the application will lead to poor performances
for now.
Authors
Detailed description
Display information about the input image like: image size, origin, spacing, metadata, projections...
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ReadImageInfo .
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Limitations
None
Authors
Detailed description
This application splits a N-bands image into N mono-band images. The output images filename will be generated from
the output parameter. Thus, if the input image has 2 channels, and the user has set as output parameter, outimage.tif,
the generated images will be outimage_0.tif and outimage_1.tif.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SplitImage .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: Input multiband image filename.
• Output Image: The output filename will be used to get the prefix an the extension of the output written’s image.
For example with outimage.tif as output filename, the generated images will had an indice (corresponding at
each bands) between the prefix and the extension, such as: outimage_0.tif and outimage_1.tif (if 2 bands).
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SplitImage.SetParameterString("out", "splitImage.tif")
Limitations
None
Authors
See Also
Detailed description
Automatically mosaic a set of non overlapping tile files into a single image. Images must have a matching number of
bands and they must be listed in lexicographic order.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
TileFusion .
Parameter Key Parameter Name Parameter Type
il Input Tile Images Input image list
cols Number of tile columns Int
rows Number of tile rows Int
out Output Image Output image
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Tile Images: Input images to concatenate (in lexicographic order, for instance : (0,0) (1,0) (0,1) (1,1)).
• Number of tile columns: Number of columns in the tile array.
• Number of tile rows: Number of rows in the tile array.
• Output Image: Output entire image.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for Image Tile Fusion.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
TileFusion.SetParameterInt("cols", 2)
TileFusion.SetParameterInt("rows", 2)
TileFusion.SetParameterString("out", "EntireImage.tif")
Limitations
None
Authors
SAR
This application computes the modulus and the phase of a complex SAR image.
Detailed description
This application computes the modulus and the phase of a complex SAR image. The input should be a single band
image with complex pixels.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ComputeModulusAndPhase .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
modulus Modulus Output image
phase Phase Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: Input image (complex single band).
√
• Modulus: Modulus of the input image computes with the following formula: 𝑟𝑒𝑎𝑙𝑟𝑒𝑎𝑙 + 𝑖𝑚𝑎𝑔𝑖𝑚𝑎𝑔 where
real and imag are respectively the real and the imaginary part of the input complex image. .
• Phase: Phase of the input image computes with the following formula: tan−1 ( 𝑖𝑚𝑎𝑔
𝑟𝑒𝑎𝑙 ) where real and imag are
respectively the real and the imaginary part of the input complex image.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ComputeModulusAndPhase.SetParameterString("modulus", "modulus.tif")
ComputeModulusAndPhase.SetParameterString("phase", "phase.tif")
Limitations
The application takes as input single band image with complex pixels.
Authors
This application has been written by Alexia Mondot ([email protected]) and Mickael Savinaud
([email protected]).
See Also
This application performs deburst of Sentinel1 IW SLC images by removing redundant lines.
Detailed description
Sentinel1 IW SLC products are composed of several burst overlapping in azimuth time for each subswath, separated by
black lines [1]. The deburst operation consist in generating a continuous image in terms of azimuth time, by removing
black separation lines as well as redundant lines between bursts.
Note that the output sensor model is updated accordingly. This deburst operation is the perfect preprocessing step to
orthorectify S1 IW SLC product with OTB [2] without suffering from artifacts caused by bursts separation.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SARDeburst .
Parameter Key Parameter Name Parameter Type
in Input Sentinel1 IW SLC Image Input image
out Output Image Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Sentinel1 IW SLC Image: Raw Sentinel1 IW SLC image, or any extract of such made by OTB (geom
file needed).
• Output Image: Deburst image, with updated geom file that can be further used by Orthorectification applica-
tion. If the input image is a raw Sentinel1 product, uint16 output type should be used (encoding of S1 product).
Otherwise, output type should match type of input image.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
1 Table: Parameters table for SAR Deburst.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SARDeburst.SetParameterString("out", "s1_iw_slc_deburst.tif")
Limitations
Only Sentinel1 IW SLC products are supported for now. Processing of other Sentinel1 modes or TerrasarX images
will result in no changes in the image and metadata. Images from other sensors will lead to an error.
Authors
See Also
SARDecompositions - SARDecompositions
From one-band complex images (each one related to an element of the Sinclair matrix), returns the selected decompo-
sition.
Detailed description
From one-band complex images (HH, HV, VH, VV), returns the selected decomposition.
All the decompositions implemented are intended for the mono-static case (transmitter and receiver are co-located).
There are two kinds of decomposition : coherent ones and incoherent ones. In the coherent case, only the Pauli
decomposition is available. In the incoherent case, there the decompositions available : Huynen, Barnes, and H-alpha-
A. User must provide three one-band complex images HH, HV or VH, and VV (mono-static case <=> HV = VH).
Incoherent decompositions consist in averaging 3x3 complex coherency/covariance matrices; the user must provide
the size of the averaging window, thanks to the parameter inco.kernelsize.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SARDecompositions .
Parameter Key Parameter Name Parameter Type
inhh Input Image Input image
inhv Input Image Input image
invh Input Image Input image
invv Input Image Input image
out Output Image Output image
decomp Decompositions Choices
decomp haa H-alpha-A incoherent decomposition Choice
decomp barnes Barnes incoherent decomposition Choice
decomp huynen Huynen incoherent decomposition Choice
decomp pauli Pauli coherent decomposition Choice
inco Incoherent decompositions Group
inco.kernelsize Kernel size for spatial incoherent averaging. Int
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image (HH).
Input Image: Input image (HV).
Input Image: Input image (VH).
Input Image: Input image (VV).
Output Image: Output image.
Decompositions Available choices are:
• H-alpha-A incoherent decomposition: H-alpha-A incoherent decomposition.
• Barnes incoherent decomposition: Barnes incoherent decomposition.
• Huynen incoherent decomposition: Huynen incoherent decomposition.
• Pauli coherent decomposition: Pauli coherent decomposition.
[Incoherent decompositions]: This group allows setting parameters related to the incoherent decompositions.
• Kernel size for spatial incoherent averaging.: Minute (0-59).
1 Table: Parameters table for SARDecompositions.
Example
otbcli_SARDecompositions -inhh HH.tif -invh VH.tif -invv VV.tif -decomp haa -out HaA.
˓→tif
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SARDecompositions.SetParameterString("invh", "VH.tif")
SARDecompositions.SetParameterString("invv", "VV.tif")
SARDecompositions.SetParameterString("decomp","haa")
SARDecompositions.SetParameterString("out", "HaA.tif")
Limitations
Some decompositions output real images, while this application outputs complex images for general purpose. Users
should pay attention to extract the real part of the results provided by this application.
Authors
See Also
SARPolarMatrixConvert - SARPolarMatrixConvert
Detailed description
This application allows converting classical polarimetric matrices to each other. For instance, it is possible to get
the coherency matrix from the Sinclar one, or the Mueller matrix from the coherency one. The filters used in this
application never handle matrices, but images where each band is related to their elements. As most of the time
SAR polarimetry handles symmetric/hermitian matrices, only the relevant elements are stored, so that the images
representing them have a minimal number of bands. For instance, the coherency matrix size is 3x3 in the monostatic
case, and 4x4 in the bistatic case : it will thus be stored in a 6-band or a 10-band complex image (the diagonal and the
upper elements of the matrix).
The Sinclair matrix is a special case : it is always represented as 3 or 4 one-band complex images (for mono- or bistatic
case). The available conversions are listed below:
— Monostatic case — 1 msinclairtocoherency –> Sinclair matrix to coherency matrix (input : 3 x 1 complex channel
(HH, HV or VH, VV) | output : 6 complex channels) 2 msinclairtocovariance –> Sinclair matrix to covariance matrix
(input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels) 3 msinclairtocircovariance –>
Sinclair matrix to circular covariance matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex
channels) 4 mcoherencytomueller –> Coherency matrix to Mueller matrix (input : 6 complex channels | 16 real
channels) 5 mcovariancetocoherencydegree –> Covariance matrix to coherency degree (input : 6 complex channels | 3
complex channels) 6 mcovariancetocoherency –> Covariance matrix to coherency matrix (input : 6 complex channels
| 6 complex channels) 7 mlinearcovariancetocircularcovariance –> Covariance matrix to circular covariance matrix
(input : 6 complex channels | output : 6 complex channels)
— Bistatic case — 8 bsinclairtocoherency –> Sinclair matrix to coherency matrix (input : 4 x 1 complex channel (HH,
HV, VH, VV) | 10 complex channels) 9 bsinclairtocovariance –> Sinclair matrix to covariance matrix (input : 4 x 1
complex channel (HH, HV, VH, VV) | output : 10 complex channels) 10 bsinclairtocircovariance –> Sinclair matrix
to circular covariance matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 10 complex channels)
— Both cases — 11 sinclairtomueller –> Sinclair matrix to Mueller matrix (input : 4 x 1 complex channel (HH, HV,
VH, VV) | output : 16 real channels) 12 muellertomcovariance –> Mueller matrix to covariance matrix (input : 16 real
channels | output : 6 complex channels) 13 muellertopoldegandpower –> Mueller matrix to polarization degree and
power (input : 16 real channels | output : 4 real channels)
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SARPolarMatrixConvert .
1 Table: Parameters table for SARPolarMatrixConvert.
• 1 Monostatic : Sinclair matrix to coherency matrix (complex output): 1 Monostatic :Sinclair matrix to
coherency matrix (complex output).
• 2 Monostatic : Sinclair matrix to covariance matrix (complex output): 2 Monostatic : Sinclair matrix to
covariance matrix (complex output).
• 3 Monostatic : Sinclair matrix to circular covariance matrix (complex output): 3 Monostatic : Sinclair
matrix to circular covariance matrix (complex output).
• 4 Monostatic : Coherency matrix to Mueller matrix: 4 Monostatic : Coherency matrix to Mueller matrix.
• 5 Monostatic : Covariance matrix to coherency degree: 5 Monostatic : Covariance matrix to coherency
degree .
• 6 Monostatic : Covariance matrix to coherency matrix (complex output): 6 Monostatic : Covariance matrix
to coherency matrix (complex output).
• 7 Monostatic : Covariance matrix to circular covariance matrix (complex output): 7 Monostatic : Covari-
ance matrix to circular covariance matrix (complex output).
• 8 Bi/mono : Mueller matrix to monostatic covariance matrix: 8 Bi/mono : Mueller matrix to monostatic
covariance matrix.
• 9 Bistatic : Sinclair matrix to coherency matrix (complex output): 9 Bistatic : Sinclair matrix to coherency
matrix (complex output).
• 10 Bistatic : Sinclair matrix to covariance matrix (complex output): 10 Bistatic : Sinclair matrix to covari-
ance matrix (complex output).
• 11 Bistatic : Sinclair matrix to circular covariance matrix (complex output): 11 Bistatic : Sinclair matrix
to circular covariance matrix (complex output).
• 12 Bi/mono : Sinclair matrix to Mueller matrix: 12 Bi/mono : Sinclair matrix to Mueller matrix.
• 13 Bi/mono : Mueller matrix to polarisation degree and power: 13 Bi/mono : Mueller matrix to polarisation
degree and power.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SARPolarMatrixConvert.SetParameterString("inhh", "HH.tif")
SARPolarMatrixConvert.SetParameterString("invh", "VH.tif")
SARPolarMatrixConvert.SetParameterString("invv", "VV.tif")
SARPolarMatrixConvert.SetParameterString("conv","msinclairtocoherency")
SARPolarMatrixConvert.SetParameterString("outc", "mcoherency.tif")
Limitations
None
Authors
See Also
SARPolarSynth - SARPolarSynth
Gives, for each pixel, the power that would have been received by a SAR system with a basis different from the
classical (H,V) one (polarimetric synthetis).
Detailed description
This application gives, for each pixel, the power that would have been received by a SAR system with a basis different
from the classical (H,V) one (polarimetric synthetis). The new basis A and B are indicated through two Jones vectors,
defined by the user thanks to orientation (psi) and ellipticity (khi) parameters. These parameters are namely psii,
khii, psir and khir. The suffixes (i) and (r) refer to the transmitting antenna and the receiving antenna respectively.
Orientations and ellipticities are given in degrees, and are between -90/90 degrees and -45/45 degrees respectively.
Four polarization architectures can be processed :
1. HH_HV_VH_VV : full polarization, general bistatic case.
2. HH_HV_VV or HH_VH_VV : full polarization, monostatic case (transmitter and receiver are co-located).
3. HH_HV : dual polarization.
4. VH_VV : dual polarization.
The application takes a complex vector image as input, where each band correspond to a particular emission/reception
polarization scheme. User must comply with the band order given above, since the bands are used to build the Sinclair
matrix.
In order to determine the architecture, the application first relies on the number of bands of the input image.
1. Architecture HH_HV_VH_VV is the only one with four bands, there is no possible confusion.
2. Concerning HH_HV_VV and HH_VH_VV architectures, both correspond to a three channels image. But they
are processed in the same way, as the Sinclair matrix is symmetric in the monostatic case.
3. Finally, the two last architectures (dual polarizations), can’t be distinguished only by the number of bands of
the input image. User must then use the parameters emissionh and emissionv to indicate the architecture of the
system : emissionh=1 and emissionv=0 –> HH_HV, emissionh=0 and emissionv=1 –> VH_VV.
Note : if the architecture is HH_HV, khii and psii are automatically both set to 0 degree; if the architecture is VH_VV,
khii and psii are automatically set to 0 degree and 90 degrees respectively.
It is also possible to force the calculation to co-polar or cross-polar modes. In the co-polar case, values for psir and
khir will be ignored and forced to psii and khii; same as the cross-polar mode, where khir and psir will be forced to
(psii + 90 degrees) and -khii.
Finally, the result of the polarimetric synthetis is expressed in the power domain, through a one-band scalar image.
Note: this application doesn’t take into account the terms which do not depend on the polarization of the antennas.
The parameter gain can be used for this purpose.
More details can be found in the OTB CookBook (SAR processing chapter).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SARPolarSynth .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
psii psii Float
khii khii Float
psir psir Float
khir khir Float
emissionh Emission H Int
emissionv Emission V Int
mode Forced mode Choices
mode none None Choice
mode co Copolarization Choice
mode cross Crosspolarization Choice
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: Input image.
• Output Image: Output image.
• psii: Orientation (transmitting antenna).
• khii: Ellipticity (transmitting antenna).
• psir: Orientation (receiving antenna).
• khir: Ellipticity (receiving antenna).
1 Table: Parameters table for SARPolarSynth.
• Emission H: This parameter is useful in determining the polarization architecture (dual polarization case).
• Emission V: This parameter is useful in determining the polarization architecture (dual polarization case).
• Forced mode Available choices are:
• None: Copolarization.
• Copolarization
• Crosspolarization: Crosspolarization.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
otbcli_SARPolarSynth -in sar.tif -psii 15. -khii 5. -psir -25. -khir 10. -out
˓→newbasis.tif
To run this example from Python, use the following code snippet:
#!/usr/bin/python
SARPolarSynth.SetParameterFloat("psii", 15.)
SARPolarSynth.SetParameterFloat("khii", 5.)
SARPolarSynth.SetParameterFloat("psir", -25.)
SARPolarSynth.SetParameterFloat("khir", 10.)
SARPolarSynth.SetParameterString("out", "newbasis.tif")
Limitations
None
Authors
See Also
Segmentation
ComputeOGRLayersFeaturesStatistics - ComputeOGRLayersFeaturesStatistics
Detailed description
Compute statistics (mean and standard deviation) of the features in a set of OGR Layers, and write them in an XML
file. This XML file can then be used by the training application.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ComputeOGRLayersFeaturesStatistics .
Parameter Key Parameter Name Parameter Type
inshp Vector Data Input vector data
outstats Output XML file Output File name
feat Feature List
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Vector Data: Name of the input shapefile.
• Output XML file: XML file containing mean and variance of each feature.
• Feature: List of features to consider for statistics.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ComputeOGRLayersFeaturesStatistics = otbApplication.Registry.CreateApplication(
˓→"ComputeOGRLayersFeaturesStatistics")
ComputeOGRLayersFeaturesStatistics.SetParameterString("outstats", "results.xml")
Limitations
Authors
This application has been written by David Youssefi during internship at CNES.
See Also
Connected component segmentation and object based image filtering of the input image according to user-defined
criterions.
Detailed description
This application allows one to perform a masking, connected components segmentation and object based image filter-
ing. First and optionally, a mask can be built based on user-defined criterions to select pixels of the image which will be
segmented. Then a connected component segmentation is performed with a user defined criterion to decide whether
two neighbouring pixels belong to the same segment or not. After this segmentation step, an object based image
filtering is applied using another user-defined criterion reasoning on segment properties, like shape or radiometric at-
tributes. Criterions are mathematical expressions analysed by the MuParser library (http://muparser.sourceforge.net/).
For instance, expression “((b1>80) and intensity>95)” will merge two neighbouring pixel in a single segment if their
intensity is more than 95 and their value in the first image band is more than 80. See parameters documentation for a
list of available attributes. The output of the object based image filtering is vectorized and can be written in shapefile
or KML format. If the input image is in raw geometry, resulting polygons will be transformed to WGS84 using sensor
modelling before writing, to ensure consistency with GIS software. For this purpose, a Digital Elevation Model can
be provided to the application. The whole processing is done on a per-tile basis for large images, so this application
can handle images of arbitrary size.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ConnectedComponentSegmentation .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Shape Output vector data
mask Mask expression String
expr Connected Component Expression String
minsize Minimum Object Size Int
obia OBIA Expression String
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: The image to segment.
Output Shape: The segmentation shape.
Mask expression: Mask mathematical expression (only if support image is given).
Connected Component Expression: Formula used for connected component segmentation.
Minimum Object Size: Min object size (area in pixel).
OBIA Expression: OBIA mathematical expression.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for Connected Component Segmentation.
Example
˓→ConnectedComponentSegmentation.shp
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ConnectedComponentSegmentation = otbApplication.Registry.CreateApplication(
˓→"ConnectedComponentSegmentation")
ConnectedComponentSegmentation.SetParameterString("mask", "((b1>80)*intensity>95)")
ConnectedComponentSegmentation.SetParameterString("expr", "distance<10")
ConnectedComponentSegmentation.SetParameterInt("minsize", 15)
ConnectedComponentSegmentation.SetParameterString("obia", "SHAPE_Elongation>8")
ConnectedComponentSegmentation.SetParameterString("out",
˓→"ConnectedComponentSegmentation.shp")
Limitations
Due to the tiling scheme in case of large images, some segments can be arbitrarily split across multiple tiles.
Authors
Detailed description
This application compares a machine segmentation (MS) with a partial ground truth segmentation (GT). The Hoover metrics ar
The application can output the overall Hoover scores along with coloredimages of the MS and GT segmentation
showing the state of each region (correct detection, over-segmentation, under-segmentation, missed) The
Hoover metrics are described in : Hoover et al., “An experimental comparison of range image segmentation
algorithms”, IEEE PAMI vol. 18, no. 7, July 1996.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
HooverCompareSegmentation .
Parameter Key Parameter Name Parameter Type
ingt Input ground truth Input image
inms Input machine segmentation Input image
bg Background label Int
th Overlapping threshold Float
outgt Colored ground truth output Output image
outms Colored machine segmentation output Output image
rc Correct detection score Float
rf Over-segmentation score Float
ra Under-segmentation score Float
rm Missed detection score Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input ground truth: A partial ground truth segmentation image.
• Input machine segmentation: A machine segmentation image.
• Background label: Label value of the background in the input segmentations.
• Overlapping threshold: Overlapping threshold used to find Hoover instances.
• Colored ground truth output: The colored ground truth output image.
• Colored machine segmentation output: The colored machine segmentation output image.
• Correct detection score: Overall score for correct detection (RC).
• Over-segmentation score: Overall score for over segmentation (RF).
• Under-segmentation score: Overall score for under segmentation (RA).
• Missed detection score: Overall score for missed detection (RM).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
1 Table: Parameters table for Hoover compare segmentation.
#!/usr/bin/python
HooverCompareSegmentation.SetParameterString("inms", "maur_labelled.tif")
HooverCompareSegmentation.SetParameterString("outgt", "maur_colored_GT.tif")
HooverCompareSegmentation.SetParameterOutputImagePixelType("outgt", 1)
Limitations
None
Authors
See Also
This application performs the second step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS) [1].
Detailed description
This application will produce a labeled image where neighbor pixels whose range distance is below range radius (and
optionally spatial distance below spatial radius) will be grouped together into the same cluster. For large images one
can use the tilesizex and tilesizey parameters for tile-wise processing, with the guarantees of identical results.
Filtered range image and spatial image should be created with the MeanShiftSmoothing application outputs (fout and
foutpos) [2], with modesearch parameter disabled. If spatial image is not set, the application will only process the
range image and spatial radius parameter will not be taken into account.
Please note that this application will generate a lot of temporary files (as many as the number of tiles), and will
therefore require twice the size of the final result in term of disk space. The cleanup option (activated by default)
allows removing all temporary file as soon as they are not needed anymore (if cleanup is activated, tmpdir set and
tmpdir does not exists before running the application, it will be removed as well during cleanup). The tmpdir option
allows defining a directory where to write the temporary files.
Please also note that the output image type should be set to uint32 to ensure that there are enough labels available.
The output of this application can be passed to the LSMSSmallRegionMerging [3] or LSMSVectorization [4] applica-
tions to complete the LSMS workflow.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
LSMSSegmentation .
Parameter Key Parameter Name Parameter Type
in Filtered image Input image
inpos Filtered position image Input image
out Output labeled Image Output image
spatialr Spatial radius Float
ranger Range radius Float
minsize Minimum Segment Size Int
tilesizex Size of tiles in pixel (X-axis) Int
tilesizey Size of tiles in pixel (Y-axis) Int
tmpdir Directory where to write temporary files Directory
cleanup Temporary files cleaning Boolean
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Filtered image: The filtered image, corresponding to the fout output parameter of the MeanShiftSmoothing
application.
• Filtered position image: The filtered position image, corresponding to the foutpos output parameter of the
MeanShiftSmoothing application.
• Output labeled Image: This output contains the segmented image, where each pixel value is the unique integer
label of the segment it belongs to. It is recommended to set the pixel type to uint32.
• Spatial radius: Threshold on Spatial distance to consider pixels in the same segment. A good value is half the
spatial radius used in the MeanShiftSmoothing application (spatialr parameter).
• Range radius: Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider
pixels in the same segment. A good value is half the range radius used in the MeanShiftSmoothing application
(ranger parameter).
• Minimum Segment Size: Minimum Segment Size. If, after the segmentation, a segment is of size lower than
this criterion, the segment is discarded.
• Size of tiles in pixel (X-axis): Size of tiles along the X-axis for tile-wise processing.
• Size of tiles in pixel (Y-axis): Size of tiles along the Y-axis for tile-wise processing.
• Directory where to write temporary files: This applications need to write temporary files for each tile. This
parameter allows choosing the path where to write those files. If disabled, the current path will be used.
• Temporary files cleaning: If activated, the application will try to remove all temporary files it created.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for Exact Large-Scale Mean-Shift segmentation, step 2.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
LSMSSegmentation.SetParameterString("inpos", "position.tif")
LSMSSegmentation.SetParameterString("out", "segmentation.tif")
LSMSSegmentation.SetParameterFloat("spatialr", 5)
LSMSSegmentation.SetParameterFloat("ranger", 15)
LSMSSegmentation.SetParameterInt("minsize", 0)
LSMSSegmentation.SetParameterInt("tilesizex", 256)
LSMSSegmentation.SetParameterInt("tilesizey", 256)
Limitations
This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) [1] and may not be suited
for any other purpose. This application is not compatible with in-memory connection since it does its own internal
streaming.
Authors
See Also
[2] MeanShiftSmoothing
[3] LSMSSmallRegionsMerging
[4] LSMSVectorization
This application performs the third (optional) step of the exact Large-Scale Mean-Shift segmentation workflow [1].
Detailed description
Given a segmentation result (can be the out output parameter of the LSMSSegmentation application [2]) and the
original image, it will merge segments whose size in pixels is lower than minsize parameter with the adjacent segments
with the adjacent segment with closest radiometry and acceptable size.
Small segments will be processed by increasing size: first all segments for which area is equal to 1 pixel will be merged
with adjacent segments, then all segments of area equal to 2 pixels will be processed, until segments of area minsize.
For large images one can use the tilesizex and tilesizey parameters for tile-wise processing, with the guarantees of
identical results.
The output of this application can be passed to the LSMSVectorization application [3] to complete the LSMS workflow.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
LSMSSmallRegionsMerging .
Parameter Key Parameter Name Parameter Type
in Input image Input image
inseg Segmented image Input image
out Output Image Output image
minsize Minimum Segment Size Int
tilesizex Size of tiles in pixel (X-axis) Int
tilesizey Size of tiles in pixel (Y-axis) Int
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input image: The input image, containing initial spectral signatures corresponding to the segmented image
(inseg).
• Segmented image: Segmented image where each pixel value is the unique integer label of the segment it
belongs to.
• Output Image: The output image. The output image is the segmented image where the minimal segments have
been merged. An ecoding of uint32 is advised.
• Minimum Segment Size: Minimum Segment Size. If, after the segmentation, a segment is of size lower than
this criterion, the segment is merged with the segment that has the closest sepctral signature.
• Size of tiles in pixel (X-axis): Size of tiles along the X-axis for tile-wise processing.
• Size of tiles in pixel (Y-axis): Size of tiles along the Y-axis for tile-wise processing.
1 Table: Parameters table for Exact Large-Scale Mean-Shift segmentation, step 3 (optional).
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
LSMSSmallRegionsMerging.SetParameterString("inseg", "segmentation.tif")
LSMSSmallRegionsMerging.SetParameterString("out", "merged.tif")
LSMSSmallRegionsMerging.SetParameterInt("minsize", 20)
LSMSSmallRegionsMerging.SetParameterInt("tilesizex", 256)
LSMSSmallRegionsMerging.SetParameterInt("tilesizey", 256)
Limitations
This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) and may not be suited for any
other purpose. This application is not compatible with in-memory connection since it does its own internal streaming.
Authors
See Also
[1] Michel, J., Youssefi, D., & Grizonnet, M. (2015). Stable mean-shift algorithm and its application to the
segmentation of arbitrarily large remote sensing images. IEEE Transactions on Geoscience and Remote
Sensing, 53(2), 952-964.
[2] LSMSegmentation
[3] LSMSVectorization
This application performs the fourth step of the exact Large-Scale Mean-Shift segmentation workflow [1].
Detailed description
Given a segmentation result (label image), that may come from the LSMSSegmentation [2] application (out parameter)
or have been processed for small regions merging [3] (out parameter), it will convert it to a GIS vector file containing
one polygon per segment. Each polygon contains additional fields: mean and variance of each channels from input
image (in parameter), segmentation image label, number of pixels in the polygon. For large images one can use the
tilesizex and tilesizey parameters for tile-wise processing, with the guarantees of identical results.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
LSMSVectorization .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
inseg Segmented image Input image
out Output GIS vector file Output File name
tilesizex Size of tiles in pixel (X-axis) Int
tilesizey Size of tiles in pixel (Y-axis) Int
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: The input image, containing initial spectral signatures corresponding to the segmented image
(inseg).
• Segmented image: Segmented image where each pixel value is the unique integer label of the segment it
belongs to.
• Output GIS vector file: The output GIS vector file, representing the vectorized version of the segmented image
where the features of the polygons are the radiometric means and variances.
• Size of tiles in pixel (X-axis): Size of tiles along the X-axis for tile-wise processing.
• Size of tiles in pixel (Y-axis): Size of tiles along the Y-axis for tile-wise processing.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for Exact Large-Scale Mean-Shift segmentation, step 4.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
LSMSVectorization.SetParameterString("inseg", "merged.tif")
LSMSVectorization.SetParameterString("out", "vector.shp")
LSMSVectorization.SetParameterInt("tilesizex", 256)
LSMSVectorization.SetParameterInt("tilesizey", 256)
Limitations
This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) and may not be suited for any
other purpose.
Authors
See Also
Detailed description
This application chains together the 4 steps of the MeanShit framework, that is the MeanShiftSmoothing [1], the
LSMSSegmentation [2], the LSMSSmallRegionsMerging [3] and the LSMSVectorization [4].
This application can be a preliminary step for an object-based analysis.
It generates a vector data file containing the regions extracted with the MeanShift algorithm. The spatial and range
radius parameters allow adapting the sensitivity of the algorithm depending on the image dynamic and resolution.
There is a step to remove small regions whose size (in pixels) is less than the given ‘minsize’ parameter. These regions
are merged to a similar neighbor region. In the output vectors, there are additional fields to describe each region.
In particular the mean and standard deviation (for each band) is computed for each region using the input image as
support. If an optional ‘imfield’ image is given, it will be used as support image instead.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
LargeScaleMeanShift .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
spatialr Spatial radius Int
ranger Range radius Float
minsize Minimum Segment Size Int
tilesizex Size of tiles in pixel (X-axis) Int
tilesizey Size of tiles in pixel (Y-axis) Int
mode Output mode Choices
mode vector Segmentation as vector output Choice
mode raster Standard segmentation with labeled raster output Choice
mode.vector.imfield Support image for field computation Input image
mode.vector.out Output GIS vector file Output File name
mode.raster.out The output raster image Output image
cleanup Temporary files cleaning Boolean
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: The input image can be any single or multiband image. Beware of pontential imbalance between bands
ranges as it may alter euclidean distance.
Spatial radius: Radius of the spatial neighborhood for averaging. Higher values will result in more smoothing and
higher processing time.
Range radius: Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider neighbor-
hood pixel for averaging. Higher values will be less edge-preserving (more similar to simple average in neighborhood),
whereas lower values will result in less noise smoothing. Note that this parameter has no effect on processing time.
Minimum Segment Size: Minimum Segment Size. If, after the segmentation, a segment is of size lower than this
criterion, the segment is merged with the segment that has the closest sepctral signature.
1 Table: Parameters table for Large-Scale MeanShift.
Size of tiles in pixel (X-axis): Size of tiles along the X-axis for tile-wise processing.
Size of tiles in pixel (Y-axis): Size of tiles along the Y-axis for tile-wise processing.
Output mode: Type of segmented output. Available choices are:
• Segmentation as vector output: In this mode, the application will produce a vector file or database and compute
field values for each region.
• Support image for field computation: This is an optional support image that can be used to compute field
values in each region. Otherwise, the input image is used as support.
• Output GIS vector file: The output GIS vector file, representing the vectorized version of the segmented image
where the features of the polygons are the radiometric means and variances.
• Standard segmentation with labeled raster output: In this mode, the application will produce a standard
labeled raster.
• The output raster image: It corresponds to the output of the small region merging step.
Temporary files cleaning: If activated, the application will try to clean all temporary files it created.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
LargeScaleMeanShift.SetParameterInt("spatialr", 4)
LargeScaleMeanShift.SetParameterFloat("ranger", 80)
LargeScaleMeanShift.SetParameterInt("minsize", 16)
LargeScaleMeanShift.SetParameterString("mode.vector.out", "regions.shp")
Limitations
None
Authors
See Also
OGRLayerClassifier - OGRLayerClassifier
Classify an OGR layer based on a machine learning model and a list of features to consider.
Detailed description
This application will apply a trained machine learning model on the selected feature to get a classification of each
geometry contained in an OGR layer. The list of feature must match the list used for training. The predicted label is
written in the user defined field for each geometry.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
OGRLayerClassifier .
Parameter Key Parameter Name Parameter Type
inshp Name of the input shapefile Input vector data
instats XML file containing mean and variance of each feature. Input File name
insvm Input model filename. Output File name
feat Features List
cfield Field containing the predicted class. String
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Name of the input shapefile: Name of the input shapefile.
• XML file containing mean and variance of each feature.: XML file containing mean and variance of each
feature.
• Input model filename.: Input model filename.
• Features: Features to be calculated.
1 Table: Parameters table for OGRLayerClassifier.
• Field containing the predicted class.: Field containing the predicted class.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
OGRLayerClassifier.SetParameterString("instats", "meanVar.xml")
OGRLayerClassifier.SetParameterString("insvm", "svmModel.svm")
Limitations
Authors
This application has been written by David Youssefi during internship at CNES.
See Also
Segmentation - Segmentation
Performs segmentation of an image, and output either a raster or a vector file. In vector mode, large input datasets are
supported.
Detailed description
This application allows one to perform various segmentation algorithms on a multispectral image.Available segmen-
tation algorithms are two different versions of Mean-Shift segmentation algorithm (one being multi-threaded), simple
pixel based connected components according to a user-defined criterion, and watershed from the gradient of the inten-
sity (norm of spectral bands vector). The application has two different modes that affects the nature of its output.
In raster mode, the output of the application is a classical image of unique labels identifying the segmented regions.
The labeled output can be passed to the ColorMapping application to render regions with contrasted colours. Please
note that this mode loads the whole input image into memory, and as such can not handle large images.
To segment large data, one can use the vector mode. In this case, the output of the application is a vector
file or database. The input image is split into tiles (whose size can be set using the tilesize parameter),
and each tile is loaded, segmented with the chosen algorithm, vectorized, and written into the output file
or database. This piece-wise behavior ensure that memory will never get overloaded, and that images of
any size can be processed. There are few more options in the vector mode. The simplify option allows
simplifying the geometry (i.e. remove nodes in polygons) according to a user-defined tolerance. The
stitch option tries to stitch together the polygons corresponding to segmented region that may have been
split by the tiling scheme.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Segmentation .
• Threshold of the final decision rule: Profiles values under the threshold will be ignored.
Processing mode: Choice of processing mode, either raster or large-scale. Available choices are:
• Tile-based large-scale segmentation with vector output: In this mode, the application will output a vector file
or database, and process the input image piecewise. This allows performing segmentation of very large images.
• Output vector file: The output vector file or database (name can be anything understood by OGR).
• Writing mode for the output vector file: This allows one to set the writing behaviour for the output
vector file. Please note that the actual behaviour depends on the file format. Available choices are:
• Update output vector file, only allow creating new layers: The output vector file is opened in
update mode if existing. If the output layer already exists, the application stops, leaving it untouched.
• Overwrite output vector file if existing.: If the output vector file already exists, it is completely
destroyed (including all its layers) and recreated from scratch.
• Update output vector file, overwrite existing layer: The output vector file is opened in update
mode if existing. If the output layer already exists, it si completely destroyed and recreated from
scratch.
• Update output vector file, update existing layer: The output vector file is opened in update mode
if existing. If the output layer already exists, the new geometries are appended to the layer.
• Mask Image: Only pixels whose mask value is strictly positive will be segmented.
• 8-neighbor connectivity: Activate 8-Neighborhood connectivity (default is 4).
• Stitch polygons: Scan polygons on each side of tiles and stitch polygons which connect by more
than one pixel.
• Minimum object size: Objects whose size is below the minimum object size (area in pixels) will
be ignored during vectorization.
• Simplify polygons: Simplify polygons according to a given tolerance (in pixel). This option allows
reducing the size of the output file or database.
• Layer name: Name of the layer in the vector file or database (default is Layer).
• Geometry index field name: Name of the field holding the geometry index in the output vector file
or database.
• Tiles size: User defined tiles size for tile-based segmentation. Optimal tile size is selected according
to available RAM if null.
• Starting geometry index: Starting value of the geometry index field.
• OGR options for layer creation: A list of layer creation options in the form KEY=VALUE that will
be passed directly to OGR without any validity checking. Options may depend on the file format,
and can be found in OGR documentation.
• Standard segmentation with labeled raster output: In this mode, the application will output a standard
labeled raster. This mode can not handle large data.
• Output labeled image: The output labeled image.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Examples
Example 1
Example of use with vector mode and watershed segmentationTo run this example in command-line, use the following:
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Segmentation.SetParameterString("mode","vector")
Segmentation.SetParameterString("mode.vector.out", "SegmentationVector.sqlite")
Segmentation.SetParameterString("filter","watershed")
Example 2
Example of use with raster mode and mean-shift segmentationTo run this example in command-line, use the following:
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Segmentation.SetParameterString("mode","raster")
Segmentation.SetParameterString("mode.raster.out", "SegmentationRaster.tif")
Segmentation.SetParameterOutputImagePixelType("mode.raster.out", 3)
Segmentation.SetParameterString("filter","meanshift")
Limitations
In raster mode, the application can not handle large input images. Stitching step of vector mode might become slow
with very large input images. MeanShift filter results depends on the number of threads used. Watershed and multiscale
geodesic morphology segmentation will be performed on the amplitude of the input image.
Authors
See Also
Detailed description
This application concatenates a list of vector data files to produce a unique vector data output file.
This application will gather all the geometries from the input files and write them into an output vector data file. Any
format supported by OGR can be used. Ideally, all inputs should have the same set of fields and the same spatial
reference system.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ConcatenateVectorData .
Parameter Key Parameter Name Parameter Type
vd Input vector files Input vector data list
out Concatenated output Output vector data
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input vector files: Vector data files to be concatenated.
• Concatenated output: Output conctenated vector data file.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for Concatenate Vector Data.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ConcatenateVectorData.SetParameterString("out", "ConcatenatedVectorData.shp")
Limitations
The vector data must be contain the same type of geometries (point / lines / polygons). The fields present in the output
file are the ones from the first input.
Authors
Rasterization - Rasterization
Detailed description
This application allows reprojecting and rasterize a vector dataset. The grid of the rasterized output can be set by using a refere
There are two rasterize mode available in the application. The first is the binary mode: it allows rendering
all pixels belonging to a geometry of the input dataset in the foreground color, while rendering the other in
background color. The second one allows rendering pixels belonging to a geometry woth respect to an attribute
of this geometry. The field of the attribute to render can be set by the user. In the second mode, the background
value is still used for unassociated pixels.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Rasterization .
Parameter Key Parameter Name Parameter Type
in Input vector dataset Input vector data
out Output image Output image
im Input reference image Input image
szx Output size x Int
szy Output size y Int
epsg Output EPSG code Int
orx Output Upper-left x Float
ory Output Upper-left y Float
spx Spacing (GSD) x Float
spy Spacing (GSD) y Float
background Background value Float
mode Rasterization mode Choices
mode binary Binary mode Choice
mode attribute Attribute burning mode Choice
mode.binary.foreground Foreground value Float
mode.attribute.field The attribute field to burn String
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input vector dataset: The input vector dataset to be rasterized.
Output image: An output image containing the rasterized vector dataset.
Input reference image: A reference image from which to import output grid and projection reference system infor-
mation.
Output size x: Output size along x axis (useless if support image is given).
Output size y: Output size along y axis (useless if support image is given).
Output EPSG code: EPSG code for the output projection reference system (EPSG 4326 for WGS84, 32631 for
UTM31N...,useless if support image is given).
Output Upper-left x: Output upper-left corner x coordinate (useless if support image is given).
Output Upper-left y: Output upper-left corner y coordinate (useless if support image is given).
Spacing (GSD) x: Spacing (ground sampling distance) along x axis (useless if support image is given).
Spacing (GSD) y: Spacing (ground sampling distance) along y axis (useless if support image is given).
Background value: Default value for pixels not belonging to any geometry.
Rasterization mode: Choice of rasterization modes. Available choices are:
• Binary mode: In this mode, pixels within a geometry will hold the user-defined foreground value.
• Foreground value: Value for pixels inside a geometry.
• Attribute burning mode: In this mode, pixels within a geometry will hold the value of a user-defined field
extracted from this geometry.
1 Table: Parameters table for Rasterization.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Rasterization.SetParameterString("out", "rasterImage.tif")
Rasterization.SetParameterFloat("spx", 1.)
Rasterization.SetParameterFloat("spy", 1.)
Limitations
None
Authors
See Also
Perform an extract ROI on the input vector data according to the input image extent
Detailed description
This application extracts the vector data features belonging to a region specified by the support image envelope. Any
features intersecting the support region is copied to output. The output geometries are NOT cropped.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VectorDataExtractROI .
Parameter Key Parameter Name Parameter Type
io Input and output data Group
io.vd Input Vector data Input vector data
io.in Support image Input image
io.out Output Vector data Output vector data
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
[Input and output data]: Group containing input and output parameters.
• Input Vector data: Input vector data.
• Support image: Support image that specifies the extracted region.
• Output Vector data: Output extracted vector data.
[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM,
DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a
product.
• DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that
this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in
this directory.
• Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage
for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB
website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
• Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM
available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set.
This is also used by some application as an average elevation value.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
1 Table: Parameters table for VectorData Extract ROI.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorDataExtractROI.SetParameterString("io.vd", "qb_RoadExtract_classification.shp")
VectorDataExtractROI.SetParameterString("io.out",
˓→"apTvUtVectorDataExtractROIApplicationTest.shp")
Limitations
None
Authors
Reproject a vector data using support image projection reference, or a user specified map projection
Detailed description
This application allows reprojecting a vector data using support image projection reference, or a user
given map projection. If given, image keywordlist can be added to reprojected vectordata.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
1 Table: Parameters table for Vector Data reprojection.
VectorDataReprojection .
Parameter Key Parameter Name Parameter Type
in Input data Group
in.vd Input vector data Input File name
in.kwl Use image keywords list Input image
out Output data Group
out.vd Output vector data Output File name
out.proj Output Projection choice Choices
out.proj image Use image projection ref Choice
out.proj user User defined projection Choice
out.proj.image.in Image used to get projection map Input image
out.proj.user.map Map Projection Choices
out.proj.user.map utm Universal Trans-Mercator (UTM) Choice
out.proj.user.map lambert2 Lambert II Etendu Choice
out.proj.user.map lambert93 Lambert93 Choice
out.proj.user.map wgs WGS 84 Choice
out.proj.user.map epsg EPSG Code Choice
out.proj.user.map.utm.zone Zone number Int
out.proj.user.map.utm.northhem Northern Hemisphere Boolean
out.proj.user.map.epsg.code EPSG Code Int
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
[Input data]
• Input vector data: The input vector data to reproject.
• Use image keywords list: Optional input image to fill vector data with image kwl.
[Output data]
• Output vector data: The reprojected vector data.
• Output Projection choice Available choices are:
• Use image projection ref: Vector data will be reprojected in image projection ref.
• Image used to get projection map: Projection map will be found using image metadata.
• User defined projection
• Map Projection: Defines the map projection to be used. Available choices are:
• Universal Trans-Mercator (UTM): A system of transverse mercator projections
dividing the surface of Earth between 80S and 84N latitude.
• Zone number: The zone number ranges from 1 to 60 and allows defining the
transverse mercator projection (along with the hemisphere).
• Northern Hemisphere: The transverse mercator projections are defined by their
zone number as well as the hemisphere. Activate this parameter if your image is
in the northern hemisphere.
• Lambert II Etendu: This is a Lambert Conformal Conic projection mainly used
in France.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorDataReprojection.SetParameterString("out.proj","image")
VectorDataReprojection.SetParameterString("out.proj.image.in", "ROI_QB_MUL_1.tif")
VectorDataReprojection.SetParameterString("out.vd", "reprojected_vd.shp")
Authors
Detailed description
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VectorDataSetField .
Parameter Key Parameter Name Parameter Type
in Input Input vector data
out Output Output vector data
fn Field String
fv Value String
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input: Input Vector Data.
• Output: Output Vector Data.
• Field: Field name.
• Value: Field value.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorDataSetField = otbApplication.Registry.CreateApplication("VectorDataSetField")
VectorDataSetField.SetParameterString("out", "VectorDataSetField.shp")
VectorDataSetField.SetParameterString("fn", "Info")
Limitations
Authors
Detailed description
This application iterates over each vertex in the input vector data file and performs a transformation on this vertex.
It is the equivalent of [1] that transforms images. For instance, if you extract the envelope of an image with [2], and
you transform this image with [1], you may want to use this application to operate the same transform on the envelope.
The applied transformation is a 2D similarity. It manages translation, rotation, scaling, and can be centered or not.
Note that the support image is used to define the reference coordinate system in which the transform is applied. For
instance the input vector data can have WGS84 coordinates, the support image is in UTM, so a translation of 1 pixel
along X corresponds to the X pixel size of the input image along the X axis of the UTM coordinates frame. This image
can also be in sensor geometry.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
VectorDataTransform .
1 Table: Parameters table for Vector Data Transformation.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
VectorDataTransform.SetParameterString("in", "qb_RoadExtract.tif")
VectorDataTransform.SetParameterString("out", "VectorDataTransform.shp")
VectorDataTransform.SetParameterFloat("transform.ro", 5)
Limitations
None
Authors
See Also
Image Filtering
This application is the implementation of the histogram equalization algorithm. It can be used to enhance contrast in
an image or to reduce the dynamic of the image without losing too much contrast. It offers several options as a no data
value, a contrast limitation factor, a local version of the algorithm and also a mode to equalize the luminance of the
image.
Detailed description
This application is the implementation of the histogram equalization algorithm. The idea of the algorithm is to use the
whole available dynamic. In order to do so it computes a histogram over the image and then use the whole dynamic:
meaning flattening the histogram. That gives us gain for each bin that transform the original histogram into the flat
one. This gain is then apply on the original image. The application proposes several options to allow a finer result:
- There is an option to limit contrast. We choose to limit the contrast by modifying the original histogram. To do so
we clip the histogram at a given height and redistribute equally among the bins the clipped population. Then we add
a local version of the algorithm. - It is possible to apply the algorithm on tiles of the image, instead of on the whole
image. That gives us gain depending on the value of the pixel and its position in the image. In order to smoothen the
result we interpolate the gain between tiles.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
ContrastEnhancement .
• Local: The histograms will be computed on each thumbnail. Each of the histogram will be equalized and the
corresponding gain will be interpolated.
• Thumbnail height: Height of the thumbnail over which the histogram will be computed. The value is in pixels.
• Thumbnail width: Width of the thumbnail over which the histogram will be computed. The value is in pixels.
• Global: The histogram will be computed on the whole image. The equalization will be computed on this
histogram.
Minimum and maximum settings: Minimum and maximum value that will bound the histogram and thus the dy-
namic of the resulting image. Values over those boundaries will be clipped. Available choices are:
• Automatic: Minimum and maximum value will be computed on the image (nodata value won’t be taken into
account) . Each band will have a minimum and a maximum.
• Global: Min/max computation will result in the same minimum and maximum for all the bands.
• Manual settings for min/max values: Minimum and maximum value will be set by the user.
• Minimum value
• Maximum value
What to equalized Available choices are:
• Channels: Each channel is equalized independently.
• Luminance: The relative luminance is computed according to the coefficients.Then the histogram is equalized
and the gain is applied to each of the channels. The channel gain will depend on the weight (coef) of the channel
in the luminance. Note that default values come from color space theories on how human eyes perceive colors).
• Red channel
• Red channel
• Value for luminance computation for the red channel
• Green channel
• Green channel
• Value for luminance computation of the green channel
• Blue channel
• Blue channel
• Value for luminance computation of the blue channel
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
Local contrast enhancement by luminanceTo run this example in command-line, use the following:
To run this example from Python, use the following code snippet:
#!/usr/bin/python
ContrastEnhancement.SetParameterString("out", "equalizedcolors.tif")
ContrastEnhancement.SetParameterOutputImagePixelType("out", 6)
ContrastEnhancement.SetParameterInt("bins", 256)
ContrastEnhancement.SetParameterInt("spatial.local.w", 500)
ContrastEnhancement.SetParameterInt("spatial.local.h", 500)
ContrastEnhancement.SetParameterString("mode","lum")
Limitations
None
Authors
Despeckle - Despeckle
Detailed description
SAR images are affected by speckle noise that inherently exists in and which degrades the image quality. It is caused
by the coherent nature of back-scattered waves from multiple distributed targets. It is locally strong and it increases
the mean Grey level of a local area.
Reducing the speckle noise enhances radiometric resolution but tend to decrease the spatial resolution.Several different
methods are used to eliminate speckle noise, based upon different mathematical models of the phenomenon. The
application includes four methods: Lee [1], Frost [2], GammaMAP [3] and Kuan [4].
We sum up below the basic principle of this four methods:
• Lee : Estimate the signal by mean square error minimization (MMSE) on a sliding window.
• Frost : Also derived from the MMSE criteria with a weighted sum of the values within the window. The
weighting factors decrease with distance from the pixel of interest.
• GammaMAP : Derived under the assumption of the image follows a Gamma distribution.
• Kuan : Also derived from the MMSE criteria under the assumption of non stationary mean and variance.
It is quite similar to Lee filter in form.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Despeckle .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
ram Available RAM (Mb) Int
filter Speckle filtering method Choices
filter lee Lee Choice
filter frost Frost Choice
filter gammamap GammaMap Choice
filter kuan Kuan Choice
filter.lee.rad Radius Int
filter.lee.nblooks Number of looks Float
filter.frost.rad Radius Int
filter.frost.deramp Deramp factor Float
filter.gammamap.rad Radius Int
filter.gammamap.nblooks Number of looks Float
filter.kuan.rad Radius Int
filter.kuan.nblooks Number of looks Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image.
Output Image: Output image.
Available RAM (Mb): Available memory for processing (in MB).
Speckle filtering method Available choices are:
• Lee: Lee filter.
• Radius: Radius in pixel.
• Number of looks: Number of looks in the input image.
• Frost: Frost filter.
• Radius: Radius in pixel.
• Deramp factor: factor use to control the exponential function used to weight effect of the distance between the
central pixel and its neighborhood. Increasing the deramp parameter will lead to take more into account pixels
farther from the center and therefore increase the smoothing effects.
• GammaMap: GammaMap filter.
• Radius: Radius in pixel.
• Number of looks: Number of looks in the input image.
1 Table: Parameters table for Despeckle.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Despeckle.SetParameterString("filter","lee")
Despeckle.SetParameterInt("filter.lee.rad", 5)
Despeckle.SetParameterString("out", "despeckle.tif")
Limitations
Authors
See Also
[3] A. Lopes, E. Nezry, R. Touzi and H. Laur, Maximum APosteriori Speckle Filtering And First Order Texture
ModelsIn Sar Images, 10thAnnual International Symposium onGeoscience and Remote Sensing, 1990,pp.
2409-2412. doi:10.1109/IGARSS.1990.689026
[4] Kuan, D. T., Sawchuk, A. A., Strand, T. C, and Chavel,P., 1987. Adaptive restoration of image with
speckle. IEEETrans on Acoustic Speech and Signal Processing, 35,pp. 373-383.
Detailed description
Performs dimensionality reduction on input image. PCA,NA-PCA,MAF,ICA methods are available. It is also possible
to compute the inverse transform to reconstruct the image. It is also possible to optionally export the transformation
matrix to a text file.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DimensionalityReduction .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
rescale Rescale Output. Group
rescale.outmin Output min value Float
rescale.outmax Output max value Float
outinv Inverse Output Image Output image
method Algorithm Choices
method pca PCA Choice
method napca NA-PCA Choice
method maf MAF Choice
method ica ICA Choice
method.napca.radiusx Set the x radius of the sliding window. Int
method.napca.radiusy Set the y radius of the sliding window. Int
method.ica.iter number of iterations Int
method.ica.mu Give the increment weight of W in [0, 1] Float
nbcomp Number of Components. Int
normalize Normalize. Boolean
outmatrix Transformation matrix output (text format) Output File name
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: The input image to apply dimensionality reduction.
Output Image: output image. Components are ordered by decreasing eigenvalues.
[Rescale Output.]
• Output min value: Minimum value of the output image.
1 Table: Parameters table for Dimensionality reduction.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DimensionalityReduction.SetParameterString("out", "FilterOutput.tif")
DimensionalityReduction.SetParameterString("method","pca")
Limitations
This application does not provide the inverse transform and the transformation matrix export for the MAF.
Authors
See Also
DomainTransform - DomainTransform
Detailed description
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
DomainTransform .
1 Table: Parameters table for DomainTransform.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
DomainTransform.SetParameterString("mode.wavelet.form","haar")
DomainTransform.SetParameterString("out", "output_wavelet_haar.tif")
Limitations
This application is not streamed, check your system resources when processing large images
Authors
See Also
Detailed description
MeanShift [1,2,3] is an iterative edge-preserving image smoothing algorithm often used in image processing and as a
first step for image segmentation. The MeanShift algorithm can be applied to multispectral images.
At first iteration, for any given pixel of the input image, the filtered value correspond to the average spectral signature
of neighborhood pixels that are both spatially closer than the spatial radius parameter (spatialr) and with spectral
signature that have an euclidean distance to the input pixel lower than the range radius (ranger), that is, pixels that are
both close in space and in spectral signatures. Subsequent iterations will repeat this process by considering that the
pixel signature corresponds to the average spectral signature computed during previous iteration, and that the pixel
position corresponds to the average position of pixels used to compute the average signature.The algorithm stops
when the maximum number of iterations (maxiter) is reached, or when the position and spectral signature does not
change much between iterations, according to the convergence threshold (thres). If the modesearch option is used
then convergence will also stops if the spatial position reaches a pixel that has already converged. This will speed-up
convergence, at the expense of stability of the result.
The application outputs the image of the final averaged spectral signatures (fout), and can also optionally output the
2D displacement field between input pixel position and final pixel position after convergence (foutpos).
Note that computing an euclidean distance between spectral signatures may be inaccurate and that techniques such
as color space transform or image normalisation could be applied before using this application. Also note that most
satellite images noise model is not gaussian, since noise variance linearly depends on radiance (the higher the radiance,
the higher the noise variance). To account for such noise model, the application provides the range radius ramp option
(rangeramp), which will vary the range radius linearly with the central pixel intensity. Default value is 1. (no ramp).
This application is the first step of the large scale MeanShift method depicted in [4]. Both outputs (fout and foutpos)
can be passed to the large scale MeanShift segmentation application [5]. If the application is used for large scale
MeanShift, modesearch option should be off.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MeanShiftSmoothing .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
fout Spectral filtered output Output image
foutpos Spatial filtered displacement output Output image
ram Available RAM (Mb) Int
spatialr Spatial radius Int
ranger Range radius Float
thres Mode convergence threshold Float
maxiter Maximum number of iterations Int
rangeramp Range radius ramp coefficient Float
modesearch Mode search. Boolean
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
1 Table: Parameters table for MeanShift Smoothing.
• Input Image: The input image can be any single or multiband image. Beware of pontential imbalance between
bands ranges as it may alter euclidean distance.
• Spectral filtered output: This output image contains the final average spectral signatures of each pixel. The
output type should be at least as wide as the input image type. Floating point encoding is advised. This output
can be used as input image (in) of the LSMSSegmentation application [4,5].
• Spatial filtered displacement output: This output image contains the 2D displacement between the input pixel
spatial position and the final position after convergence. Floating point encoding is mandatory. This output can
be used as input image (in) of the LSMSSegmentation application [4,5].
• Available RAM (Mb): Available memory for processing (in MB).
• Spatial radius: Radius of the spatial neighborhood for averaging. Higher values will result in more smoothing
and higher processing time.
• Range radius: Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider
neighborhood pixel for averaging. Higher values will be less edge-preserving (more similar to simple average in
neighborhood), whereas lower values will result in less noise smoothing. Note that this parameter has no effect
on processing time.
• Mode convergence threshold: Algorithm will stop if update of average spectral signature and spatial position
is below this threshold.
• Maximum number of iterations: Algorithm will stop if convergence threshold is not met after the maximum
number of iterations.
• Range radius ramp coefficient: Vary the range radius linearly with the central pixel intensity (experimental).
• Mode search.: If activated pixel iterative convergence is stopped if the path crosses an already converged pixel.
Be careful, with this option, the result will slightly depend on thread number and the results will not be stable
(see [4] for more details).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MeanShiftSmoothing.SetParameterString("fout", "smooth.tif")
MeanShiftSmoothing.SetParameterString("foutpos", "position.tif")
MeanShiftSmoothing.SetParameterInt("spatialr", 16)
MeanShiftSmoothing.SetParameterFloat("ranger", 16)
MeanShiftSmoothing.SetParameterFloat("thres", 0.1)
MeanShiftSmoothing.SetParameterInt("maxiter", 100)
Limitations
When modesearch is on, the application will yield slightly different results between executions, due to multi-threading.
Results will also not be stable [4].
Authors
See Also
Smoothing - Smoothing
Detailed description
This application applies a smoothing filter to an image. Three methodes can be used : a gaussian filter , a mean filter ,
or an anisotropic diffusion using the Perona-Malik algorithm.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Smoothing .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
ram Available RAM (Mb) Int
type Smoothing Type Choices
type mean Mean Choice
type gaussian Gaussian Choice
type anidif Anisotropic Diffusion Choice
type.mean.radius Radius Int
type.gaussian.radius Radius Float
type.anidif.timestep Time Step Float
type.anidif.nbiter Nb Iterations Int
type.anidif.conductance Conductance Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
Input Image: Input image to smooth.
Output Image: Output smoothed image.
Available RAM (Mb): Available memory for processing (in MB).
Smoothing Type: Smoothing kernel to apply. Available choices are:
• Mean
• Radius: Kernel’s radius (in pixels).
• Gaussian
• Radius: Standard deviation of the gaussian kernel used to filter the image.
• Anisotropic Diffusion
• Time Step: Time step that will be used to discretize the diffusion equation.
• Nb Iterations: Number of iterations needed to get the result.
• Conductance: Controls the sensitivity of the conductance term in the diffusion equation. The lower it is the
stronger the features will be preserved.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Examples
Example 1
Image smoothing using a mean filter.To run this example in command-line, use the following:
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Smoothing.SetParameterString("out", "smoothedImage_mean.png")
Smoothing.SetParameterOutputImagePixelType("out", 1)
Smoothing.SetParameterString("type","mean")
Example 2
Image smoothing using an anisotropic diffusion filter.To run this example in command-line, use the following:
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Smoothing.SetParameterString("out", "smoothedImage_ani.png")
Smoothing.SetParameterOutputImagePixelType("out", 6)
Smoothing.SetParameterString("type","anidif")
Smoothing.SetParameterFloat("type.anidif.timestep", 0.1)
Smoothing.SetParameterInt("type.anidif.nbiter", 5)
Smoothing.SetParameterFloat("type.anidif.conductance", 1.5)
Limitations
None
Authors
Deprecated
Convert an image to a different format, optionally rescaling the data and/or changing the pixel type.
Detailed description
This application performs an image pixel type conversion (short, ushort, uchar, int, uint, float and double types are handled). Th
The conversion can include a rescale of the data range, by default it’s set from 2% to 98% of the data values.
The rescale can be linear or log2. The choice of the output channels can be done with the extended filename,
but less easy to handle. To do this, a ‘channels’ parameter allows you to select the desired bands at the output.
There are 3 modes, the available choices are: * grayscale : to display mono image as standard color image *
rgb : select 3 bands in the input image (multi-bands) * all : keep all bands.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Convert .
1 Table: Parameters table for Image Conversion.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Convert.SetParameterString("out", "otbConvertWithScalingOutput.png")
Convert.SetParameterString("type","linear")
Convert.SetParameterString("channels","rgb")
Limitations
None
Authors
See Also
Detailed description
This application scales the given image pixel intensity between two given values. By default min (resp. max) value is
set to 0 (resp. 255). Input minimum and maximum values is automatically computed for all image bands.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
Rescale .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
ram Available RAM (Mb) Int
outmin Output min value Float
outmax Output max value Float
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: The image to scale.
• Output Image: The rescaled image filename.
• Available RAM (Mb): Available memory for processing (in MB).
• Output min value: Minimum value of the output image.
• Output max value: Maximum value of the output image.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
Rescale.SetParameterString("out", "rescaledImage.png")
Rescale.SetParameterOutputImagePixelType("out", 1)
Rescale.SetParameterFloat("outmin", 0)
Rescale.SetParameterFloat("outmax", 255)
Limitations
None
Authors
Change Detection
Detailed description
This application performs change detection between two multispectral images using the Multivariate Alteration De-
tector (MAD) [1] algorithm.
The MAD algorithm produces a set of N change maps (where N is the maximum number of bands in first and second input imag
• Change maps are differences of a pair of linear combinations of bands from image 1 and bands from image
2 chosen to maximize the correlation,
• Each change map is orthogonal to the others.
This is a statistical method which can handle different modalities and even different bands and number of bands
between images.
The application will output all change maps into a single multiband image. If numbers of bands in image 1 and 2 are
equal, then change maps are sorted by increasing correlation. If number of bands is different, the change maps are
sorted by decreasing correlation.
The application will also print the following information: - Mean1 and Mean2 which are the mean values of bands for
both input images, - V1 and V2 which are the two linear transform that are applied to input image 1 and input image
2 to build the change map, - Rho, the vector of correlation associated to each change map.
The OTB filter used in this application has been implemented from the Matlab code kindly made available by the
authors here [2]. Both cases (same and different number of bands) have been validated by comparing the output image
to the output produced by the Matlab code, and the reference images for testing have been generated from the Matlab
code using Octave.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
MultivariateAlterationDetector .
Parameter Key Parameter Name Parameter Type
in1 Input Image 1 Input image
in2 Input Image 2 Input image
out Change Map Output image
ram Available RAM (Mb) Int
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image 1: Multiband image of the scene before perturbations.
• Input Image 2: Mutliband image of the scene after perturbations.
• Change Map: Multiband image containing change maps. Each map will be in range [-1,1], so a floating point
output type is advised.
• Available RAM (Mb): Available memory for processing (in MB).
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
MultivariateAlterationDetector = otbApplication.Registry.CreateApplication(
˓→"MultivariateAlterationDetector")
MultivariateAlterationDetector.SetParameterString("in2", "Spot5-Gloucester-after.tif")
MultivariateAlterationDetector.SetParameterString("out", "detectedChangeImage.tif")
Limitations
Input images 1 and 2 should share exactly the same origin, spacing, size, and projection if any.
Authors
See Also
Calibration
Perform optical calibration TOA/TOC (Top Of Atmosphere/Top Of Canopy). Supported sensors: QuickBird, Ikonos,
WorldView2, Formosat, Spot5, Pleiades, Spot6, Spot7. For other sensors the application also allows providing cali-
bration parameters manually.
Detailed description
The application allows converting pixel values from DN (for Digital Numbers) to reflectance. Calibrated values are
called surface reflectivity and its values lie in the range [0, 1]. The first level is called Top Of Atmosphere (TOA)
reflectivity. It takes into account the sensor gain, sensor spectral response and the solar illuminations. The second
level is called Top Of Canopy (TOC) reflectivity. In addition to sensor gain and solar illuminations, it takes into
account the optical thickness of the atmosphere, the atmospheric pressure, the water vapor amount, the ozone amount,
as well as the composition and amount of aerosol gasses. It is also possible to indicate an AERONET file which
contains atmospheric parameters (version 1 and version 2 of Aeronet file are supported. Note that computing TOC
reflectivity will internally compute first TOA and then TOC reflectance.
If the sensor is not supported by the metadata interface factory of OTB, users still have the possibility to give the
needed parameters to the application. For TOA conversion, these parameters are : - day and month of acquisition, or
flux normalization coefficient; - sun elevation angle; - gains and biases, one pair of values for each band (passed by a
file); - solar illuminations, one value for each band (passed by a file).
For the conversion from DN (for Digital Numbers) to spectral radiance (or ‘TOA radiance’) L, the following formula
is used :
1. L(b) = DN(b)/gain(b)+bias(b) (in W/m2/steradians/micrometers) with b being a band ID.
These values are provided by the user thanks to a simple txt file with two lines, one for the gains and one for the biases.
Each value must be separated with colons (:), with eventual spaces. Blank lines are not allowed. If a line begins with
the ‘#’ symbol, then it is considered as comments. Note that sometimes, the values provided by certain metadata files
assume the formula L(b) = gain(b)*DC(b)+bias(b). In this case, be sure to provide the inverse gain values so that the
application can correctly interpret them.
In order to convert TOA radiance to TOA reflectance, the following formula is used :
2. R(b) = (pi*L(b)*d*d) / (ESUN(b)*cos(𝜃)) (no dimension) where :
• L(b) is the spectral radiance for band b
• pi is the famous mathematical constant (3.14159...)
• d is the earth-sun distance (in astronomical units) and depends on the acquisition’s day and month
• ESUN(b) is the mean TOA solar irradiance (or solar illumination) in W/m2/micrometers
• 𝜃 is the solar zenith angle in degrees.
Note that the application asks for the solar elevation angle, and will perform the conversion to the zenith angle itself
(zenith_angle = 90 - elevation_angle , units : degrees). Note also that ESUN(b) not only depends on the band b, but
also on the spectral sensitivity of the sensor in this particular band. In other words, the influence of spectral sensitivities
is included within the ESUN different values. These values are provided by the user thanks to a txt file following the
same convention as before. Instead of providing the date of acquisition, the user can also provide a flux normalization
coefficient ‘fn’. The formula used instead will be the following :
3. R(b) = (pi*L(b)) / (ESUN(b)*fn*fn*cos(𝜃))
Whatever the formula used (2 or 3), the user should pay attention to the interpretation of the parameters he will provide
to the application, by taking into account the original formula that the metadata files assumes.
Below, we give two examples of txt files containing information about gains/biases and solar illuminations :
• gainbias.txt :
# Gain values for each band. Each value must be separated with colons (:), with eventual spaces. Blank lines not
allowed. 10.4416 : 9.529 : 8.5175 : 14.0063 # Bias values for each band. 0.0 : 0.0 : 0.0 : 0.0
• solarillumination.txt :
# Solar illumination values in watt/m2/micron (‘micron’ means actually ‘for each band’). # Each value must be
separated with colons (:), with eventual spaces. Blank lines not allowed. 1540.494123 : 1826.087443 : 1982.671954
: 1094.747446
Finally, the ‘Logs’ tab provides useful messages that can help the user in knowing the process different status.
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
OpticalCalibration .
and set the output pixel type (-out filename double for example).
Clamp of reflectivity values between [0, 1]: Clamping in the range [0, 1]. It can be useful to preserve area with
specular reflectance.
[Acquisition parameters]: This group allows setting the parameters related to the acquisition conditions.
• Minute: Minute (0-59).
• Hour: Hour (0-23).
• Day: Day (1-31).
• Month: Month (1-12).
• Year: Year.
• Flux Normalization: Flux Normalization Coefficient.
• Sun angles: This group contains the sun angles.
• Sun elevation angle (deg): Sun elevation angle (in degrees).
• Sun azimuth angle (deg): Sun azimuth angle (in degrees).
• Viewing angles: This group contains the sensor viewing angles.
• Viewing elevation angle (deg): Viewing elevation angle (in degrees).
• Viewing azimuth angle (deg): Viewing azimuth angle (in degrees).
• Gains or biases: Gains or biases.
• Solar illuminations: Solar illuminations (one value per band).
[Atmospheric parameters (for TOC)]: This group allows setting the atmospheric parameters.
• Aerosol Model Available choices are:
• No Aerosol Model
• Continental
• Maritime
• Urban
• Desertic
• Ozone Amount: Ozone Amount.
• Water Vapor Amount: Water Vapor Amount (in saturation fraction of water).
• Atmospheric Pressure: Atmospheric Pressure (in hPa).
• Aerosol Optical Thickness: Aerosol Optical Thickness.
• Aeronet File: Aeronet file containing atmospheric parameters.
• Relative Spectral Response File: Sensor relative spectral response file By default the application gets this
information in the metadata.
• Window radius (adjacency effects): Window radius for adjacency effects correctionsSetting this parameters
will enable the correction ofadjacency effects.
• Pixel size (in km): Pixel size (in km )used tocompute adjacency effects, it doesn’t have tomatch the image
spacing.
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
#!/usr/bin/python
OpticalCalibration.SetParameterString("level","toa")
OpticalCalibration.SetParameterString("out", "OpticalCalibration.tif")
Limitations
None
Authors
See Also
Perform radiometric calibration of SAR images. Following sensors are supported: TerraSAR-X, Sentinel1 and
Radarsat-2.Both Single Look Complex(SLC) and detected products are supported as input.
Detailed description
The objective of SAR calibration is to provide imagery in which the pixel values can be directly related to the radar
backscatter of the scene. This application allows computing Sigma Naught (Radiometric Calibration) for TerraSAR-
X, Sentinel1 L1 and Radarsat-2 sensors. Metadata are automatically retrieved from image products.The application
supports complex and non-complex images (SLC or detected products).
Parameters
This section describes in details the parameters available for this application. Table1 presents a summary of these
parameters and the parameters keys to be used in command-line and programming languages. Application key is
SARCalibration .
Parameter Key Parameter Name Parameter Type
in Input Image Input image
out Output Image Output image
ram Available RAM (Mb) Int
noise Disable Noise Boolean
lut Lookup table sigma /gamma/ beta/ DN. Choices
lut sigma Use sigma nought lookup Choice
lut gamma Use gamma nought lookup Choice
lut beta Use beta nought lookup Choice
lut dn Use DN value lookup Choice
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file
• Input Image: Input complex image.
• Output Image: Output calibrated image. This image contains the backscatter (sigmaNought) of the input
image.
• Available RAM (Mb): Available memory for processing (in MB).
• Disable Noise: Flag to disable noise. For 5.2.0 release, the noise values are only read by TerraSARX product.
• Lookup table sigma /gamma/ beta/ DN.: Lookup table values are not available with all SAR products. Prod-
ucts that provide lookup table with metadata are: Sentinel1, Radarsat2. Available choices are:
• Use sigma nought lookup: Use Sigma nought lookup value from product metadata.
• Use gamma nought lookup: Use Gamma nought lookup value from product metadata.
• Use beta nought lookup: Use Beta nought lookup value from product metadata.
• Use DN value lookup: Use DN value lookup value from product metadata.
• Load otb application from xml file: Load otb application from xml file.
• Save otb application to xml file: Save otb application to xml file.
Example
To run this example from Python, use the following code snippet:
1 Table: Parameters table for SAR Radiometric calibration.
#!/usr/bin/python
SARCalibration.SetParameterString("out", "SarRadiometricCalibration.tif")
Limitations
None
Authors
EIGHT
Introduction
What’s in OTB?
• Image access: optimized read/write access for most of remote sensing image formats, meta-data access, simple
visualization;
• Sensor geometry: sensor models, cartographic projections;
• Radiometry: atmospheric corrections, vegetation indices;
• Filtering: blurring, denoising, enhancement;
• Fusion: image pansharpening;
• Feature extraction: interest points, alignments, lines;
• Image segmentation: region growing, watershed, level sets;
• Classification: K-means, SVM, Markov random fields;
• Change detection.
• Object based image analysis.
• Geospatial analysis.
For a full list of applications see the Applications Reference Documentation. For an introduction to the C++ API see
the Software Guide. And for exhaustive descrpition of the C++ API see the Doxygen.
What is ORFEO?
ORFEO stands for Optical and Radar Federated Earth Observation. In 2001 a cooperation program was set between
France and Italy to develop ORFEO, an Earth observation dual system with metric resolution: Italy is in charge of
COSMO-Skymed the radar component development, and France of PLEIADES the optic component.
The PLEIADES optic component is composed of two “small satellites” (mass of one ton) offering a spatial resolution
at nadir of 0.7 m and a field of view of 20 km. Their great agility enables a daily access all over the world, essentially
for defense and civil security applications, and a coverage capacity necessary for the cartography kind of applications
at scales better than those accessible to SPOT family satellites. Moreover, PLEIADES have stereoscopic acquisition
capacity to meet the fine cartography needs, notably in urban regions, and to bring more information when used with
aerial photography.
385
OTB CookBook Documentation, Release 6.6.0
The ORFEO “targeted” acquisition capacities made it a system particularly adapted to defense or civil security mis-
sions, as well as critical geophysical phenomena survey such as volcanic eruptions, which require a priority use of the
system resources.
With respect to the constraints of the Franco-Italian agreement, cooperation have been set up for the PLEIADES
optical component with Sweden, Belgium, Spain and Austria.
Beside the Pleiades (PHR) and Cosmo-Skymed (CSK) systems developments forming ORFEO, the dual and bilateral
system (France - Italy) for Earth Observation, the ORFEO Accompaniment Program was set up, to prepare, accompany
and promote the use and the exploitation of the images derived from these sensors.
The creation of a preparatory program is needed because of:
• the new capabilities and performances of the ORFEO systems (optical and radar high resolution, access capa-
bility, data quality, possibility to acquire simultaneously in optic and radar),
• the implied need of new methodological developments: new processing methods, or adaptation of existing
methods,
• the need to realize those new developments in very close cooperation with the final users, the integration of new
products in their systems.
This program was initiated by CNES mid-2003 and will last until mid 2013. It consists in two parts, between which it
is necessary to keep a strong interaction:
• A Methodological part,
• A Thematic part.
This Accompaniment Program uses simulated data (acquired during airborne campaigns) and satellite images quite
similar to Pleiades (as QuickBird and Ikonos), used in a communal way on a set of special sites. The validation of
specified products and services will be realized with Pleiades data
Apart from the initial cooperation with Italy, the ORFEO Accompaniment Program enlarged to Belgium, with inte-
gration of Belgian experts in the different WG as well as a participation to the methodological part.
Where can I get more information about the ORFEO Accompaniment Program?
The French Centre National d’Études Spatiales, CNES, initiated the ORFEO Toolbox and is responsible for the specifi-
cation of the library. CNES funds the industrial development contracts and research contracts needed for the evolution
of OTB.
License
OTB is distributed under the permissive open source license Apache v2.0 - aka Apache Software License (ASL) v2.0:
http://www.apache.org/licenses/LICENSE-2.0
No. The license gives you the option to distribute your application if you want to. You do not have to exercise this
option in the license.
No.
If I wanted to distribute an application using OTB what license would I need to use?
The license of your choice. The OTB license only requires you to include a copy of the Apache license and to provide
a clear attribution to the OTB project in any distribution including a piece of OTB software.
No. The OTB license only requires you to include a copy of the Apache license and to provide a clear attribution to
the OTB project in any distribution including a piece of OTB software.
Getting OTB
Go to http://www.orfeo-toolbox.org and follow the “download OTB” link. You will have access to the OTB source
code, to the Software User’s Guide and to the Cookbook of the last release. Binary packages are also provided for
the current version. OTB and Monteverdi are also integrated in OSGeo-Live since version 4.5. You can find more
information about the project at http://live.osgeo.org/. Moreover you can found the last release of Monteverdi and
OTB applications through the OSGeo4W installer.
You can get the current development version, as our repository is public, using Git (available at http://git-scm.com).
Be aware that, even if the golden rule is what is committed will compile, this is not always the case. Changes are
usually more than ten per day.
The first time, you can get the source code using:
Then you can build OTB as usual using this directory as the source (refer to build instructions). Later if you want to
update your source, from OTB’s source directory, just do:
git pull
A simple make in your OTB binary directory will be enough to update the library (recompiling only the necessary
files).
All information about OTB compilation can be found in the Software Guide. We present here only the special issues
which can be encountered.
On some Debian and Ubuntu versions, the system GDAL library and its tiff internal symbol might conflict with the
system Tiff library (bugs.debian.org/558733). This is most likely the case if you get odd segmentation fault whenever
trying to open a tiff image. This symbol clash happens when using OTB. A workaround to the issue has been provided
in GDAL sources, but is available in the 1.9.0 release.
The recommended procedure is to get this recent source and build GDAL from sources, with the following configure
command:
The internal version of libkml cannot be compiled when using an external build of ITK. See http://bugs.orfeo-toolbox.
org/view.php?id=879 for more details.
To workaround the problem, either use an external build of libkml (it is provided on most systems), or use an internal
build of ITK by setting to OFF the CMake variable OTB_USE_EXTERNAL_ITK.
To build OTB on Windows, you should prepare an environment with the following tools:
• Visual Studio 2015 or later
• CMake 3.1 or later
• OTB XDK : download a Windows binary package of OTB and use the supplied uninstall script to remove OTB
binaries and headers. Now, this package only contains the dependencies needed to build OTB.
Then, you can download OTB sources (preferably, a version compatible with your XDK), and compile them as a
standard CMake project. More details are available in the SoftwareGuide.
There is an other solution, using OSGeo4W distribution. However, the dependencies may be outdated.
Using OTB
The maximum physical space a user can allocate depends on her platform. Therefore, image allocation in OTB is
restricted by image dimension, size, pixel type and number of bands.
Fortunately, thanks to the streaming mechanism implemented within OTB’s pipeline (actually ITK’s), this limitation
can be bypassed. The use of the at the end of the pipeline, will seamlessly break the large, problematic data into
small pieces whose allocation is possible. These pieces are processed one after the other, so that there is not allocation
problem anymore. We are often working with images of 25000 × 25000 pixels.
For the streaming to work, all the filters in the pipeline must be streaming capable (this is the case for most of the
filters in OTB). The output image format also need to be streamable (not PNG or JPEG, but TIFF or ENVI formats,
for instance).
The class manage the steaming process following two strategies: by tile or by strip. Different size configuration
for these two strategies are available into the interface. The default mode use the information about how the file is
streamed on the disk and will try to minimize the memory consumption along the pipeline. More information can be
found into the documentation of the class.
If you use OTB standalone binaries, there should not be any dependency conflict with other libraries installed on your
system. OTB will always try to grab supplied libraries in the standalone package.
However, when using Python wrappings, there can be conflicts if you import otbApplications along with other software
that share common dependencies with OTB. For instance, if you want to use OTB Applications and Fiona in a Python
script, they both rely on GDAL library. As the libraries loaded by Python must be unique, the first library SomeLib
loaded will be used by any other binary depending on it. Thus, the order of the imports has an effect. In some cases,
symbol problems have been observed in libcrypto, and the solution was to import OTB Applications before importing
Fiona.
Getting help
Yes. There is a discussion group at http://groups.google.com/group/otb-users/ where you can get help on the set up
and the use of OTB.
for these examples is distributed with the toolbox. Another information source is the on-line API documentation which
is available at http://www.orfeo-toolbox.org/doxygen.
You can also find some information about how to use Monteverdi and the OTB-Applications into the Cookbook at
http://www.orfeo-toolbox.org/CookBook/.
Contributing to OTB
There are many ways to join us in the OTB adventure. The more people contribute, the better the library is for
everybody!
First, you can send an email to the user mailing list ([email protected]) to let us know what functionality
you would like to introduce in OTB. If the functionality seems important for OTB users, we will then discuss on how
to retrieve your code, make the necessary adaptions, check with you that the results are correct and finally include it
in the next release.
You can also run the nightly tests so we have a wider range of platforms to detect bugs earlier.
You can also find more information about how to contribute at https://www.orfeo-toolbox.org/community
Besides the satisfaction of contributing to an open source project, we will include the references to relevant papers in
the software guide. Having algorithms published in the form of reproducible research helps science move faster and
encourages people who needs your algorithms to use them.
You will also benefit from the strengths of OTB: multi-platform, streaming and threading, etc.
All functionalities which are useful for remote sensing data are of interest. As OTB is a library, it should be generic
algorithms: change, detection, fusion, object detection, segmentation, interpolation, etc.
More specific applications can be contributed using the framework directly in the Applications directory of OTB.
OTB is an ever changing library, it is quite active and have scores of changes per day from different people. It would
be a headache to make sure that the brand new improvement that you introduced didn’t break anything, if we didn’t
have automated tests. You also have to take into account differences in OS, compilers, options, versions of external
libraries, etc. By running the tests and submitting it to the dashboard, you will help us detect problems and fix them
early.
For each class, at minimum there is a test which tries to instantiate it and another one which uses the class. The output
of each test (image, text file, binary file) is controlled against a baseline to make sure that the result hasn’t changed.
All OTB tests source code are available in the directory Testing and are also good examples on how to use the
different classes.
There is more than 2500 tests for OTB and it takes from 20 minutes to 3 hours to run all the test, mainly depending on
your compilation options (Release mode does make a difference) and of course your hardware.
To run the tests, you first have to make sure that you set the option BUILD_TESTING to ON before building the
library. If you want to modify it, just rerun ccmake, change the option, then make.
For some of the tests, you also need the test data and the baselines (see [sec:FAQTestData]).
Once OTB is built with the tests, you just have to go to the binary directory where you built OTB and run ctest -N
to have a list of all the tests. Just using ctest will run all the tests. To select a subset, you can do ctest -R Kml
to run all tests related to kml files or ctest -I 1,10 to run tests from 1 to 10.
Data used for the tests are also versioned using Git (see [sec:FAQGit]).
You can get the base doing:
This is about 1 GB of data, so it will take a while, but you have to do it only once, as after, a simple
git pull
Once you know how to run the tests, you can also help us to detect the bugs or configuration problems specific to
your configuration. As mentioned before, the possible combinations between OS, compiler, options, external libraries
version is too big to be tested completely, but the more the better.
You just have to launch ctest with the -D Experimental switch. Hence:
There is no detailed plan about the availability of OTB new features, since OTB’s content depends on ongoing research
work and on feedback from thematic users of the ORFEO Accompaniment Program. You can find ideas and plans for
the future on the Wishlist at https://wiki.orfeo-toolbox.org/index.php/Wishlist.