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 calculations 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 Padding | Description | Diagram |
---|---|---|
Constant | Each added pixel is assigned the same value. On some blocks and
System objects you can specify the constant value. The value
| In the diagram, |
Replicate | 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. |
Symmetric | 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. |
Reflection | The padding pixels are added such that they reflect around the pixel at the edge of the image. This type of padding is useful for machine learning applications because it removes edge contrast and maintains texture. | The diagram shows the pattern of reflected values assigned to the inactive pixels around the active frame. The pixel values are reflected around the first pixel of the image in both dimensions. |
None | 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 be useful for applications that meet any of these conditions.
For an example, see Increase Throughput by Omitting Padding. | 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. For more detail on blanking intervals,
see Configure Blanking Intervals.
See Also
Image Filter | visionhdl.ImageFilter