Standards /

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.


op be a condenseOpType,
d be some integer with d > 0,
namei be pairwise distinct identifiers which additionally, in the request on hand, are not used already as a variable in this expression's scope,
loi and hii be integers for 1 ≤ i ≤ d with loihii,
P be a booleanExpr possibly containing occurrences of namei,
V be a scalarExpr possibly containing occurrences of namei

1 ≤ i ≤ d.


For any scalarExpr S

S  =  condense op
      over name1 in (lo1,hi1),
           ... ,
           named in (lod,hid)
      [ where P ]
      using v

S is constructed as follows:

Let S = neutral element of type(V); 
for all name1 ∈ {lo1, ... ,hi1}
for all name2 ∈ {lo2, ... ,hi2} ...
for all named ∈ {lod, ... ,hid}
let predicate P' be obtained from expression P by substituting all occurrences of namei by V where (namei,V) ∈ p; if (P') then let V' be obtained from expression V by substituting all occurrences of namei by V where (namei,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).