Horus Doc || Global Function Guide || General documentation   | Function documentation  

HxAdd

Synopsis

HxImageRep HxAdd(HxImageRep im1, HxImageRep im2)

Input

HxImageRep im1
The first input image

HxImageRep im2
The second input image

Return value

HxImageRep
The sum of the input images

Description

The function HxAdd adds two images on a pixel-by-pixel basis. Vector pixel types of the same dimension are summed component wise, while pixel types of different dimensions cannot be summed.

Remarks

Admissable image types
The two input images should have the same dimensionality, the same pixeldimensionality and the same size.

Warning for possible overflow
When two byte images are added, where the sum of the maximums of the images is larger than 255, a warning is given that an overflow could have occured. In case the sum of two bytes is larger than 255, the value of that byte pixel will be the sum modulo 256.

Examples

Adding two images

#include "HxImageRepGlobalFuncs.h"
#include "HxImageRep.h"

HxImageRep HxAddExample1(HxImageRep im1, HxImageRep im2) {
   im1 = HxImageAsDouble(im1);
   im2 = HxImageAsDouble(im2);
   im1 = HxAdd(im1, im2);
   im1 = HxContrastStretch(im1, 255);
   im1 = HxImageAsByte(im1);

   return im1;
}

int main(int argc, char* argv[])
{
    HxImageRep im1 = HxMakeFromFile(argv[1]);
    HxImageRep im2 = HxMakeFromFile(argv[2]);
    im1 = HxAddExample1(im1, im2);
    HxWriteFile(im1, argv[3]);

    return 0;
}

exampleImage1.gif

First input image for the HxAdd example.

exampleImage2.gif

Second input image for the HxAdd example.

HxAddResult1.gif

Output image of the HxAdd example.

In this example we add two (scalar) images. First we convert the image to double images to prevent overflow as much as possible. After adding the images, we stretch the result and convert it to byte for visualization purposes.

See also

HxSub, HxMul, HxDiv,

Keywords

Binary, Arithmetic,


Generated on Mon Jan 27 15:44:58 2003 for GlobalFunctionGuide by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001