Main Content

Edge Padding

To perform a kernel-based operation such as filtering on a pixel at the edge of a frame, Vision HDL Toolbox™ algorithms pad the edges of the frame with extra pixels. These padding pixels are used for internal calculation only. The output frame has the same dimensions as the input frame. The padding operation assigns a pattern of pixel values to the inactive pixels around a frame. Vision HDL Toolbox algorithms provide padding by constant value, replication, or symmetry.

Some blocks and System objects also support opting out of setting the padding pixel values. This option reduces the hardware resources used by the block and the blanking required between frames but affects the accuracy of the output pixels at the edges of the frame.

The diagrams show the top-left corner of a frame, with padding added to accommodate a 5-by-5 filter kernel. When computing the filtered value for the top-left active pixel, the algorithm requires two rows and two columns of padding. The edge of the active image is indicated by the double line.

Type of PaddingDescriptionDiagram

Each added pixel is assigned the same value. On some blocks and System objects you can specify the constant value. The value 0, representing black, is a reserved value in some video standards. Choosing a small number, such as 16, as a near-black padding value, is common.

In the diagram, C is the constant value assigned to the inactive pixels around the active frame.


The pixel values at the edge of the active frame are repeated to make rows and columns of padding pixels.

The diagram shows the pattern of replicated values assigned to the inactive pixels around the active frame.


The padding pixels are added such that they mirror the edge of the image.

The diagram shows the pattern of symmetric values assigned to the inactive pixels around the active frame. The pixel values are symmetric about the edge of the image in both dimensions.


This option excludes padding logic. The line buffer does not set the pixels outside the image frame to any particular value. The kernel calculation uses the current value in the line buffer. To maintain pixel stream timing, the output frame is the same size as the input frame. However, to avoid using pixels calculated from undefined padding values, mask off the KernelSize/2 pixels around the edge of the frame for downstream operations.

Excluding padding can useful for applications that meet any of these conditions.

  • The output video stream does not need to maintain physical timing.

  • The resulting image is not displayed. For example, finding the location of objects in an image.

  • The information of interest is always in the center of the image.

For an example, see Increase Throughput with Padding None.

The diagram shows the undefined values of the inactive pixels around the active frame.

Padding requires minimum horizontal and vertical blanking periods. This interval gives the algorithm time to add and store the extra pixels. The blanking period, or inactive pixel region, must be at least KernelWidth pixels horizontally and KernelHeight lines vertically.

When you set the Padding method to None, the horizontal blanking period must have at least 6 pixels of front porch and 6 pixels of back porch. For the Median Filter block with the Padding method set to None, the horizontal blanking must have at least 10 pixels of front porch and 10 pixels of back porch. The vertical blanking still must be KernelHeight lines.

See Also


Related Topics