Bilateral Filter

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:

Where

and is a gaussian filter with variance .
The gaussian filter is given by:

API Syntax

template void xFBilateralFilter ( xF::Mat src, xF::Mat dst, float sigma_space, float sigma_color )

Parameter Descriptions

The following table describes the template and the function parameters.

Table 1.xFBilateralFilter Function Parameter Descriptions
Parameter Description
FILTER_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 is supported (XF_8UC1)
ROWS Maximum height of input and output image (must be a multiple of 8)
COLS Maximum width of input and output image (must be a multiple of 8)
NPC Number of pixels to be processed per cycle; this function supports only XF_NPPC1 or 1 pixel per cycle operations.
src Input image
dst Output image
sigma_space Standard deviation of filter is 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 usingVivado HLS 2017.1version tool for theXilinx Xczu9eg-ffvb1156-1-i-es1FPGA, to progress a grayscale HD (1080x1920) image.

Table 2.xFBilateralFilter 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

Performance Estimate

The following table summarizes a performance estimate of the kernel in different configurations, as generated usingVivado HLS 2017.1tool forXilinx Xczu9eg-ffvb1156-1-i-es1FPGA, to process a grayscale HD (1080x1920) image.

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

Deviation fromOpenCV

UnlikeOpenCV,xfOpenCVonly supports filter sizes of 3, 5 and 7.