VPI - Vision Programming Interface

0.3.7 Release

Gaussian Image Filter

Overview

Gaussian image filter is a low-pass discrete Gaussian filter that smooths out the image by doing a Gaussian-weighted averaging of neighbor pixels of a given input pixel. It produces images with less artifacts than Box Image Filter, but could potentially be more costly to compute.

It supports two modes of operation:

  • Kernel support size is automatically calculated based on the filter standard deviation (sigma).
  • Use both user-provided kernel support size and filter standard deviation.
Input Gaussian kernel Output
7x7 support,

\[ \sigma=1.7 \]

Implementation

Gaussian filter is implemented as a convolution operation on the input image where the kernel has the following weights:

\[ w_g[x,y] = \frac{1}{2\pi\sigma^2} \cdot e^{-\frac{x^2+y^2}{2\sigma^2}} \]

When the input kernel support size is 0 for a given dimension (or both), it is calculated from the given standard deviation by assuming that the weights outside \(\pm3\sigma\) window are zero.

In this case, the following formula is used:

\[ w = \max\{3,2 \times \lceil 3\sigma\rceil-1\} \]

Note
We clamp the minimum kernel size to 3 because a kernel with size 1 doesn't have enough samples to properly characterize a Gaussian function.

Usage

  1. Initialization phase
    1. Include the header that defines the Gaussian filter function.
    2. Define the stream on which the algorithm will be executed, the input and output images.
      VPIStream stream = /*...*/;
      VPIImage input = /*...*/;
    3. Create the output image.
      uint32_t w, h;
      vpiImageGetSize(input, &w, &h);
      vpiImageGetType(input, &type);
      VPIImage output;
      vpiImageCreate(w, h, type, 0, &output);
  2. Processing phase
    1. Submit the algorithm to the stream, input, output images, window size and boundary condition.
      vpiSubmitGaussianImageFilter(stream, input, output, 7, 7, 1.7, 1.7, VPI_BOUNDARY_COND_ZERO);
    2. Optionally, wait until the processing is done.
      vpiStreamSync(stream);

For more details, consult the API reference.

Limitations and Constraints

Constraints for specific backends supersede the ones specified for all backends.

All Backends

PVA

Performance

For further information on how performance was benchmarked, see Performance Measurement.

Jetson AGX Xavier
sizetypekernelCPUCUDAPVA
1920x1080u83x3 0.27 ms0.0652 ms1.017 ms
1920x1080u85x5 0.564 ms0.0689 ms1.318 ms
1920x1080u87x7 0.65 ms0.0882 ms1.958 ms
1920x1080u811x11 0.89 ms0.0992 ms3.45 ms
1920x1080u163x3 0.43 ms0.1070 ms1.117 ms
1920x1080u165x5 0.59 ms0.1159 ms1.595 ms
1920x1080u167x7 1.12 ms0.1346 ms2.521 ms
1920x1080u1611x11 1.29 ms0.1579 ms4.83 ms
Jetson TX2
sizetypekernelCPUCUDAPVA
1920x1080u83x3 0.831 ms0.259 msn/a
1920x1080u85x5 1.02 ms0.292 msn/a
1920x1080u87x7 1.14 ms0.397 msn/a
1920x1080u811x11 1.58 ms0.472 msn/a
1920x1080u163x3 1.97 ms0.390 msn/a
1920x1080u165x5 2.1 ms0.422 msn/a
1920x1080u167x7 2.72 ms0.584 msn/a
1920x1080u1611x11 3.39 ms0.679 msn/a
Jetson Nano
sizetypekernelCPUCUDAPVA
1920x1080u83x3 1.559 ms0.669 msn/a
1920x1080u85x5 2.269 ms0.746 msn/a
1920x1080u87x7 2.72 ms1.024 msn/a
1920x1080u811x11 3.029 ms1.236 msn/a
1920x1080u163x3 3.58 ms0.976 msn/a
1920x1080u165x5 4.21 ms1.021 msn/a
1920x1080u167x7 5.269 ms1.392 msn/a
1920x1080u1611x11 7.31 ms1.663 msn/a
VPIImageType
VPIImageType
Image formats.
Definition: Types.h:206
GaussianImageFilter.h
vpiStreamSync
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
VPIStream
struct VPIStreamImpl * VPIStream
A handle to a stream.
Definition: Types.h:177
VPIImage
struct VPIImageImpl * VPIImage
A handle to an image.
Definition: Types.h:183
vpiImageGetSize
VPIStatus vpiImageGetSize(VPIImage img, uint32_t *width, uint32_t *height)
Get the image size in pixels.
vpiImageGetType
VPIStatus vpiImageGetType(VPIImage img, VPIImageType *type)
Get the image type.
VPI_BOUNDARY_COND_ZERO
@ VPI_BOUNDARY_COND_ZERO
All pixels outside the image are considered to be zero.
Definition: Types.h:270
vpiImageCreate
VPIStatus vpiImageCreate(uint32_t width, uint32_t height, VPIImageType type, uint32_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
vpiSubmitGaussianImageFilter
VPIStatus vpiSubmitGaussianImageFilter(VPIStream stream, VPIImage input, VPIImage output, uint32_t kernelSizeX, uint32_t kernelSizeY, float sigmaX, float sigmaY, VPIBoundaryCond boundary)
Runs a 2D Gaussian filter over an image.