Local Tone Mapping - 2023.2 English

Vitis Libraries

Release Date
2023-12-20
Version
2023.2 English

Most of the display devices have limited dynamic range. Hence images with wide dynamic range cannot be seen natively on such devices. To see wide dynamic range images on devices with low dynamic range, we need to compress the wide dynamic range of image to a low dynamic range. This process is called as tone-mapping.

Local tone mapping takes pixel neighbor statistics into account, and produces images with more contrast and brightness.

This implementaion is based on the algorithm proposed by J. Yang, A. Hore and O. Yadid-Pecht.

API Syntax

LTM Class API:

template <int IN_TYPE, int OUT_TYPE, int BLOCK_HEIGHT, int BLOCK_WIDTH, int ROWS, int COLS, int NPC, int XFCVDEPTH_IN_1 = _XFCVDEPTH_DEFAULT, int XFCVDEPTH_OUT_1 = _XFCVDEPTH_DEFAULT>
class LTM {}

Processing member function:

xf::cv::LTM<IN_TYPE, OUT_TYPE, BLOCK_HEIGHT, BLOCK_WIDTH, ROWS, COLS, NPC>::process(xf::cv::Mat<IN_TYPE, ROWS, COLS, NPC>& in,
                     int block_rows,
                     int block_cols,
                     XF_CTUNAME(IN_TYPE, NPC) omin_r[MinMaxVArrSize][MinMaxHArrSize],
                     XF_CTUNAME(IN_TYPE, NPC) omax_r[MinMaxVArrSize][MinMaxHArrSize],
                     XF_CTUNAME(IN_TYPE, NPC) omin_w[MinMaxVArrSize][MinMaxHArrSize],
                     XF_CTUNAME(IN_TYPE, NPC) omax_w[MinMaxVArrSize][MinMaxHArrSize],
                     xf::cv::Mat<OUT_TYPE, ROWS, COLS, NPC>& out)

Overlaoded processing member function:

xf::cv::LTM<IN_TYPE, OUT_TYPE, BLOCK_HEIGHT, BLOCK_WIDTH, ROWS, COLS, NPC>::process(xf::cv::Mat<IN_TYPE, ROWS, COLS, NPC>& in,
                     XF_CTUNAME(IN_TYPE, NPC) omin_r[MinMaxVArrSize][MinMaxHArrSize],
                     XF_CTUNAME(IN_TYPE, NPC) omax_r[MinMaxVArrSize][MinMaxHArrSize],
                     XF_CTUNAME(IN_TYPE, NPC) omin_w[MinMaxVArrSize][MinMaxHArrSize],
                     XF_CTUNAME(IN_TYPE, NPC) omax_w[MinMaxVArrSize][MinMaxHArrSize],
                     xf::cv::Mat<OUT_TYPE, ROWS, COLS, NPC>& out)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 632 Table . LocalToneMapping Function Parameter Descriptions
Parameter Description
IN_TYPE Input pixel type. The current supported pixel value is XF_8UC3, XF_10UC3, XF_12UC3, XF_16UC3, XF_32FC3
OUT_TYPE Input pixel type. The current supported pixel value is XF_8UC3, XF_10UC3, XF_12UC3, XF_16UC3
BLOCK_WIDTH Max block width the image is divided into. This can be any positive integer greater than or equal to 32 and less than input image width.
BLOCK_HEIGHT Max block height the image is divided into. This can be any positive integer greater than or equal to 32 and less than input image height.
ROWS Maximum number of rows of the input image that the hardware kernel must be built for.
COLS Maximum number of columns of the input image that the hardware kernel must be built for.
NPC Number of pixels to process per cycle. Supported values are XF_NPPC1, XF_NPPC2, XF_NPPC4, XF_NPPC8.
XFCVDEPTH_IN Depth of the input image.
XFCVDEPTH_OUT Depth of the output image.
in Input HDR image
block_rows Actual block height
block_cols Actual block width
omin_r Array of min values to be read by the next frame.
omax_r Array of max values to be read by the next frame.
omin_w Array of min values computed in the current frame.
omax_w Array of max values computed in the current frame.
out Output HDR image

Resource Utilization

The following table summarizes the resource utilization of LocalToneMapping for a 4K image, as generated in the Vitis HLS 2020.2 version tool for the Xilinx xcu200-fsgd2104-2-e FPGA at 300MHz.

Table 633 Table . LocalToneMapping Function Resource Utilization Summary
Operating Mode

Operating Frequency

(MHz)

Utilization Estimate
BRAM_18K DSP_48Es FF LUTs
1 pixel 300 0 123 35216 20246
4 pixel 300 0 330 67457 40391

Performance Estimate

The following table summarizes performance estimates of the LocalToneMapping function for a 4K image, generated using Vitis HLS 2020.2 version tool for the Xilinx xcu200-fsgd2104-2-e FPGA.

Table 634 Table . LocalToneMapping Function Performance Estimate Summary
Operating Mode

Operating Frequency

(MHz)

Latency Estimate
Max (ms)
1 pixel 300 7.2
4 pixel 300 1.9