コード例 #1
0
ファイル: image_test.py プロジェクト: Amos-zq/menpo
def test_normalize_norm_image_per_channel():
    pixels = np.random.randn(120, 120, 3)
    pixels[..., 1] *= 17
    pixels[..., 0] += -114
    pixels[..., 2] /= 30
    image = Image(pixels)
    image.normalize_norm_inplace(mode='per_channel')
    assert_allclose(
        np.mean(image.as_vector(keep_channels=True), axis=0), 0, atol=1e-10)
    assert_allclose(
        np.linalg.norm(image.as_vector(keep_channels=True), axis=0), 1)
コード例 #2
0
ファイル: image_test.py プロジェクト: jacksoncsy/menpo
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(120, 120, 3)
    pixels[..., 1] *= 9
    pixels[..., 0] += -3
    pixels[..., 2] /= 140
    image = Image(pixels)
    image.normalize_std_inplace(mode='per_channel')
    assert_allclose(np.mean(image.as_vector(keep_channels=True), axis=0),
                    0,
                    atol=1e-10)
    assert_allclose(np.std(image.as_vector(keep_channels=True), axis=0), 1)
コード例 #3
0
ファイル: image_test.py プロジェクト: OlivierML/menpo
def test_normalize_std_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 9
    pixels[0] += -3
    pixels[2] /= 140
    image = Image(pixels)
    image.normalize_std_inplace(mode='per_channel')
    assert_allclose(
        np.mean(image.as_vector(keep_channels=True), axis=1), 0, atol=1e-10)
    assert_allclose(
        np.std(image.as_vector(keep_channels=True), axis=1), 1)
コード例 #4
0
def test_normalize_norm_image_per_channel():
    pixels = np.random.randn(3, 120, 120)
    pixels[1] *= 17
    pixels[0] += -114
    pixels[2] /= 30
    image = Image(pixels)
    image.normalize_norm_inplace(mode='per_channel')
    assert_allclose(np.mean(image.as_vector(keep_channels=True), axis=1),
                    0,
                    atol=1e-10)
    assert_allclose(
        np.linalg.norm(image.as_vector(keep_channels=True), axis=1), 1)
コード例 #5
0
ファイル: image_test.py プロジェクト: Amos-zq/menpo
def test_image_as_vector_keep_channels():
    pixels = np.random.rand(10, 20, 2)
    image = Image(pixels)
    assert(np.all(image.as_vector(keep_channels=True) ==
                  pixels.reshape([-1, 2])))
コード例 #6
0
ファイル: image_test.py プロジェクト: Amos-zq/menpo
def test_image_as_vector():
    pixels = np.random.rand(10, 20, 1)
    image = Image(pixels)
    assert(np.all(image.as_vector() == pixels.ravel()))
コード例 #7
0
ファイル: image_test.py プロジェクト: jacksoncsy/menpo
def test_image_as_vector_keep_channels():
    pixels = np.random.rand(10, 20, 2)
    image = Image(pixels)
    assert (np.all(
        image.as_vector(keep_channels=True) == pixels.reshape([-1, 2])))
コード例 #8
0
ファイル: image_test.py プロジェクト: jacksoncsy/menpo
def test_image_as_vector():
    pixels = np.random.rand(10, 20, 1)
    image = Image(pixels)
    assert (np.all(image.as_vector() == pixels.ravel()))
コード例 #9
0
ファイル: test_image.py プロジェクト: tzirakis/menpo
def test_image_as_vector_keep_channels():
    pixels = np.random.rand(2, 10, 20)
    image = Image(pixels)
    assert np.all(
        image.as_vector(keep_channels=True) == pixels.reshape([2, -1]))
コード例 #10
0
ファイル: image_test.py プロジェクト: nontas/menpo
def test_image_as_vector_keep_channels():
    pixels = np.random.rand(2, 10, 20)
    image = Image(pixels)
    assert np.all(image.as_vector(keep_channels=True) == pixels.reshape([2, -1]))