def crop_rect(image, vertical, horizontal, width, height):
    """Crops a rectangle out of the image.
    params:
        image: A numpy ndarray, which has 2 or 3 dimensions
        vertical: An integer, which is the vertical coord for the top left
                  of the rectangle
        horizontal: An integer, which is the horizontal coord for the top left
                  of the rectangle
        width: An integer, which is the width of the rectangle
        height: An integer, which is the height of the rectangle
    return: A numpy ndarray, which has the same number of dimensions as image
    """
    return image[vertical:vertical + height, horizontal:horizontal + width]
