Resolution Conversion (Resize) - 2024.1 English

Vitis Libraries

Release Date
2024-05-30
Version
2024.1 English

Resolution Conversion is the method used to resize the source image to the size of the destination image. Different types of interpolation techniques can be used in resize function, namely: Nearest-neighbor, Bilinear, and Area interpolation. The type of interpolation can be passed as a template parameter to the API. The following enumeration types can be used to specify the interpolation type:

  • XF_INTERPOLATION_NN - For Nearest-neighbor interpolation
  • XF_INTERPOLATION_BILINEAR - For Bilinear interpolation
  • XF_INTERPOLATION_AREA - For Area interpolation

Note: Scaling factors greater than or equal to 0.25 are supported in down-scaling and values less than or equal to 8 are supported for up-scaling.

API Syntax

template<int INTERPOLATION_TYPE, int TYPE, int SRC_ROWS, int SRC_COLS, int DST_ROWS, int DST_COLS, int NPC, bool USE_URAM, int MAX_DOWN_SCALE, int XFCVDEPTH_IN = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT = _XFCVDEPTH_DEFAULT>
void resize (xf::cv::Mat<TYPE, SRC_ROWS, SRC_COLS, NPC, XFCVDEPTH_IN> & _src, xf::cv::Mat<TYPE, DST_ROWS, DST_COLS, NPC, XFCVDEPTH_OUT> & _dst)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 710 Table . resize Parameter Description
Parameter Description
INTERPOLATIO N_TYPE

Interpolation type. The different options possible are

  • XF_INTERPOLATION_NN – Nearest Neighbor Interpolation
  • XF_INTERPOLATION_BILINEAR – Bilinear interpolation
  • XF_INTERPOLATION_AREA – Area Interpolation
TYPE Input and Output pixel type. Only 8-bit, unsigned, 1 and 3 channels are supported (XF_8UC1 and XF_8UC3)
SRC_ROWS Maximum Height of input image for which the hardware kernel would be built.
SRC_COLS Maximum Width of input image for which the hardware kernel would be built (must be a multiple of 8).
DST_ROWS Maximum Height of output image for which the hardware kernel would be built.
DST_COLS Maximum Width of output image for which the hardware kernel would be built (must be a multiple of 8).
NPC Number of pixels to be processed per cycle. Possible options are NPPC1, NPPC2, NPPC4, and NPPC8
USE_URAM Enable to map storage structures to UltraRAM.
MAX_DOWN_SCA LE Set to 2 for all 1 pixel modes, and for upscale in x direction. When down scaling in x direction in 8-pixel mode, please set this parameter to the next highest integer value of the down scale factor i.e., if downscaling from 1920 columns to 1280 columns, set to 2. For 1920 to 640, set to 3.
XFCVDEPTH_IN Depth of the input image.
XFCVDEPTH_OUT Depth of the output image.
_src Input Image
_dst Output Image

Resource Utilization

The following table summarizes the resource utilization of Resize function in Resource Optimized (8 pixel) mode and Normal mode, as generated in the Vivado HLS 2019.1 tool for the Xilinx xczu9eg-ffvb1156-2-i-es2 FPGA.

Table 711 Table . resize Function Resource Utilization Summary
Operating Mode Utilization Estimate
1 Pixel (at 300 MHz) 8 Pixel (at 150MHz)
IMAGESIZE LUTs FFs DSPs BRAMs IMAGESIZE LUTs FFs DSPs BRAMs
Downscale Nearest Neighbor 1920X1080 TO 960X1620 1089 1593 4 2 3840X2160 TO 1920X1080 2545 2250 4 12
Downscale Bilinear 1920X1080 TO 960X1080 1340 1846 8 2 3840X2160 TO 1920X1080 5159 3092 36 12
Downscale Area 3840X2160 TO 1920X1080 6146 8338 19 10 3840X2160 TO 1920X1080 17892 19758 162 16
Upscale Nearest Neighbor 1920X1080 TO 3840X540 1089 1593 4 2 1920X1080 TO 3840X2160 1818 1686 4 6
Upscale Bilinear 1920X1080 TO 3840X540 1340 1846 8 2 1920X1080 TO 3840X2160 3697 2739 36 6
Upscale Area 1920X1080 TO 3840X2160 5811 8773 28 32 1920X1080 TO 3840X2160 12214 14003 98 24

The following table summarizes the resource utilization of Resize function in Normal mode, as generated in the Vivado HLS 2019.1 tool for the Xilinx xczu9eg-ffvb1156-2-i-es2 FPGA for 3channel image as input.

Table 712 Table . resize Function Resource Utilization Summary
Operating Mode Utilization Estimate
1 Pixel (at 300 MHz)
IMAGESIZE LUTs FFs DSPs BRAMs
Downscale Nearest Neighbor 3840X2160 TO 1920X108 1184 168 4 18
Downscale Bilinear 3840X2160 TO 1920X1080 1592 2058 14 18
Downscale Area 3840X2160 TO 1920X1080 3212 4777 104 72
Upscale Nearest Neighbor 1920X1080 TO 3840X2160 1166 1697 4 9
Upscale Bilinear 1920X1080 TO 3840X2160 1574 2053 14 9
Upscale Area 1920X1080 TO 3840X2160 1731 2733 36 31

Performance Estimate

The following table summarizes the performance estimation of Resize for various configurations, as generated in the Vivado HLS 2019.1 tool for the xczu9eg-ffvb1156-2-i-es2 FPGA at 300 MHz to resize a grayscale image from 1080x1920 to 480x640 (downscale); and to resize a grayscale image from 1080x1920 to 2160x3840 (upscale). This table also shows the latencies obtained for different interpolation types.

Table 713 Table . resize Function Performance Estimate Summary
Operating Mode

Operating Frequency

(MHz)

Latency Estimate (ms)

Downscale

NN

Downscale

Bilinear

Downscale

Area

Upscale

NN

Upscale

Bilinear

Upscale

Area

1 pixel 300 6.94 6.97 7.09 27.71 27.75 27.74