computer_vision.otsu_threshold ============================== .. py:module:: computer_vision.otsu_threshold Functions --------- .. autoapisummary:: computer_vision.otsu_threshold.otsu_threshold Module Contents --------------- .. py:function:: otsu_threshold(image: PIL.Image) -> PIL.Image Applies Otsu's thresholding method to a grayscale image. Parameters: image (PIL.Image.Image): A grayscale PIL image object. Returns: PIL.Image.Image: A binary image after applying Otsu's thresholding. Example: >>> from PIL import Image >>> import numpy as np >>> image_array = np.array( ... [[0, 0, 0, 0], [255, 255, 255, 255], [0, 0, 0, 0], [255, 255, 255, 255]], ... dtype=np.uint8 ... ) >>> image = Image.fromarray(image_array) >>> binary_image = otsu_threshold(image) >>> np.array(binary_image) array([[ 0, 0, 0, 0], [255, 255, 255, 255], [ 0, 0, 0, 0], [255, 255, 255, 255]], dtype=uint8)