VPI - Vision Programming Interface

0.2.0 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);

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.4 ms0.0647 ms0.9614 ms
1920x1080u83x3clamp 0.675 ms0.0637 ms1.0782 ms
1920x1080u85x5zero 0.43 ms0.0690 ms1.2316 ms
1920x1080u87x7zero 0.98 ms0.0881 ms1.7586 ms
1920x1080u811x11zero 1.30 ms0.0994 ms3.2608 ms
1920x1080u163x3zero 0.839 ms0.1075 ms1.0610 ms
1920x1080u163x3clamp 0.815 ms0.1071 ms1.0676 ms
1920x1080u165x5zero 1.3 ms0.1153 ms1.5123 ms
1920x1080u167x7zero 1.08 ms0.1353 ms2.3511 ms
1920x1080u1611x11zero 1.284 ms0.1582 ms4.6477 ms
Jetson TX2
sizetypekernelboundaryCPUCUDAPVA
1920x1080u83x3zero 1.5 ms0.255 msn/a
1920x1080u83x3clamp 1.41 ms0.255 msn/a
1920x1080u85x5zero 1.72 ms0.288 msn/a
1920x1080u87x7zero 2.29 ms0.395 msn/a
1920x1080u811x11zero 2.99 ms0.472 msn/a
1920x1080u163x3zero 1.86 ms0.380 msn/a
1920x1080u163x3clamp 1.84 ms0.377 msn/a
1920x1080u165x5zero 2.2 ms0.423 msn/a
1920x1080u167x7zero 2.55 ms0.578 msn/a
1920x1080u1611x11zero 3.37 ms0.677 msn/a
Jetson Nano
sizetypekernelboundaryCPUCUDAPVA
1920x1080u83x3zero 3.00 ms0.6692 msn/a
1920x1080u83x3clamp 2.995 ms0.6591 msn/a
1920x1080u85x5zero 3.792 ms0.7444 msn/a
1920x1080u87x7zero 4.76 ms1.025 msn/a
1920x1080u811x11zero 6.77 ms1.237 msn/a
1920x1080u163x3zero 3.550 ms0.964 msn/a
1920x1080u163x3clamp 3.56 ms0.969 msn/a
1920x1080u165x5zero 4.21 ms1.018 msn/a
1920x1080u167x7zero 5.305 ms1.386 msn/a
1920x1080u1611x11zero 7.44 ms1.657 msn/a
VPIImageType
VPIImageType
Image formats.
Definition: Types.h:190
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)...
VPIImage
struct VPIImageImpl * VPIImage
Definition: Types.h:170
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.
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.
VPI_BOUNDARY_COND_ZERO
@ VPI_BOUNDARY_COND_ZERO
All pixels outside the image are considered to be zero.
Definition: Types.h:251
VPIStream
struct VPIStreamImpl * VPIStream
Definition: Types.h:164