3.7.2 New operators and functions

New operators and functions have been implemented within BandMathX application. These ones can be divided into two categories.

Concerning the last category, here is a list of implemented operators or functions (they are all implemented in otbParserXPlugins.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:

im1divim2
(3.13)

im1 dv2.0
(3.14)

Operators mult and mlt
These operators are the duals of the previous ones. For instance:

im1 mult im2
(3.15)

im1mlt 2.0
(3.16)

Note that the operator ’*’ could have been used instead of ’pw’ one. But ’pw’ is a little bit more permisive, and can tolerate one-dimensional vector as right element.

Operators pow and pw
The first operator allows the definition of an element-wise exponentiation 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 exponentiated by the same unique value). For instance:

im1 pow im2
(3.17)

im1 pw2.0
(3.18)

Function bands
This function allows to select specific bands from an image, and/or to rearrange them in a new vector; for instance:

bands(im1,{1,2,1,1})
(3.19)

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):

∑(i,j)m1 (i,j)∗ m2(i,j)
(3.20)

For instance:

dotpr(kernel1,im1b1N3x5 )
(3.21)

is correct provided that kernel1 and im1b1N3x5 have the same dimensions. The function can take as many neighbourhoods as needed in inputs.

Thus, if n neighbourhoods must be processed, the output will consist in a row vector of n values. This behaviour is typical of the functions implemented in the BandMathX application.

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:

mean(im1b1N3x3,im1b2N3x3,im1b3N3x3,im1b4N3x3 )
(3.22)

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:

var(im1b1N3x3)
(3.23)

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:

median(im1b1N3x3)
(3.24)

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:

corr(im1b1N3x3,im1b2N3x3 )
(3.25)

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:

maj(im1b1N3x3, im1b2N3x3)
(3.26)

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:

(vmax(im3b1N3x5)+ vmin(im3b1N3x5))div{2.0}
(3.27)

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:

cat(im3b1,vmin(im3b1N3x5 ),median(im3b1N3x5 ),vmax(im3b1N3x5 ))
(3.28)

Note: the user should prefer the use of semi-colons (;) when setting expressions, instead of directly use this function. The application will call the function ’cat’ automatically.

Function ndvi
This function implements the classical normalized difference vegetation index; it tkaes two inputs. For instance:

ndvi(im1b1,im1b4)
(3.29)

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.




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 mltoperators
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



Table 3.4: Functions and operators summary.