Custom Convolution
ThexFfilter2D
function performs convolution over an image using a user-defined kernel.
Convolution is a mathematical operation on two functionsfandg, producing a third function, The third function is typically viewed as a modified version of one of the original functions, that gives the area overlap between the two functions to an extent that one of the original functions is translated.
The filter can be unity gain filter or a non-unity gain filter. The filter must be of type AU_16SP. If the co-efficients are floating point, it must be converted into the Qm.n and provided as the input as well as the shift parameter has to be set with the ‘n’ value. Else, if the input is not of floating point, the filter is provided directly and the shift parameter is set to zero.API Syntax
template void xFfilter2D(xF::Mat & _src_mat,xF::Mat & _dst_mat,short int filter[FILTER_HEIGHT*FILTER_WIDTH],unsigned char _shift)
Parameter Descriptions
The following table describes the template and the function parameters.
Parameter | Description |
---|---|
BORDER_TYPE | Border Type supported is XF_BORDER_CONSTANT |
FILTER_HEIGHT | Number of rows in the input filter |
FILTER_WIDTH | Number of columns in the input filter |
SRC_T | Input pixel type. Only 8-bit, unsigned, 1 channel is supported (XF_8UC1) |
DST_T | Output pixel type.8-bit unsigned single channel (XF_8UC1) and 16-bit signed single channel (XF_16SC1) supported. |
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; possible options are XF_NPPC1 and XF_NPPC8 for 1 pixel and 8 pixel operations respectively. |
_src_mat | Input image |
_dst_mat | Output image |
filter | The input filter of any size, provided the dimensions should be an odd number. The filter co-efficients either a 16-bit value or a 16-bit fixed point equivalent value. |
_shift | The filter must be of type XF_16SP. If the co-efficients are floating point, it must be converted into the Qm.n and provided as the input as well as the shift parameter has to be set with the ‘n’ value. Else, if the input is not of floating point, the filter is provided directly and the shift parameter is set to zero. |
Resource Utilization
The following table summarizes the resource utilization of the kernel in different configurations, generated usingVivado HLS 2017.1tool for theXilinx Xczu9eg-ffvb1156-1-i-es1FPGA, to process a grayscale HD (1080x1920) image.
Operating Mode | Filter Size | Operating Frequency (MHz) |
Utilization Estimate | ||||
---|---|---|---|---|---|---|---|
BRAM_18K | DSP_48Es | FF | LUT | CLB | |||
1 pixel | 3x3 | 300 | 3 | 9 | 1701 | 1161 | 269 |
5x5 | 300 | 5 | 25 | 3115 | 2144 | 524 | |
8 pixel | 3x3 | 150 | 6 | 72 | 2783 | 2768 | 638 |
5x5 | 150 | 10 | 216 | 3020 | 4443 | 1007 |
Performance Estimate
The following table summarizes the performance of the kernel in different configurations, as generated using Vivado HLS 2017.1 tool for theXilinx Xczu9eg-ffvb1156-1-i-es1, to process a grayscale HD (1080x1920) image.
Operating Mode | Operating Frequency (MHz) |
Filter Size | Latency Estimate |
---|---|---|---|
Max (ms) | |||
1 pixel | 300 | 3x3 | 7 |
300 | 5x5 | 7.1 | |
8 pixel | 150 | 3x3 | 1.86 |
150 | 5x5 | 1.86 |