def is_image_defective()

in quality_comparison/measure_reconstruction_completeness.py [0:0]


def is_image_defective(info):
    mode = info["mode"]
    depth, rgb = None, None
    use_depth = mode in ["depth", "rgb+depth"]
    use_rgb = mode in ["rgb", "rgb+depth"]
    # Read images
    if use_depth:
        depth = np.load(info["depth_path"] + ".npz")["depth"]
    if use_rgb:
        rgb = imageio.imread(info["rgb_path"])
    # Get fraction of defective values
    if use_depth and use_rgb:
        mask = (depth == 0) | np.all(rgb == 0, axis=2)
    elif use_depth:
        mask = depth == 0
    else:
        mask = np.all(rgb == 0, axis=2)
    frac = float(np.count_nonzero(mask)) / mask.size
    # Get scene name
    match = re.match("(.*)_img_(.*).npy", osp.basename(info["depth_path"]))
    assert match is not None
    scene_name = match.group(1)
    has_defect = 1.0 if frac > args.frac_thresh else 0.0
    return scene_name, has_defect, frac