コード例 #1
0
ファイル: test_freeimage.py プロジェクト: beyondboy/mahotas
def test_freeimage():
    img = np.arange(256).reshape((16,16)).astype(np.uint8)

    freeimage.imsave(_testimgname, img)
    img_ = freeimage.imread(_testimgname)
    assert img.shape == img_.shape
    assert np.all(img == img_)
コード例 #2
0
def test_as_grey(tmpdir):
    fname = tmpdir.join('mahotas_test.png')
    colour = np.arange(16 * 16 * 3).reshape((16, 16, 3))
    freeimage.imsave(fname, colour.astype(np.uint8))
    c2 = freeimage.imread(fname, as_grey=True)
    assert len(c2.shape) == 2
    assert c2.shape == colour.shape[:-1]
コード例 #3
0
def test_freeimage():
    img = np.arange(256).reshape((16, 16)).astype(np.uint8)

    freeimage.imsave(_testimgname, img)
    img_ = freeimage.imread(_testimgname)
    assert img.shape == img_.shape
    assert np.all(img == img_)
コード例 #4
0
def test_save_load_rgba(tmpdir):
    fname = tmpdir.join('mahotas_test.png')
    img = np.arange(256).reshape((8, 8, 4)).astype(np.uint8)
    freeimage.imsave(fname, img)
    img_ = freeimage.imread(fname)
    assert img.shape == img_.shape
    assert np.all(img == img_)
コード例 #5
0
ファイル: test_freeimage.py プロジェクト: beyondboy/mahotas
def test_rgba():
    rgba = path.join(
                path.dirname(__file__),
                'data',
                'rgba.png')
    rgba = imread(rgba)
    assert np.all(np.diff(rgba[:,:,3].mean(1)) < 0 ) # the image contains an alpha gradient
コード例 #6
0
def test_uint16():
    img = np.zeros((32, 32), dtype=np.uint16)
    freeimage.imsave(_testimgname, img)
    img_ = freeimage.imread(_testimgname)

    assert img.shape == img_.shape
    assert img.dtype == img_.dtype
    assert np.all(img == img_)
コード例 #7
0
def test_freeimage(tmpdir):
    img = np.arange(256).reshape((16, 16)).astype(np.uint8)

    fname = tmpdir.join('mahotas_test.png')
    freeimage.imsave(fname, img)
    img_ = freeimage.imread(fname)
    assert img.shape == img_.shape
    assert np.all(img == img_)
コード例 #8
0
ファイル: test_freeimage.py プロジェクト: beyondboy/mahotas
def test_uint16():
    img = np.zeros((32,32), dtype=np.uint16)
    freeimage.imsave(_testimgname, img)
    img_ = freeimage.imread(_testimgname)

    assert img.shape == img_.shape
    assert img.dtype == img_.dtype
    assert np.all(img == img_)
コード例 #9
0
ファイル: test_freeimage.py プロジェクト: beyondboy/mahotas
def test_1bpp():
    bpp = path.join(
                path.dirname(__file__),
                'data',
                '1bpp.bmp')
    bpp = imread(bpp)
    assert bpp.sum()
    assert bpp.sum() < bpp.size
コード例 #10
0
def test_uint16():
    img = np.zeros((32, 32), dtype=np.uint16)
    fname = tmpdir.join('mahotas_test.png')
    freeimage.imsave(fname, img)
    img_ = freeimage.imread(fname)

    assert img.shape == img_.shape
    assert img.dtype == img_.dtype
    assert np.all(img == img_)
コード例 #11
0
ファイル: test_freeimage.py プロジェクト: beyondboy/mahotas
def test_save_load_rgba():
    img = np.arange(256).reshape((8,8,4)).astype(np.uint8)
    freeimage.imsave(_testimgname, img)
    img_ = freeimage.imread(_testimgname)
    assert img.shape == img_.shape
    assert np.all(img == img_)
コード例 #12
0
def test_1bpp():
    bpp = path.join(path.dirname(__file__), 'data', '1bpp.bmp')
    bpp = imread(bpp)
    assert bpp.sum()
    assert bpp.sum() < bpp.size
コード例 #13
0
def test_save_load_rgba():
    img = np.arange(256).reshape((8, 8, 4)).astype(np.uint8)
    freeimage.imsave(_testimgname, img)
    img_ = freeimage.imread(_testimgname)
    assert img.shape == img_.shape
    assert np.all(img == img_)
コード例 #14
0
def test_rgba():
    rgba = path.join(path.dirname(__file__), 'data', 'rgba.png')
    rgba = imread(rgba)
    assert np.all(np.diff(rgba[:, :, 3].mean(1)) <
                  0)  # the image contains an alpha gradient
コード例 #15
0
def test_as_grey():
    colour = np.arange(16 * 16 * 3).reshape((16, 16, 3))
    imsave(_testimgname, colour.astype(np.uint8))
    c2 = imread(_testimgname, as_grey=True)
    assert len(c2.shape) == 2
    assert c2.shape == colour.shape[:-1]
コード例 #16
0
ファイル: test_freeimage.py プロジェクト: tylerluo/mahotas
def test_1bpp():
    bpp = path.join(path.dirname(__file__), "data", "1bpp.bmp")
    bpp = freeimage.imread(bpp)
    assert bpp.sum()
    assert bpp.sum() < bpp.size
コード例 #17
0
ファイル: test_freeimage.py プロジェクト: beyondboy/mahotas
def test_as_grey():
    colour = np.arange(16*16*3).reshape((16,16,3))
    imsave(_testimgname, colour.astype(np.uint8))
    c2 = imread(_testimgname, as_grey=True)
    assert len(c2.shape) == 2
    assert c2.shape == colour.shape[:-1]