Weighted Sum

Use the WeightedSum API to compute weighted sums in a signal within various regions sizes and positions using the CPU or GPU.

Precisions

The weights are defined for each corner of a region (2 weights in 1D, 4 in 2D, 8 in 3D), in-between weights are computed by linear interpolation.
Optionally the weighted sum can be normalized to get the weighted average.
Weighted sum can be extremely useful to give far more flexibility than the classic flat sum. It can give a sense of probability to the computation, giving more weights where probability is higher. For example think about brows correlation while detecting heads. Brows can be very thin or may be larger so using vertical Haar features with higher weights towards the expected middle of the brows can be interesting. Same for nostrils, etc.
Moreover with 2D weights variations (vertical / horizontal variation) for a same region, you can identify the weights set which maximises the results and infer corresponding gradient orientation information. The use cases are numerous.

Going further

By using multiple adjacent regions with suitable weighing, one can approximate any kernel function, like gaussian, sine/cosine, inverse etc …with piecewise linear weighing while still keeping the constant time compute property. The approximations will then be more accurate with more regions.

Note : At the creation of sigOone (October 2017) and as far as we know, weighted sums in O(1) is not referenced in the state of the art.