def pyrup_hybrid_test(): image = imread('test_materials/MonroeEnstein_AudeOliva2007_small.png') image = pyrup(image) image = pyrup(image) image = pyrup(image) image = np.uint8(np.clip(image, 0, 255)) correct = imread('test_materials/MonroeEnstein_AudeOliva2007_large.png') assert (np.abs(image - correct) / 255.0 < 1e-2).all()
def pyrup_hybrid_test(): image = imread('test_materials/MonroeEnstein_AudeOliva2007_small.png') image = image.astype(np.float32) image = pyrup(image) image = pyrup(image) image = pyrup(image) image = np.uint8(np.clip(image, 0, 255)) correct = imread('test_materials/MonroeEnstein_AudeOliva2007_large.png') assertNear(image / 255.0, correct / 255.0, 1e-2)
def pyrdown_random_nonsquare_test(): height = 16 width = 31 image = np.random.random((height, width, 3)) up = pyrup(image) assert up.shape == (2 * height, 2 * width, 3)
def pyrdown_ones_nonsquare_test(): height = 16 width = 31 image = np.ones((height, width, 3), dtype=np.float32) up = pyrup(image) assert up.shape == (2 * height, 2 * width, 3) assert (up == 1).all()
def pyrdown_ones_square_test(): height = 16 width = 16 image = np.ones((height, width, 3), dtype=np.float32) up = pyrup(image) assert up.shape == (2 * height, 2 * width, 3) assertNear(up, 1, 1e-6)
def pyrdown_ones_nonsquare_test(): height = 16 width = 31 image = np.ones((height, width, 3), dtype=np.float32) up = pyrup(image) assert up.shape == (2 * height, 2 * width, 3) assertNear(up, 1, 1e-5)
def pyrdown_pyrup_test_single_channel(): height = 16 width = 31 image = np.random.random((height * 2, width * 2, 1)) down = pyrdown(image) assert down.shape == (height, width, 1) up = pyrup(down) assert up.shape == (height * 2, width * 2, 1)
def pyrup_pyrdown_test_single_channel(): height = 16 width = 31 image = np.random.random((height, width, 1)) up = pyrup(image) assert up.shape == (2 * height, 2 * width, 1) down = pyrdown(up) assert down.shape == (height, width, 1)
def pyrup_pyrdown_test(): height = 16 width = 31 image = np.random.random((height, width, 3)) up = pyrup(image) assert up.shape == (2 * height, 2 * width, 3) down = pyrdown(up) assert down.shape == (height, width, 3)
if mode in ('depth', 'both'): depth = np.load(data.depth_npy) K_right = data.K_right depth = cv2.medianBlur(depth, 5) depth = cv2.medianBlur(depth, 5) if data.mesh_downscale_factor > data.stereo_downscale_factor: for i in range(data.mesh_downscale_factor - data.stereo_downscale_factor): depth = pyrdown(depth) elif data.stereo_downscale_factor > data.mesh_downscale_factor: for i in range(data.stereo_downscale_factor - data.mesh_downscale_factor): depth = pyrup(depth) for i in range(data.mesh_downscale_factor): K_right[:2, :] /= 2 if mode == 'both': depth_weight = data.depth_weight if mode == 'depth': albedo = data.right[0] if alpha is not None: for i in range(data.mesh_downscale_factor): alpha = pyrdown(alpha) if normals is not None:
depth = cv2.medianBlur(depth, 5) depth = cv2.medianBlur(depth, 5) if data.mesh_downscale_factor > data.stereo_downscale_factor: for i in range(data.mesh_downscale_factor - data.stereo_downscale_factor): # depth is 2D so give it 1 channel and then extract it back out x = depth[:, :, np.newaxis] y = pyrdown(x) depth = y[:, :, 0] elif data.stereo_downscale_factor > data.mesh_downscale_factor: for i in range(data.stereo_downscale_factor - data.mesh_downscale_factor): x = depth[:, :, np.newaxis] y = pyrup(x) depth = y[:, :, 0] for i in range(data.mesh_downscale_factor): K_right[:2, :] /= 2 if mode == 'both': depth_weight = data.depth_weight if mode == 'depth': albedo = data.right[0] if alpha is not None: for i in range(data.mesh_downscale_factor): x = alpha[:, :, np.newaxis] y = pyrdown(x)
if mode in ('depth', 'both'): depth = np.load(data.depth_npy) K_right = data.K_right depth = cv2.medianBlur(depth, 5) depth = cv2.medianBlur(depth, 5) if data.mesh_downscale_factor > data.stereo_downscale_factor: for i in xrange(data.mesh_downscale_factor - data.stereo_downscale_factor): depth = pyrdown(depth) elif data.stereo_downscale_factor > data.mesh_downscale_factor: for i in xrange(data.stereo_downscale_factor - data.mesh_downscale_factor): depth = pyrup(depth) for i in xrange(data.mesh_downscale_factor): K_right[:2, :] /= 2 if mode == 'both': depth_weight = data.depth_weight if mode == 'depth': albedo = data.right[0] if alpha is not None: for i in xrange(data.mesh_downscale_factor): alpha = pyrdown(alpha) if normals is not None: