Sobel Filter - 2024.1 English

Vitis Libraries

Release Date
2024-05-30
Version
2024.1 English

The Sobel function Computes the gradients of input image in both x and y direction by convolving the kernel with input image being processed.

  • For Kernel size 3x3
    • GradientX: 22.17 G x = - 1 0 1 - 2 0 2 - 1 0 1 * I
    • GradientY: image150
  • For Kernel size 5x5
    • GradientX: image151
    • GradientY: image152
  • For Kernel size 7x7
    • GradientX: image153
    • GradientY: image154

API Syntax

template<int BORDER_TYPE,int FILTER_TYPE, int SRC_T,int DST_T, int ROWS, int COLS,int NPC=1, bool USE_URAM=false, int XFCVDEPTH_IN = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT_X = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT_Y = _XFCVDEPTH_DEFAULT>
void Sobel(xf::cv::Mat<SRC_T, ROWS, COLS, NPC, XFCVDEPTH_IN> & _src_mat,xf::cv::Mat<DST_T, ROWS, COLS, NPC, XFCVDEPTH_OUT_X> & _dst_matx,xf::cv::Mat<DST_T, ROWS, COLS, NPC, XFCVDEPTH_OUT_Y> & _dst_maty)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 726 Table . Sobel Parameter Description
Parameter Description
FILTER_TYPE 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
SRC_T Input pixel type. Only 8-bit, unsigned, 1 and 3 channels are supported (XF_8UC1 and XF_8UC3)
DST_T Output pixel type. Only 8-bit unsigned, 16-bit signed,1 and 3 channels are supported (XF_8UC1, XF_16SC1,XF_8UC3 and XF_16SC3)
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; possible options are XF_NPPC1 and XF_NPPC8 for 1 pixel and 8 pixel operations respectively.
USE_URAM Enable to map storage structures to UltraRAM
XFCVDEPTH_IN Depth of the input image.
XFCVDEPTH_OUT_X Depth of the output image.
XFCVDEPTH_OUT_Y Depth of the output image.
_src_mat Input image
_dst_matx X gradient output image.
_dst_maty Y gradient output image.
  1. Sobel 7x7 8-pixel is not supported.

Resource Utilization

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

Table 727 Table . Sobel Function Resource Utilization Summary
Operating Mode Filter Size

Operating Frequency

(MHz)

Utilization Estimate
BRAM_18K DSP_48Es FF LUT CLB
1 pixel 3x3 300 3 0 609 616 135
  5x5 300 5 0 1133 1499 308
  7x7 300 7 0 2658 3334 632
8 pixel 3x3 150 6 0 1159 1892 341
  5x5 150 10 0 3024 5801 999

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

Table 728 Table . Sobel Function Resource Utilization Summary
Operating Mode Filter Size

Operating Frequency

(MHz)

Utilization Estimate
BRAM_18K DSP_48Es FF LUT
1 pixel 3x3 300 18 0 1047 1107
  5x5 300 30 0 5370 3312
  7x7 300 42 0 6100 5496

The following table summarizes the resource utilization of the kernel in different configurations, generated using Vivado HLS 2019.1 tool for the Xilinx xczu7ev-ffvc1156-2-e FPGA, to process a grayscale 4K (3840x2160) image with UltraRAM enable.

Table 729 Table . Sobel Function Resource Utilization Summary with UltraRAM enable
Operating Mode Filter Size

Operating Frequency

(MHz)

Utilization Estimate
BRAM_18K URAM DSP_48Es FF LUT
1 pixel 3x3 300 0 1 0 919 707
  5x5 300 0 1 0 2440 1557
  7x7 300 0 1 0 4066 3495
8 pixel 3x3 150 0 3 0 1803 2050
  5x5 150 0 5 0 4159 6817

Performance Estimate

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

Table 730 Table . Sobel Function Performance Estimate Summary
Operating Mode

Operating Frequency

(MHz)

Filter Size

Latency Estimate

(ms)

1 pixel 300 3x3 7.5
300 5x5 7.5
300 7x7 7.5
8 pixel 150 3x3 1.7
150 5x5 1.71