def crop_dtu_input(images, cams, height, width, base_image_size, depth_image=None):
    ' resize images and cameras to fit the network (can be divided by base image size) '
    for view in range(len(images)):
        (h, w) = images[view].shape[0:2]
        new_h = h
        new_w = w
        if (new_h > height):
            new_h = height
        else:
            new_h = int((math.floor((h / base_image_size)) * base_image_size))
        if (new_w > width):
            new_w = width
        else:
            new_w = int((math.floor((w / base_image_size)) * base_image_size))
        start_h = int(math.floor(((h - new_h) / 2)))
        start_w = int(math.floor(((w - new_w) / 2)))
        finish_h = (start_h + new_h)
        finish_w = (start_w + new_w)
        images[view] = images[view][start_h:finish_h, start_w:finish_w]
        cams[view][1][0][2] = (cams[view][1][0][2] - start_w)
        cams[view][1][1][2] = (cams[view][1][1][2] - start_h)
    if (not (depth_image is None)):
        depth_image = depth_image[start_h:finish_h, start_w:finish_w]
        return (images, cams, depth_image)
    else:
        return (images, cams)
resize images and cameras to fit the network (can be divided by base image size)
def crop_dtu_input(images, cams, height, width, base_image_size, depth_image=None):
    '  '
    for view in range(len(images)):
        (h, w) = images[view].shape[0:2]
        new_h = h
        new_w = w
        if (new_h > height):
            new_h = height
        else:
            new_h = int((math.floor((h / base_image_size)) * base_image_size))
        if (new_w > width):
            new_w = width
        else:
            new_w = int((math.floor((w / base_image_size)) * base_image_size))
        start_h = int(math.floor(((h - new_h) / 2)))
        start_w = int(math.floor(((w - new_w) / 2)))
        finish_h = (start_h + new_h)
        finish_w = (start_w + new_w)
        images[view] = images[view][start_h:finish_h, start_w:finish_w]
        cams[view][1][0][2] = (cams[view][1][0][2] - start_w)
        cams[view][1][1][2] = (cams[view][1][1][2] - start_h)
    if (not (depth_image is None)):
        depth_image = depth_image[start_h:finish_h, start_w:finish_w]
        return (images, cams, depth_image)
    else:
        return (images, cams)