Otsu Threshold

Otsu threshold is used to automatically perform clustering-based image thresholdingor the reduction of a gray-level image to a binary image. The algorithm assumes that the image contains two classes of pixels following bi-modal histogram (foreground pixels and background pixels), it then calculates the optimum threshold separating the two classes.

Otsu method is used to find the threshold which can minimize the intra class variance which separates two classes defined by weighted sum of variances of two classes.



Where, w_1is the class probability computed from the histogram.



Otsu shows that minimizing the intra-class variance is the same as maximizing inter-class variance





Where,is the class mean.

API Syntax

template void xFOtsuThreshold(xF::Mat & _src_mat, uint8_t &_thresh)

Parameter Descriptions

The following table describes the template and the function parameters.

Table 1.xFOtsuThreshold Function Parameter Descriptions
Parameter Description
SRC_T Input 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; possible options are XF_NPPC1 and XF_NPPC8 for 1 pixel and 8 pixel operations respectively.
_src_mat Input image
_thresh Output threshold value after the computation

Resource Utilization

The following table summarizes the resource utilization of the xFOtsuThreshold function, generated usingVivado HLS 2017.1tool for the Xilinx Xczu9eg-ffvb1156-1-i-es1 FPGA, to process a grayscale HD (1080x1920) image.

Table 2.xFOtsuThreshold Function Resource Utilization Summary
Operating Mode

Operating Frequency

(MHz)

Utilization Estimate
BRAM_18K DSP_48Es FF LUT CLB
1 pixel 300 8 49 2239 3353 653
8 pixel 150 22 49 1106 3615 704

Performance Estimate

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

Table 3.xFOtsuThreshold Function Performance Estimate Summary
Operating Mode Latency Estimate
Max Latency (ms)
1 pixel operation(300 MHz) 6.92 ms
8 pixel operation(150 MHz) 1.76 ms