import math


def grid_split(image, h, w):
    """Split the image into a grid."""
    n_rows = math.ceil(image.shape[0] / h)
    n_cols = math.ceil(image.shape[1] / w)

    rows = []
    for r in range(n_rows):
        cols = []
        for c in range(n_cols):
            cols.append(image[r * h: (r + 1) * h, c * w: (c + 1) * w, ...])
        rows.append(cols)

    return rows