Skip to content

simple_utils

Simple utility functions used throughout page_dewarp.

Currently provides a small helper (fltp) to flatten integer coordinates.

fltp

fltp(point: ndarray) -> tuple[int, int]

Flatten and convert a NumPy coordinate to an (x, y) integer tuple.

Parameters:

Name Type Description Default
point ndarray

A NumPy array containing [x, y] coordinates (possibly float).

required

Returns:

Type Description
tuple[int, int]

An (x, y) tuple of integers.

Source code in src/page_dewarp/simple_utils.py
def fltp(point: np.ndarray) -> tuple[int, int]:
    """Flatten and convert a NumPy coordinate to an (x, y) integer tuple.

    Args:
        point: A NumPy array containing [x, y] coordinates (possibly float).

    Returns:
        An (x, y) tuple of integers.

    """
    return tuple(point.astype(int).flatten())