addw

[ XITE Reference Manual | XITE home ]

Name

addw - add two bands pixel by pixel, with weights

Syntax

 #include <xite/arithmetic.h>

 int addw( IBAND band1, IBAND band2,
    IBAND output, double w1, double w2,
    double offset );

Description

addw calculates, pixel by pixel, the weighted sum of band1 and band2.

 output(x,y) = w1*band1(x,y) + w2*band2(x,y) + offset

For complex or double complex bands, the result is

 output(x,y).re = w1*band1(x,y).re + w2*band2(x,y).re
                  + offset
 output(x,y).im = w1*band1(x,y).im + w2*band2(x,y).im
                  + offset

If the result is outside the pixeltype range, the result is truncated. Within the pixeltype range, the result is rounded to the nearest possible pixelvalue.

Restriction

Only the largest rectangle common to all three bands are added. All three bands must be of the same pixel type.

Return value

 0 => ok
 1 => bands have different pixel types
 2 => unknown pixel types

See also

addw(1), absDiff(3), signDiff(3), multiply(3), divide(3)

Author

Tor Lønnestad, BLAB, Ifi, UiO

Revised

Svein Bøe, Ifi, UiO. Implemented for all pixel types, not only unsigned byte.

Id

$Id: addw.c,v 1.36 1997/04/23 20:44:28 svein Exp $