예제 #1
0
def pyrdown_hybrid_test():
    image = imread('test_materials/MonroeEnstein_AudeOliva2007.jpg')
    image = pyrdown(image)
    image = pyrdown(image)
    image = pyrdown(image)

    image = np.uint8(np.clip(image, 0, 255))
    correct = imread('test_materials/MonroeEnstein_AudeOliva2007_small.png')

    assert (np.abs(image - correct) / 255.0 < 1e-2).all()
예제 #2
0
파일: tests.py 프로젝트: cs4670/pa4
def pyrdown_hybrid_test():
    image = imread('test_materials/MonroeEnstein_AudeOliva2007.jpg')
    image = image.astype(np.float32)
    image = pyrdown(image)
    image = pyrdown(image)
    image = pyrdown(image)

    image = np.uint8(np.clip(image, 0, 255))
    correct = imread('test_materials/MonroeEnstein_AudeOliva2007_small.png')

    assertNear(image / 255.0, correct / 255.0, 1e-2)
예제 #3
0
def pyrdown_hybrid_test():
    image = imread('test_materials/MonroeEnstein_AudeOliva2007.jpg')
    image = image.astype(np.float32)
    image = pyrdown(image)
    image = pyrdown(image)
    image = pyrdown(image)

    image = np.uint8(np.clip(image, 0, 255))
    correct = imread('test_materials/MonroeEnstein_AudeOliva2007_small.png')

    assertNear(image / 255.0, correct / 255.0, 1e-2)
예제 #4
0
파일: tests.py 프로젝트: cs4670/pa4
def pyrdown_random_test():
    height = 16
    width = 31

    image = np.random.random((height, width, 3))

    down = pyrdown(image)

    assert down.shape == ((height + 1) / 2, (width + 1) / 2, 3)
예제 #5
0
def pyrdown_random_test():
    height = 16
    width = 31

    image = np.random.random((height, width, 3))

    down = pyrdown(image)

    assert down.shape == ((height + 1) / 2, (width + 1) / 2, 3)
예제 #6
0
def pyrdown_odd_test():
    height = 17
    width = 17

    image = np.ones((height, width, 3), dtype=np.float32)

    down = pyrdown(image)

    assert down.shape == ((height + 1) / 2, (width + 1) / 2, 3)
    assert (down == 1).all()
예제 #7
0
def pyrdown_nonsquare_test():
    height = 16
    width = 31

    image = np.ones((height, width, 3), dtype=np.float32)

    down = pyrdown(image)

    assert down.shape == ((height + 1) // 2, (width + 1) // 2, 3)
    assert (down == 1).all()
예제 #8
0
파일: tests.py 프로젝트: cs4670/pa4
def pyrdown_even_test():
    height = 16
    width = 16

    image = np.ones((height, width, 3), dtype=np.float32)

    down = pyrdown(image)

    assert down.shape == (height / 2, width / 2, 3)
    assertNear(down, 1, 1e-6)
예제 #9
0
def pyrdown_even_test():
    height = 16
    width = 16

    image = np.ones((height, width, 3), dtype=np.float32)

    down = pyrdown(image)

    assert down.shape == (height / 2, width / 2, 3)
    assert (down == 1).all()
예제 #10
0
파일: tests.py 프로젝트: cs4670/pa4
def pyrdown_nonsquare_test():
    height = 16
    width = 31

    image = np.ones((height, width, 3), dtype=np.float32)

    down = pyrdown(image)

    assert down.shape == ((height + 1) / 2, (width + 1) / 2, 3)
    assertNear(down, 1, 1e-6)
예제 #11
0
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)
예제 #12
0
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)
예제 #13
0
파일: tests.py 프로젝트: cs4670/pa4
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)
예제 #14
0
    albedo = imread(data.albedo_png)
    normals = np.load(data.normals_npy)

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 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':
예제 #15
0
Rt_left = data.Rt_left

ncc_size = data.ncc_size
width = data.width
height = data.height

ncc_gif_writer = GifWriter(data.ncc_temp, data.ncc_gif)
projected_gif_writer = GifWriter(data.projected_temp, data.projected_gif)
"""
Images are pretty large, so we're going to reduce their size
in each dimension.
"""
right = data.right[0]
left = data.left[0]
for i in xrange(data.stereo_downscale_factor):
    right = pyrdown(right)
    left = pyrdown(left)
    height, width, _ = right.shape
    K_left[:2, :] /= 2
    K_right[:2, :] /= 2
"""
We'll give you the depth labels for this problem.
"""
depths = get_depths(data)

tic = time.time()
"""
The planes will be swept fronto-parallel to the right camera, so no
reprojection needs to be done for this image.  Simply compute the normalized
patches across the entire image.
"""
예제 #16
0
    cam0 = calib_values['cam0']
    cam1 = calib_values['cam1']
    doffs = float(calib_values['doffs'])
    baseline = float(calib_values['baseline'])
    width = int(calib_values['width'])
    height = int(calib_values['height'])

    # since this is a String, work with it to obtain f value
    cam0 = cam0[1:-1]
    tokens = cam0.split(' ')
    f = float(tokens[0])

# reduce size of ground truth image using the pyrdown from util.py
# reduce size by same amount as the plane_sweep_stereo did
for i in range(data.stereo_downscale_factor):
    ground_truth = pyrdown(ground_truth)

# we have some infinite values so set them to the max value we find in the ground truth
ground_truth[ground_truth == float('inf')] = 0
ground_truth[ground_truth == 0] = np.max(ground_truth)

# convert our depths to disparity
our_depth = (baseline * f) / our_depth

print('done converting disparity to depth')

# compute root mean squared error
N = np.size(ground_truth)
h, w = ground_truth.shape
sum = 0
for y in range(h):
예제 #17
0
파일: combine.py 프로젝트: rjc362/pa4
tic = time.time()
if mode in ('normals', 'both'):
    albedo = imread(data.albedo_png)
    normals = np.load(data.normals_npy)

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:
예제 #18
0
tic = time.time()
if mode in ('normals', 'both'):
    albedo = imread(data.albedo_png)
    normals = np.load(data.normals_npy)

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:
예제 #19
0
ncc_size = data.ncc_size
width = data.width
height = data.height

ncc_gif_writer = GifWriter(data.ncc_temp, data.ncc_gif)
projected_gif_writer = GifWriter(data.projected_temp, data.projected_gif)

"""
Images are pretty large, so we're going to reduce their size
in each dimension.
"""
right = data.right[0]
left = data.left[0]
for i in xrange(data.stereo_downscale_factor):
    right = pyrdown(right)
    left = pyrdown(left)
    height, width, _ = right.shape
    K_left[:2, :] /= 2
    K_right[:2, :] /= 2

"""
We'll give you the depth labels for this problem.
"""
depths = get_depths(data)

tic = time.time()

"""
The planes will be swept fronto-parallel to the right camera, so no
reprojection needs to be done for this image.  Simply compute the normalized