VPI - Vision Programming Interface

0.1.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

Box image filter is currently implemented using separable image convolver if it satisfies \(max(m,n) \geq 7\) and the input characteristics (size and/or type) satisfies its constraints.

If \(max(m,n) < 7\) it'll use image convolver if input characteristics satisfies its constraints, or else the operation will fail.

Note
Currently, image convolver has some limitations on its PVA backend that makes some box filter operations fail. This is the case when the box filter has \(mn > 49\) on image types VPI_IMAGE_TYPE_Y8 and VPI_IMAGE_TYPE_Y8I.
VPIImageType
VPIImageType
Image formats.
Definition: Types.h:172
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:153
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
All pixels outside the image are considered to be zero.
Definition: Types.h:204
VPIStream
struct VPIStreamImpl * VPIStream
Definition: Types.h:147