Skip to main content

raygeo.image.grayscale

Functions

compute_auto_levels()

compute_auto_levels(
gray_image: numpy.NDArray[numpy.uint8],
clip_percent: float = 1,
) -> tuple[int, int]

Compute auto black/white levels from a grayscale image histogram.

ParameterTypeDescription
gray_imagenumpy.NDArray[numpy.uint8]Grayscale image as uint8 array.
clip_percentfloat = 1Percentage of pixels to clip from each end.
Returnstuple[int, int]Tuple of (black_point, white_point).
ComplexityO(n) where n = number of pixels

normalize_grayscale()

normalize_grayscale(
gray_image: numpy.NDArray[numpy.uint8],
black_point: int = 0,
white_point: int = 255,
) -> numpy.NDArray[numpy.uint8]

Normalize a grayscale image by stretching the dynamic range.

Raises: ValueError — If black_point >= white_point.

ParameterTypeDescription
gray_imagenumpy.NDArray[numpy.uint8]Input grayscale image as uint8 array.
black_pointint = 0Black point for normalization.
white_pointint = 255White point for normalization.
Returnsnumpy.NDArray[numpy.uint8]Normalized grayscale image with the same shape.
ComplexityO(n) where n = number of pixels