WCPS-Manual / generalCondenseExpr

The general generalCondenseExpr consolidates cell values
of a coverage along selected axes to a scalar value based on the condensing
operation indicated. It iterates over a given domain while combining the result
values of the scalarExprs
through the **condenseOpType** indicated.

Any summarisation function s() is admissible for a generalCondenseExpr over some coverage if it has the following properties:

- s() is a binary function between values of the coverage range type;
- s() is commutative and associative.

Binary "+" on floating point numbers is admissible for a condenser on a float coverage, while binary "-" is not.

Let

op be a **condenseOpType**,

d be some **integer** with d > 0,

name_{i} be pairwise
distinct **identifier**s which additionally, in the request on hand, are not
used already as a variable in this expression's scope,

lo_{i} and hi_{i} be integers
for 1 ≤ i ≤ d with lo_{i}
≤ hi_{i},

P be a booleanExpr
possibly containing occurrences of name_{i},

V be a scalarExpr possibly containing occurrences of name_{i}

where

1 ≤ i ≤ d.

Then,

For any scalarExpr
S

where

S = condense op over name_{1}in (lo_{1},hi_{1}), ... , name_{d}in (lo_{d},hi_{d}) [ where P ] using v

Let S = neutral element of type(V);

for all name_{1}∈ {lo_{1}, ... ,hi_{1}}

for all name_{2}∈ {lo_{2}, ... ,hi_{2}} ...

for all name_{d}∈ {lo_{d}, ... ,hi_{d}}

let predicate P' be obtained from expression P by substituting all occurrences of name_{i}by V where (name_{i},V) ∈ p; if (P') then let V' be obtained from expression V by substituting all occurrences of name_{i}by V where (name_{i},V) ∈ p; S = S op value(V'); return S

Null values encountered **shall** be treated according to the :

- if at least one non-null value is encountered in the repeated evaluation of V, then all null values **shall** be ignored;

- if V is not evaluated at least once, or if there are
only null-valued input values, then the overall result **shall** be null.

For a filter kernel k, the condenser must summarise not only over the cell under inspection, but also some neighbourhood. The following applies a filter kernel to some coverage C; note that the result image is defined to have an x and y type axis.

coverage filteredImage over px x(imageCrsDomain(C,x)), py y(imageCrsDomain(C,y)) values condense + over kx x(imageCrsDomain(k,x)), ky y(imageCrsDomain(k,y)) using C[ (x(kx+px), y(ky+py) ] * k[ x(fx), y(fy) ]

where k is a 3x3 matrix like

1 | 3 | 1 |

0 | 0 | 0 |

-1 | -3 | -1 |

NOTE See **coverageConstExpr** for a way to specify the
k matrix.

NOTE Condensers are heavily used, among others, in these two situations:

- To collapse Boolean-valued coverage expressions into scalar Boolean values so that they can be used in predicates.
- In conjunction with the coverageConstructorExpr to phrase high-level imaging, signal processing and statistical operations.

NOTE additional expressive power of condenseExpr over reduceExpr is twofold:

- A WCPS implementation may offer further summarisation functions.
- The condenseExpr gives explicit access to the coordinate values; this makes summarisation considerably more powerful (see example below).