VPI - Vision Programming Interface

0.3.7 Release

Box Image Filter

Overview

Box Image Filter is a low-pass filter that smooths the image by making each output pixel the average of the surrounding ones, removing details, noise and and edges from images.

Input Window size Output
5x5

Implementation

Box image filter is implemented as a convolution operation on the input image using the following kernel:

\[ box_{m,n} = \frac{1}{mn} \begin{bmatrix} 1 & 1 & \dots & 1 \\ 1 & 1 & \dots & 1 \\ \vdots & \vdots & \ddots & \vdots \\ 1 & 1 & \dots & 1 \end{bmatrix}_{m \times n} \]

Usage

  1. Initialization phase
    1. Include the header that defines the box 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.
      vpiSubmitBoxImageFilter(stream, input, output, 5, 5, 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
sizetypekernelboundaryCPUCUDAPVA
1920x1080u83x3zero 0.35 ms0.06516 ms1.004 ms
1920x1080u83x3clamp 0.354 ms0.0640 ms1.135 ms
1920x1080u85x5zero 0.44 ms0.0686 ms1.310 ms
1920x1080u87x7zero 0.99 ms0.0876 ms1.930 ms
1920x1080u811x11zero 1.29 ms0.0987 ms3.440 ms
1920x1080u163x3zero 0.43 ms0.10668 ms1.108 ms
1920x1080u163x3clamp 0.42 ms0.1066 ms1.098 ms
1920x1080u165x5zero 0.58 ms0.1146 ms1.598 ms
1920x1080u167x7zero 1.110 ms0.13415 ms2.52 ms
1920x1080u1611x11zero 1.289 ms0.1575 ms4.833 ms
Jetson TX2
sizetypekernelboundaryCPUCUDAPVA
1920x1080u83x3zero 1.48 ms0.260 msn/a
1920x1080u83x3clamp 1.45 ms0.257 msn/a
1920x1080u85x5zero 1.8 ms0.292 msn/a
1920x1080u87x7zero 2.25 ms0.396 msn/a
1920x1080u811x11zero 3.03 ms0.474 msn/a
1920x1080u163x3zero 1.80 ms0.387 msn/a
1920x1080u163x3clamp 1.80 ms0.385 msn/a
1920x1080u165x5zero 2.14 ms0.420 msn/a
1920x1080u167x7zero 2.70 ms0.586 msn/a
1920x1080u1611x11zero 3.43 ms0.680 msn/a
Jetson Nano
sizetypekernelboundaryCPUCUDAPVA
1920x1080u83x3zero 3.047 ms0.673 msn/a
1920x1080u83x3clamp 3.10 ms0.664 msn/a
1920x1080u85x5zero 3.80 ms0.746 msn/a
1920x1080u87x7zero 4.699 ms1.027 msn/a
1920x1080u811x11zero 6.91 ms1.2364 msn/a
1920x1080u163x3zero 3.588 ms0.969 msn/a
1920x1080u163x3clamp 3.56 ms0.978 msn/a
1920x1080u165x5zero 4.21 ms1.018 msn/a
1920x1080u167x7zero 5.44 ms1.393 msn/a
1920x1080u1611x11zero 7.33 ms1.662 msn/a
VPIImageType
VPIImageType
Image formats.
Definition: Types.h:206
vpiSubmitBoxImageFilter
VPIStatus vpiSubmitBoxImageFilter(VPIStream stream, VPIImage input, VPIImage output, uint32_t kernelSizeX, uint32_t kernelSizeY, VPIBoundaryCond boundary)
Runs a 2D box filter over an image.
BoxImageFilter.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.