コード例 #1
0
ファイル: tests.py プロジェクト: wangvincentt/CV5670
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()
コード例 #2
0
ファイル: tests.py プロジェクト: cs4670/pa4
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)
コード例 #3
0
ファイル: tests.py プロジェクト: dp435/ComputerVision
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)
コード例 #4
0
ファイル: tests.py プロジェクト: wangvincentt/CV5670
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)
コード例 #5
0
ファイル: tests.py プロジェクト: cs4670/pa4
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)
コード例 #6
0
ファイル: tests.py プロジェクト: wangvincentt/CV5670
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()
コード例 #7
0
ファイル: tests.py プロジェクト: cw11794/pa4
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)
コード例 #8
0
ファイル: tests.py プロジェクト: cs4670/pa4
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)
コード例 #9
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)
コード例 #10
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)
コード例 #11
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)
コード例 #12
0
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:
コード例 #13
0
    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)
コード例 #14
0
ファイル: combine.py プロジェクト: rjc362/pa4
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: