Selects the sub-image inside the given box

    :param img: Image to crop from
    :param box: Box to crop from. Box can be either Box object or array of [x, y, width, height]
    :return: Cropped sub-image from the main image

def img_box(img, box):
    """
    Selects the sub-image inside the given box

    :param img: Image to crop from
    :param box: Box to crop from. Box can be either Box object or array of [x, y, width, height]
    :return: Cropped sub-image from the main image
    """
    if isinstance(box, tuple):
        box = Box.from_tup(box)

    if len(img.shape) == 3:
        return img[box.y:box.y + box.height, box.x:box.x + box.width, :]
    else:
        return img[box.y:box.y + box.height, box.x:box.x + box.width]