def partition(emap, rows, cols):
    """
    Partition edge maps into windows
        emap: (array) edge map
        rows: (int) number of rows for each partition
        cols: (int) number of columns for each partition
    """
    h, w = emap.shape

    return (emap.reshape(h // rows, rows, -1, cols)
            .swapaxes(1, 2)
            .reshape(-1, rows, cols))