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

HxConvKernelSeparated2d

Synopsis

HxImageRep HxConvKernelSeparated2d (HxImageRep img, HxImageRep kernelX, HxImageRep kernelY, ResultPrecision resPrec = DEFAULT_PREC)

Input

HxImageRep img
The image you want to convolve with the kernel described by the kernelX and kernelY images.

HxImageRep kernelX
The kernel for the convolution in the x-direction. The dimensions of this image should be 1 by x, where x is an arbitrary positive integer.

HxImageRep kernelY
The kernel for the convolution in the y-direction. The dimensions of this image should be 1 by y, where y is an arbitrary positive integer.

ResultPrecision resPrec
This parameter determines the precision of the resulting image. The available precision values are DEFAULT_PREC, SOURCE_PREC, ARITH_PREC, SMALL_PREC . See the section on Precision for a more detailed description about precision.

Return value

HxImageRep
The result of convolving the input image with kernelX and kernelY.

Description

The function HxConvKernelSeparated2d convolves the input image with a 1 by x filter in the x-direction, after which the result of that convolution is convolved with a 1 by y filter in the y-direction. The convolution kernels can be either a scalar or vector images. If the kernels are scalar images, the input image may be a scalar or a vector image. In case of scalar kernels and a vector input image, the convolution (in each direction) 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 kernels. The kernels should have the same pixel dimensionality. Note that both kernels are given in a `1 by q' format.

Remarks

Valid input image types
All 2D types of images are allowed for this function.

Valid kernel image types
The kernelX image should be an image of size 1 by x, where x should be smaller or equal to the size of the input image in the x-direction. The kernelY image should be an image of size 1 by y, where y should be smaller or equal to the size of the input image in the y-direction. If the input image is a vector image, the kernels should be vector images with the same pixel dimension as the input image. The kernels should have the same pixel dimensionality.

Valid precision values
The available precision values are DEFAULT_PREC, SOURCE_PREC, ARITH_PREC, SMALL_PREC . See the section on Precision for a more detailed description about precision.

Border handling
This function uses MIRRORED border handling, see the section on Border handling.

Examples

Convolving an image with two seperate 1d kernels.

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

HxImageRep HxConvKernelSeparated2dExample1(HxImageRep img) {
   img = HxImageAsDouble(img);
   HxImageRep kernelX = HxMakeGaussian1d(3.0, 0, 5.0, 10, -1);
   HxImageRep kernelY = HxMakeParabola1d(1.0, 5.0, 10, -1);
   img = HxConvKernelSeparated2d(img, kernelX, kernelY);
   img = HxContrastStretch(img, 255.0);
   img = HxImageAsByte(img);

   return img;
}

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

    return 0;
}

exampleImage1.gif

Input image for the HxConvKernelSeparated2d example.

HxConvKernelSeparated2dResult1.gif

Output image of the HxConvKernelSeparated2d example.

In this example we generate a 1d Gaussian kernel for the x-direction and a 1d parabola kernel for the y-direction. The input image in this example code is then convolved with the two generated kernels.

See also

HxGaussDerivative2d, HxConvolution, HxConvGauss2d , HxConvKernelSeparated ,

Keywords

Filter, Convolution,


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