Bilateral Filter - 2023.2 English

Vitis Libraries

Release Date
2023-12-20
Version
2023.2 English

In general, any smoothing filter smoothens the image which will affect the edges of the image. To preserve the edges while smoothing, a bilateral filter can be used. In an analogous way as the Gaussian filter, the bilateral filter also considers the neighboring pixels with weights assigned to each of them. These weights have two components, the first of which is the same weighing used by the Gaussian filter. The second component takes into account the difference in the intensity between the neighboring pixels and the evaluated one.

The bilateral filter applied on an image is:
image10
Where
image11
and image12 is a gaussian filter with variance image13.

The gaussian filter is given by: image14

API Syntax

template<int FILTER_SIZE, int BORDER_TYPE, int TYPE, int ROWS, int COLS, int NPC=1, int XFCVDEPTH_IN_1 = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT_1 = _XFCVDEPTH_DEFAULT>
void bilateralFilter (
xf::cv::Mat<TYPE, ROWS, COLS, NPC, XFCVDEPTH_IN_1>& src,
xf::cv::Mat<TYPE, ROWS, COLS, NPC, XFCVDEPTH_OUT_1>& dst,
float sigma_space, float sigma_color )

Parameter Descriptions

The following table describes the template and the function parameters.

Table 300 Table bilateralFilter Parameter Description
Parameter Description
WINDOW_SIZE Filter size. Filter size of 3 (XF_FILTER_3X3), 5 (XF_FILTER_5X5) and 7 (XF_FILTER_7X7) are supported
BORDER_TYPE Border type supported is XF_BORDER_CONSTANT
TYPE Input and output pixel type. Only 8-bit, unsigned, 1 channel, and 3 channels are supported (XF_8UC1 and XF_8UC3)
ROWS Maximum height of input and output image.
COLS Maximum width of input and output image (must be multiple of 8, for 8-pixel operation)
NPC Number of pixels to be processed per cycle; this function supports XF_NPPC1 and XF_NPPC4.
XFCVDEPTH_IN_1 Depth of input image
XFCVDEPTH_OUT_1 Depth of output image
src Input image
dst Output image
sigma_space Standard deviation of filter in spatial domain
sigma_color Standard deviation of filter used in color space

Resource Utilization

The following table summarizes the resource utilization of the kernel in different configurations, generated using Vivado HLS 2019.1 version tool for the Xczu9eg-ffvb1156-1-i-es1 FPGA, to progress a grayscale HD (1080x1920) image.

Table 301 Table bilateralFilter Resource Utilization Summary
Operating Mode Filter Size Operating Frequency (MHz) Utilization Estimate
BRAM_18K DSP_48Es FF LUT
1 Pixel 3x3 300 6 22 4934 4293
5x5 300 12 30 5481 4943
7x7 300 37 48 7084 6195

The following table summarizes the resource utilization of the kernel in different configurations, generated using Vivado HLS 2019.1 version tool for the Xczu9eg-ffvb1156-1-i-es1 FPGA, to progress a 4K 3 channel image.

Table 302 Table bilateralFilter Resource Utilization Summary
Operating Mode Filter Size Operating Frequency (MHz) Utilization Estimate
BRAM_18K DSP_48Es FF LUT
1 Pixel 3x3 300 12 32 8342 7442
5x5 300 27 57 10663 8857
7x7 300 49 107 12870 12181

Performance Estimate

The following table summarizes a performance estimate of the kernel in different configurations, as generated using Vivado HLS 2019.1 tool for Xczu9eg-ffvb1156-1-i-es1 FPGA, to process a grayscale HD (1080x1920) image.

Table 303 Table 35. bilateralFilter Function Performance Estimate Summary
Operating Mode Filter Size Latency Estimate
300 MHz
Max Latency (ms)
1 pixel 3x3 7.18
5x5 7.20
7x7 7.22

Deviation from OpenCV

Unlike OpenCV, Vitis Vision only supports filter sizes of 3, 5 and 7.