Synopsis
HxImageRep HxConvolution (HxImageRep img, HxImageRep kernel, HxImageRep::ResultPrecision resPrec)
Input
HxImageRep img
HxImageRep kernel
ResultPrecision resPrec
Return value
HxImageRep
Description
The function HxConvolution convolves the input image with the kernel image. The convolution kernel can be either a scalar or vector image. If the kernel is a scalar image, the input image may be a scalar or a vector image. In case of a scalar kernel and an vector input image, the convolution is taken separately for each channel. If both kernel and image are vector images, the pixel dimension should be the same. In the latter case, each channel of the input image is convolved with the corresponding channel of the kernel.
Remarks
Examples
Convolving an image with a kernel.
#include "HxImageRepGlobalFuncs.h" #include "HxImageRep.h" HxImageRep HxConvolutionExample1(HxImageRep im1, HxImageRep im2) { im1 = HxImageAsDouble(im1); im2 = HxImageAsDouble(im2); im1 = HxConvolution(im1, im2, HxImageRep::DEFAULT_PREC); im1 = HxContrastStretch(im1, 255.0); im1 = HxImageAsByte(im1); return im1; } int main(int argc, char* argv[]) { HxImageRep im1 = HxMakeFromFile(argv[1]); HxImageRep im2 = HxMakeFromFile(argv[2]); im1 = HxConvolutionExample1(im1, im2); HxWriteFile(im1, argv[3]); return 0; }
First input image for the HxConvolution example.
Second input image for the HxConvolution example.
Output image of the HxConvolution example.
In this example an image is convolved with the upper left corner from that image. The example code only works on 2D images.
See also
HxConvKernelSeparated, HxConvGauss2d, HxConvGauss3d, HxConvKernelSeparated2d,
Keywords
Filter, Convolution,