def im2col_get_pixel(im, height, width, row, col, channel, pad):
    """
    Args:
        im: input image.
        height: image height.
        width: image width.
        row: row index.
        col: col index.
        channel: channel index.
        pad: padding length.
    """
    row = row - pad
    col = col - pad
    if row < 0 or col < 0 or row >= height or col >= width:
        pixel = 0
    else:
        pixel = im[int(col + width * (row + height * channel))]
    return pixel