def crop(x, wrg, hrg, is_random=False, row_index=<NUM_LIT:0>, col_index=<NUM_LIT:1>):
h, w = x.shape[row_index], x.shape[col_index]<EOL>if (h < hrg) or (w < wrg):<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT>if is_random:<EOL><INDENT>h_offset = int(np.random.uniform(<NUM_LIT:0>, h - hrg))<EOL>w_offset = int(np.random.uniform(<NUM_LIT:0>, w - wrg))<EOL>return x[h_offset:hrg + h_offset, w_offset:wrg + w_offset]<EOL><DEDENT>else:  <EOL><INDENT>h_offset = int(np.floor((h - hrg) / <NUM_LIT>))<EOL>w_offset = int(np.floor((w - wrg) / <NUM_LIT>))<EOL>h_end = h_offset + hrg<EOL>w_end = w_offset + wrg<EOL>return x[h_offset:h_end, w_offset:w_end]<EOL><DEDENT>
Randomly or centrally crop an image.

    Parameters
    ----------
    x : numpy.array
        An image with dimension of [row, col, channel] (default).
    wrg : int
        Size of width.
    hrg : int
        Size of height.
    is_random : boolean,
        If True, randomly crop, else central crop. Default is False.
    row_index: int
        index of row.
    col_index: int
        index of column.

    Returns
    -------
    numpy.array
        A processed image.