Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
calculate_map [2011/07/24 23:44] hermann [Image Neighborhood Operators] |
calculate_map [2022/08/19 23:49] admin [Notes] |
||
---|---|---|---|
Line 7: | Line 7: | ||
===== Inputs ===== | ===== Inputs ===== | ||
- | ^ Name ^ Type ^ Description ^ | + | ^ Name ^ Type ^ Description ^ |
- | | Expression | [[Image Expression Type | Image Expression]] | Algebraic or logical expression used to calculate the output map. | | + | | Expression | [[Image Expression Type]] | Algebraic or logical expression used to calculate the output map. | |
===== Optional Inputs ===== | ===== Optional Inputs ===== | ||
- | ^ Name ^ Type ^ Description ^ Default Value ^ | + | ^ Name ^ Type ^ Description ^ Default Value ^ |
- | | Cell Type | [[Cell Type Type | Cell Type]] | Data cell type | Signed 32 Bit Integer | | + | | Cell Type | [[Cell Type Type]] | Data cell type | Signed 32 Bit Integer | |
- | | Null Value | [[Int Type | Int]] | Null value | -2147483648 | | + | | Null Value | [[Null Value Type]] | Null value | Default((Based on the value of the Cell Type input.)) | |
- | | Result Is Sparse | [[Bool Type | Bool]] | If true, the resulting map is created as a sparse image. Sparse images have the advantage of storing only the cells containing non-null values, but they have diminished access time. | False | | + | | Result Is Sparse | [[Boolean Value Type]] | If true, the resulting map is created as a sparse image. Sparse images have the advantage of storing only the cells containing non-null values, but they have diminished access time. | False | |
+ | | Result Format | [[Map Type]] | Map representing the output format. Any category information presents in the given map is not used as part of the map format. | None | | ||
===== Outputs ===== | ===== Outputs ===== | ||
- | ^ Name ^ Type ^ Description ^ | + | ^ Name ^ Type ^ Description ^ |
- | | Result | [[Map Type | Map]] | Output map. | | + | | Result | [[Map Type]] | Output map. | |
===== Group ===== | ===== Group ===== | ||
Line 30: | Line 31: | ||
The expression result is calculated as a real value and converted to the data cell type of the output map. | The expression result is calculated as a real value and converted to the data cell type of the output map. | ||
- | If the calculation of the expression diverges or if the data cell type is not large enough, the corresponding cell is filled with the null value. | + | If the calculation of the expression diverges, the corresponding cell is filled with the null value. In practice, it means that every time a null value is found in a expression calculation, the calculation results in null value, unless the occurrence of the null value is isolated from the rest of the expression by a special operator like ''[[image_expression_type#image_operators_and_functions|isNull()]]'' or ''[[image_expression_type#general_operators|?]]''. |
- | List of mathematical and logical operators, in order of precedence that can be employed in the logic/algebraic expression. Operators separated by blank lines have the same precedence. | + | The examples below illustrates: |
- | ==== General Operators ==== | + | ^ Example ^ Analysis ^ |
+ | | <code cpp>i1 / 0</code> | The expression always results in null value (division by zero). | | ||
+ | | <code cpp>i1 + i2 / i3 ^ 3</code> | If the current cell of any of the images involved in the calculation is null value, the expression results in null value . | | ||
+ | | <code cpp>if isNull(i1) then | ||
+ | 1 | ||
+ | else | ||
+ | 2 | ||
+ | </code> | The expression never results in null value. | | ||
+ | | <code cpp>if isNull(i1) then | ||
+ | i2 | ||
+ | else | ||
+ | i3 | ||
+ | </code> | The expression might result in null value depending on the the value of i2 and i3. | | ||
+ | | <code cpp>(100 / i2) ? 0</code> | The expression never results in null value. | | ||
+ | | <code cpp>(100 / i2) ? i1</code> | The expression might result in null value depending on the the value of i1. | | ||
- | ^ Operator ^ Description ^ Symbol ^ Usage Example ^ | + | If the data cell type is not large enough, the corresponding cell is also filled with the null value. |
- | | Boolean Or | | or \\ <nowiki>||</nowiki> | not isNull(i1) or isNull(i2) \\ not isNull(i1) <nowiki>||</nowiki> isNull(i2) | | + | |
- | | Boolean And | | and \\ && | not isNull(i1) and isNull(i2) \\ not isNull(i1) && isNull(i2) | | + | |
- | | Equal | | = \\ == | i1 = 2 \\ i1 == 2 | | + | |
- | | Not Equal | | != \\ /= \\ <> | i1 != 2 \\ i1 /= 2 \\ i1 <> 2 | | + | |
- | | Greater Than | | > | i1 > 2 | | + | |
- | | Greater Than Or Equal | | >= | i1 >= 2 | | + | |
- | | Less Than | | < | i1 < i2 | | + | |
- | | Less Than Or Equal | | <nowiki><=</nowiki> | i1 <nowiki><=</nowiki> i2 | | + | |
- | | Add | | + | i1 + i2 | | + | |
- | | Subtract | | – | i1 – i1 / i2 | | + | |
- | | Times | | * | i1 * i2 | | + | |
- | | Divide | | / | i1 / i2 | | + | |
- | | Mod | | % | i1 % 100 | | + | |
- | | Power | | <nowiki>^</nowiki> | i1 <nowiki>^</nowiki> 3 | | + | |
- | | Catch Error | Catch an algebraic error and replace it with the result of another expression | ? | (i1 / i2) ? (i1 – i2) | | + | |
- | | Boolean Not | | ! \\ not | not isNull(i1) \\ ! isNull(i1) | | + | |
- | | Value | | | 2 + i1 / -3.5e-2 | | + | |
- | | Random | Generate a random value using the uniform probability distribution | rand | if rand > 0.5 then 1 else i2 | | + | |
- | | Negate | | – | – ceil(i1 + i2) | | + | |
- | | Squared Root | | sqrt() | sqrt(i1 / i4) | | + | |
- | | Sin | Sin (input in radians) | sin() | sin(i1 / i4) | | + | |
- | | Cos | Cos (input in radians) | cos() | cos(i1 + i2) | | + | |
- | | Tan | Tan (input in radians) | tan() | tan(i1 * i5 + 6) | | + | |
- | | Acos | Acos (output in radians) | acos() | acos(i1 + i2) | | + | |
- | | Asin | Asin (output in radians) | asin() | asin(i1 + i2) | | + | |
- | | Atan | Atan (output in radians) | atan() | atan(i1 + i2) | | + | |
- | | Ceil | | ceil() | ceil(i1 + i2) | | + | |
- | | Exp | | exp() | exp(i1[i1 + i2]) | | + | |
- | | Floor | | floor() | floor(i1 + i2) | | + | |
- | | Round | | round() | round(i1 / i4) | | + | |
- | | Abs | | abs() | abs(i1 + i2) | | + | |
- | | Ln | | ln() | ln(i1 / i4) | | + | |
- | | Log | | log() | log(i1 / i4) | | + | |
- | | Max | | max() | max(i1, i2) | | + | |
- | | Min | | min() | min(i1, i4) | | + | |
- | | Signal | Return +1, if the expression is positive, -1, if it is negative, and 0, otherwise. | signal() | signal(i1 - 4) | | + | |
- | | Abort | Abort the model execution | abort | if i1 > 0 then i1 * i2 + 4 else abort | | + | |
- | | Conditional | Execute the second or third term of the equation conditionally to the first | if then else | if not isNull(i1) and isNull(i2) then i3 else if isNull(i1) then i1 – i1 / i2 else (i1 / i2) ? (i1 – i2) | | + | |
- | ==== Value Operators ==== | + | The list of mathematical and logical operators that can be employed in the logic/algebraic expression can be found in the [[Image Expression Type | image expression reference]]. |
- | ^ Operator ^ Description ^ Symbol ^ Usage Example ^ | + | The maps used by the "Calculate Map" must be provided by a corresponding [[Number Map]], the tables must be provided by a corresponding [[Number Table]] and the values must be provided by a corresponding [[Number Value]]. |
- | | Get Variable Value | Return the variable value | vX \\ where X is an integer value from 1 to 100 | v1 + t1[v2 + 4] | | + | |
- | ==== Image Operators ==== | + | For additional information about how the null values are handled during image and value calculation, see [[Image Expression Null Value Handling|this reference]]. |
- | + | ||
- | ^ Operator ^ Description ^ Symbol ^ Usage Example ^ | + | |
- | | Get Image Value | Return the image value at the current cell | iX \\ where X is an integer value from 1 to 100 | i2 | | + | |
- | | Get Image Value At Location | Return the image value on the specified cell coordinate | iX[ , ] \\ where X is an integer value from 1 to 100 | i1[line – 1, column – 2] | | + | |
- | | Get Image Null Value | Return the null value of the current image | null \\ null(iX) | if i1 > 2 then i1 else null \\ if null(i2) > 2 then 1 else null | | + | |
- | | Is Null | | isNull(iX) \\ where X is an integer value from 1 to 100 | if not isNull(i1) then i1 else i2 | | + | |
- | | Get Line Number | Return the line number of the current cell | line | line + 1 | | + | |
- | | Get Column Number | Return the column number of the current cell | column | if column / 2 > 50 then 1 else null | | + | |
- | + | ||
- | ==== Table Operators ==== | + | |
- | + | ||
- | Table operators return the value corresponding to a given key according to a rule-operator. | + | |
- | + | ||
- | It uses the following syntax: tX[N ] \\ where: X is a table identifier; N is the rule-operator. | + | |
- | + | ||
- | ^ Operator ^ Description ^ Symbol ^ Usage Example ^ | + | |
- | | Get Table Value | Return the table value in the X key position of the table | tX[ ] \\ where X is an integer value from 1 to 100 | t2[i1 + 2] | | + | |
- | | Get Table Equal Lower Bound Value | Return the table value in the greater key less than or equal to the X key position of the table. | tX[<= ] \\ tX{ } \\ where X is an integer value from 1 to 100 | 2[<= 14] \\ t2{14} | | + | |
- | | Get Table Lower Bound Value | Return the table value in the greater key less than the X key position of the table. | tX[< ] \\ where X is an integer value from 1 to 100 | t2[< i1 + 2] | | + | |
- | | Get Table Equal Upper Bound Value | Return the table value in the lesser key greater than or equal to the X key position of the table. | tX[>= ] \\ where X is an integer value from 1 to 100 | t2[>= i1 + i3]= | | + | |
- | | Get Table Upper Bound Value | Return the table value in the lesser key greater than the X key position of the table. | tX[> ] \\ where X is an integer value from 1 to 100 | t2[> i7] | | + | |
- | | Get Table Closest Value | Return the table value in the key closest to the X key position of the table. | tX[>< ] \\ where X is an integer value from 1 to 100 | t2[>< 3 + i7] | | + | |
- | | Get Table Interpoled Value | Return a linear interpoled value drawn through the neighbor keys of the X key position of the table. | tX[/ ] \\ where X is an integer value from 1 to 100 | t2[/ i2] | | + | |
- | | Test Table Key | Return 1, if expression corresponds to a key stored in the table, and 0, otherwise. | tX[? ] \\ tX[=? ] \\ tX[==? ] \\ where X is an integer value from 1 to 100 | t2[? i2] \\ t2[=? i2] | | + | |
- | + | ||
- | ==== Image Neighborhood Operators ==== | + | |
- | + | ||
- | Neighborhood operators return the value of an operation within a defined neighborhood window. | + | |
- | It uses the following syntax: nbN(iX, h, w, y, x) \\ where: N is the operator name; X is an image identifier; h is the number of window lines; w is the number of window columns; y is the line where the window center is anchored at the image; x is the column where the window center is anchored at the image. | + | |
- | + | ||
- | The calculation usually includes the center of the window. | + | |
- | + | ||
- | Even-sided windows have the center displaced toward the top left corner. | + | |
- | + | ||
- | The window anchor (y and x) can be omitted when the window center is anchored at the current line and column. The shortened syntax is: nbN(iX, h, w) | + | |
- | + | ||
- | ^ Operator ^ Description ^ Symbol ^ Usage Example ^ | + | |
- | | Min | Returns the minimum value of the neighbor non-null cells. | nbMin() | nbMin(i4, 2, 3, line-1, column) | | + | |
- | | Max | Returns the maximum value of the neighbor non-null cells. | nbMax() | nbMax(i1, 4, 4) - 1 | | + | |
- | | Sum | Returns the sum of the neighbor non-null cells. | nbSum() | nbSum(i3, 5, 5) + 7 | | + | |
- | | Product | Returns the product of the neighbor non-null cells. | nbProd() | if not isNull(i1) then nbProd(i1, 2, 2, 0, column) else 0 | | + | |
- | | Count | Returns the number of neighbor non-null cells. | nbCount() | nbCount(i2, 3, 3) + nbCount(i1, 3, 3, line, column+3) | | + | |
- | | Average | Returns the arithmetic mean of the neighbor non-null cells. | nbAverage() | round(nbAverage(i1, 7, 7)) | | + | |
- | | Median | Returns the median value of the neighbor non-null cells. For an even number of values, the greater of the two median values is returned. | nbMedian() | nbMedian(i1, 5, 5) | | + | |
- | | Mode | Returns the mode of the neighbor non-null cells. If a mode does not exist, null is returned. If there is more than one, the lesser one is returned. | nbMode() | nbMode(i1, 5, 5) | | + | |
- | | Variance | Returns the variance of the values of the neighbor non-null cells according to the expression: <m 8>sigma^2 = {1/{n-1}}sum{i=1}{n}{(x_i-X)^2}</m> \\ where x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>i</sub> are the neighbor cells; X is the mean of the neighbor cells. | nbVar() | nbVar(i4, 7, 7) / 25 | | + | |
- | | Standard Deviation | Returns the standard deviation of the neighbor non-null cells according to the expression: <m 6>sigma = sqrt{{1/{n-1}}sum{i=1}{n}{(x_i-X)^2}}</m> \\ where x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>i</sub> are the neighbor cells; X is the mean of the neighbor cells. | nbStdDev() | nbStdDev(i2, 3, 3, line-1, column) + nbStdDev(i2, 3, 3) + nbStdDev(i2, 3, 3, line+1, column) | | + | |
- | + | ||
===== Internal Name ===== | ===== Internal Name ===== | ||
CalculateMap | CalculateMap | ||
- |