Formulas¶
The formula should be a mathematical expression containing: band names, operators and functions. Available bands for supported data blocks are listed in supported blocks section.
Basic arithmetics¶
Available bands can be referenced by their name. You can add, subtract, multiply and divide. Example:
"((BAND1 + BAND2 - BAND3) / 2) * 5"
Functions¶
The following functions are available in formulas:
Rounding¶
round(x)
ceil(x)
floor(x)
Trigonometric¶
sin(x)
cos(x)
tan(x)
sinh(x)
cosh(x)
tanh(x)
arcsin(x)
arccos(x)
arctan(x)
Logarithm and exponentiation¶
sqrt(x)
log(x)
log2(x)
log10(x)
exp(x)
relu(x)
- rectified linear unitsigmoid(x)
expit(x)
- alias forsigmoid
Summary statistics¶
min(x)
- the minimum value of the entire band in the current imagemax(x)
- the maximum value of the entire band in the current imagestd(x)
- the standard deviation of values in the band in the current imagevar(x)
- the variance of values in the band in the current imagemean(x)
- the mean value of the entire band in the current imagemedian(x)
- the median value of the entire band in the current image
Miscellaneous¶
abs(x)
threshold(x, t)
- returns1
forx >= t
and0
otherwise
Example:
"threshold(abs(BAND1 - BAND2), 12.5) * 255"
Convolution¶
Use @
operator or convolve
function with an array of constant values to apply a convolutional filter to a band.
There are also several predefined filters:
box_blur(x)
- uses[[1, 1, 1], [1, 1, 1], [1, 1, 1]] / 9
kernelgauss_blur(x)
- uses[[1, 2, 1], [2, 4, 2], [1, 2, 1]] / 16
kerneledges(x)
- uses[[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]]
kernelsobel_x(x)
- uses[[1, 0, -1], [2, 0, -2], [1, 0, -1]]
kernelsobel_y(x)
- uses[[1, 2, 1], [0, 0, 0], [-1, -2, -1]]
kernel
Examples:
"(BAND1 @ [[1, 2, 1], [2, 4, 2], [1, 2, 1]]) / 16"
"(convolve(BAND1, [[1, 2, 1], [2, 4, 2], [1, 2, 1]]) / 16)"
"gauss_blur(BAND1)"
Operator Precedence¶
Priority |
Operator |
Associativity |
---|---|---|
0 |
|
right to left |
1 |
|
left to right |
2 |
|
left to right |
3 |
|
left to right |