Synopsis
HxImageRep HxSub(HxImageRep im1, HxImageRep im2)
Input
HxImageRep im1
HxImageRep im2
Return value
HxImageRep
Description
The function HxSub substracts two images on a pixel-by-pixel basis. Vector pixel types of the same dimension are substracted component wise, while pixel types of different dimensions cannot be summed.
Remarks
Examples
Substracting two images
#include "HxImageRepGlobalFuncs.h" #include "HxImageRep.h" HxImageRep HxSubExample1(HxImageRep im1, HxImageRep im2) { im1 = HxImageAsDouble(im1); im2 = HxImageAsDouble(im2); im1 = HxSub(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 = HxSubExample1(im1, im2); HxWriteFile(im1, argv[3]); return 0; }
First input image for the HxSub example.
Second input image for the HxSub example.
Output image of the HxSub example.
In this example we substract two (scalar) images. First we convert the image to double images to prevent overflow as much as possible. After substracting the images, we stretch the result and convert it to byte for visualization purposes.
See also
Keywords
Binary, Arithmetic,