Click4Ai

316.

Medium

Otsu's Thresholding

======================

Description:

Otsu's thresholding is a technique to automatically determine the optimal threshold value for image thresholding. It's a widely used method in image processing and computer vision.

Example:

Consider an image with a binary object on a white background. We can use Otsu's thresholding to automatically determine the optimal threshold value.

Constraints:

* The input image is a 2D array of pixel intensities.

* The output is the optimal threshold value.

* The output is a scalar value.

Goal:

Implement a function to perform Otsu's thresholding using NumPy.

Test Cases

Test Case 1
Input: [[10, 20, 30], [40, 50, 60]]
Expected: 50
Test Case 2
Input: [[100, 200, 300], [400, 500, 600]]
Expected: 300
+ 3 hidden test cases