Click4Ai

317.

Medium

Adaptive Thresholding

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

Description:

Adaptive thresholding is a technique to automatically determine the optimal threshold value for image thresholding based on the local neighborhood of each pixel. 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 adaptive thresholding to automatically determine the optimal threshold value for each pixel.

Constraints:

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

* The output image is a binary array where pixels with intensity above the threshold are set to 1 and below the threshold are set to 0.

* The output image has the same shape as the input image.

Goal:

Implement a function to perform adaptive thresholding using NumPy.

Test Cases

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