示例#1
0
def test_as_pil_image_float32():
    im = MaskedImage(np.ones((120, 120, 1)).astype(np.float32))
    new_im = im.as_PILImage()
    assert_allclose(np.asarray(new_im.getdata()).reshape(im.pixels.shape),
                    (im.pixels * 255).astype(np.uint8))
示例#2
0
def test_as_pil_image_3channels():
    im = MaskedImage(np.random.randn(120, 120, 3))
    new_im = im.as_PILImage()
    assert_allclose(np.asarray(new_im.getdata()).reshape(im.pixels.shape),
                    (im.pixels * 255).astype(np.uint8))
示例#3
0
def test_as_pil_image_bad_range():
    im = MaskedImage(np.random.randn(1, 120, 120), copy=False)
    im.as_PILImage()
示例#4
0
def test_as_pil_image_bad_range():
    im = MaskedImage(np.random.randn(120, 120, 1))
    im.as_PILImage()
示例#5
0
def test_as_pil_image_3channels():
    im = MaskedImage(np.ones((120, 120, 3)))
    new_im = im.as_PILImage()
    assert_allclose(
        np.asarray(new_im.getdata()).reshape(im.pixels.shape),
        (im.pixels * 255).astype(np.uint8))
示例#6
0
def test_as_pil_image_bad_range():
    im = MaskedImage(np.random.randn(120, 120, 1))
    im.as_PILImage()
示例#7
0
def test_as_pil_image_bad_range():
    im = MaskedImage(np.random.randn(1, 120, 120), copy=False)
    with raises(ValueError):
        im.as_PILImage()
示例#8
0
def test_as_pil_image_bad_range():
    im = MaskedImage(np.random.randn(1, 120, 120), copy=False)
    im.as_PILImage()
示例#9
0
def test_as_pil_image_bad_range():
    im = MaskedImage(np.random.randn(1, 120, 120), copy=False)
    with raises(ValueError):
        im.as_PILImage()