from typing import Tuple
import itertools


def get_img_windows_list(img_shape: Tuple[int, int], tile_size: int):
    """
    return list of tiles coordinate inside an image

    currently the tile are computed without overlaping and by rounding
    so union of all tiles are smaller than image.
    Tile are square.

    Parameters
    ----------
    img_shape : Tuple[int, int]
        shape of the image in pixel, similar to numpy array shape.
    tile_size : int
        size of the tile to extract in pixel. size in all dimension are the same.

    Returns
    -------
    List[Tuple(int, int, int, int)] :
       List of tile pixel coordinate as a tuple with row/col min and row/col max.
    """
    col_step = [col for col in range(0, img_shape[0], tile_size)]
    col_step.append(img_shape[0])
    row_step = [row for row in range(0, img_shape[1], tile_size)]
    row_step.append(img_shape[1])

    windows_list = []
    for i, j in itertools.product(
        range(0, len(col_step) - 2), range(0, len(row_step) - 2)
    ):
        windows_list.append(
            tuple(
                (
                    row_step[j],
                    col_step[i],
                    row_step[j + 1] - row_step[j],
                    col_step[i + 1] - col_step[i],
                )
            )
        )
    return windows_list