def crop_array_with_roi(array, roi):
    """
    Crop a roi from an input array
    :param array: numpy array
    :param roi: list with roi as [a,b,w,h]
    :return: cropped array
    """
    assert array.shape[0] > roi[3], "roi is larger than the original array"
    assert array.shape[1] > roi[2], "roi is larger than the original array"
    assert array.shape[0] > roi[1], "roi is not inside the original array"
    assert array.shape[1] > roi[0], "roi is not inside the original array"

    cropped = array[int(roi[1]):int(roi[1] + roi[3]), int(roi[0]):int(roi[0] + roi[2])]
    return cropped