# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405

import numpy
import numpy.typing
__all__ = [
    "compute_adaptive_threshold",
    "denoise_binary",
    "filter_components",
    "get_component_areas",
    "grayscale_to_binary",
]

def compute_adaptive_threshold(areas: list[int]) -> int:
    r"""
    Compute an adaptive area threshold to separate noise from content.
    
    Analyses the distribution of connected component areas and finds the
    largest gap to determine a threshold that separates noise (small
    components) from meaningful content.
    
    :param areas: Sorted list of component pixel areas.
    :returns: Adaptive threshold value (minimum area to keep).
    :complexity: O(n) where n = number of unique area values
    """

def denoise_binary(binary: numpy.typing.NDArray[numpy.uint8]) -> numpy.typing.NDArray[numpy.uint8]:
    r"""
    Remove small noise components from a binary image using adaptive thresholding.
    
    Computes connected components, finds the largest gap in component area
    distribution to separate noise from content, and removes small components.
    
    :param binary: 2D binary uint8 array (values 0 or 1).
    :returns: 2D binary uint8 array with noise removed.
    :complexity: O(w*h)
    """

def filter_components(binary: numpy.typing.NDArray[numpy.uint8], min_area: int) -> numpy.typing.NDArray[numpy.uint8]:
    r"""
    Remove connected components smaller than min_area.
    
    Uses 8-connectivity for component detection.
    
    :param binary: 2D binary uint8 array (values 0 or 1).
    :param min_area: Minimum pixel count to keep a component.
    :returns: 2D binary uint8 array (values 0 or 1).
    :complexity: O(w*h)
    """

def get_component_areas(binary: numpy.typing.NDArray[numpy.uint8]) -> list[int]:
    r"""
    Compute the pixel area of each connected component.
    
    Uses 8-connectivity. Areas are returned sorted ascending.
    Background (0-valued pixels) is excluded.
    
    :param binary: 2D binary uint8 array (values 0 or 1).
    :returns: Sorted list of component pixel areas.
    :complexity: O(w*h)
    """

def grayscale_to_binary(gray: numpy.typing.NDArray[numpy.uint8], threshold: float = 0.5, invert: bool = False, auto_threshold: bool = True) -> numpy.typing.NDArray[numpy.uint8]:
    r"""
    Convert grayscale image to binary using Otsu or fixed threshold.
    
    Pixels at or below the threshold become foreground (1).
    Uses Otsu's method when auto_threshold is True.
    
    :param gray: 2D grayscale uint8 image.
    :param threshold: Fixed threshold (0.0-1.0), used only if auto_threshold is False.
    :param invert: If True, pixels above threshold become foreground.
    :param auto_threshold: If True, compute threshold via Otsu's method.
    :returns: 2D binary uint8 array (values 0 or 1).
    :complexity: O(w*h)
    """

