Esempio n. 1
0
def test_watersheds():

    res = watershedsUnionFind(img_scalar_f)
    checkShape(img_scalar_f, res[0])
    checkType(res[0], np.uint32)

    res = watershedsUnionFind(img_scalar_f, 4)
    checkShape(img_scalar_f, res[0])
    checkType(res[0], np.uint32)

    img_scalar_i = at.ScalarImage(img_scalar_f.shape, dtype=np.uint32)
    res = watershedsUnionFind(img_scalar_f, 8, img_scalar_i)
    assert (res[0] is img_scalar_i)

    assert_raises(RuntimeError, watershedsUnionFind, img_scalar_f, 5,
                  img_scalar_i)

    res = watersheds(img_scalar_f, seeds=img_scalar_i, method="RegionGrowing")
    checkShape(img_scalar_f, res[0])
    checkType(res[0], np.uint32)

    # 3D
    res = watershedsUnionFind(vol_scalar_f, 6)
    checkShape(vol_scalar_f, res[0])

    vol_scalar_i = at.ScalarVolume(vol_scalar_f.shape, dtype=np.uint32)
    res = watershedsUnionFind(vol_scalar_f, 26, vol_scalar_i)
    assert (res[0] is vol_scalar_i)

    assert_raises(RuntimeError, watershedsUnionFind, img_scalar_f, 17,
                  img_scalar_i)
Esempio n. 2
0
#######################################################################

from __future__ import division, print_function
import sys
print("\nexecuting test file", __file__, file=sys.stderr)
exec(compile(open('set_paths.py', "rb").read(), 'set_paths.py', 'exec'))

from nose.tools import assert_equal, raises
import numpy as np
from vigra import *
from vigra import arraytypes as at
from vigra.filters import *
from vigra.analysis import *

img_rgb_f = at.RGBImage(np.random.rand(100, 200, 3) * 255, dtype=np.float32)
img_scalar_f = at.ScalarImage(np.random.rand(100, 200) * 255, dtype=np.float32)
img_multi_f = at.Vector4Image(np.random.rand(100, 200, 4) * 255,
                              dtype=np.float32)
img_3_f = at.Vector3Image(np.random.rand(100, 200, 3) * 255, dtype=np.float32)

img_rgb_i = at.RGBImage(np.random.rand(100, 200, 3) * 255, dtype=np.int32)
img_scalar_i = at.ScalarImage(np.random.rand(100, 200) * 255, dtype=np.int32)
img_multi_i = at.Vector4Image(np.random.rand(100, 200, 4) * 255,
                              dtype=np.int32)

vol_rgb_f = at.RGBVolume(np.random.rand(100, 200, 60, 3) * 255,
                         dtype=np.float32)
vol_scalar_f = at.ScalarVolume(np.random.rand(100, 200, 50) * 255,
                               dtype=np.float32)
vol_multi_f = at.Vector6Volume(np.random.rand(100, 200, 50, 6) * 255,
                               dtype=np.float32)
Esempio n. 3
0
print("\nexecuting test file", __file__, file=sys.stderr)
exec(compile(open('set_paths.py', "rb").read(), 'set_paths.py', 'exec'))

from nose.tools import assert_equal, raises
import numpy as np
from vigra import *
from vigra.filters import *
from vigra.sampling import *
from vigra.noise import *
import vigra.arraytypes as at

#in the hope, that functions are tested in C++, we basicly test return types

#image=readImage("/export/home/nhuesken/sas/experiments/testdata/bmpmultilabel.bmp")
image = at.RGBImage(np.random.rand(100, 100, 3) * 255, dtype=np.float32)
scalar_image = at.ScalarImage(np.random.rand(100, 100) * 255, dtype=np.float32)
volume256 = at.Volume(np.random.rand(100, 100, 100) * 255, dtype=np.uint8)
volumeBin = at.Volume(np.random.rand(100, 100, 100)) > 0.5


def checkImages(i1, i2):
    assert (i1.shape == i2.shape)
    assert (np.sum(i1 == i2) != 0)


def checkAboutSame(i1, i2):
    assert (i1.shape == i2.shape)
    difference = np.sum(np.abs(i1 - i2)) / float(np.size(i1))
    assert (difference < 5)

Esempio n. 4
0
print("\nexecuting test file", __file__, file=sys.stderr)
exec(compile(open('set_paths.py', "rb").read(), 'set_paths.py', 'exec'))

from nose.tools import assert_equal, raises
import numpy as np
import vigra.vigranumpycore # FIXME: why is this needed? (without, impex returns ndarray)
import vigra.impex as im
import vigra.arraytypes as at

#in the hope, that functions are tested in C++, we basicly test return types

image=at.RGBImage(np.random.rand(10,10,3)*255,dtype=np.float32, 
                  axistags=at.VigraArray.defaultAxistags(3, 'V'))
image2=at.RGBImage(np.random.rand(20,20,3)*255,dtype=np.uint8, 
                  axistags=at.VigraArray.defaultAxistags(3, 'V'))
scalar_image=at.ScalarImage(np.random.rand(10,10)*255,dtype=np.float32, 
                  axistags=at.AxisTags(at.AxisInfo.x, at.AxisInfo.y))
volume256=at.Volume(np.random.rand(8,9,10)*255,dtype=np.uint8, 
                  axistags=at.AxisTags(at.AxisInfo.x, at.AxisInfo.y, at.AxisInfo.z))
volumeFloat=at.Volume(np.random.rand(3,4,5,6)*100,dtype=np.float32, 
                  axistags=at.VigraArray.defaultAxistags(4, 'C'))

def checkEqualData(i1,i2):
    assert_equal(i1.shape, i2.shape)
    assert(np.all(i1==i2))

def checkUnequalData(i1,i2):
    assert_equal(i1.shape, i2.shape)
    assert(np.any(i1!=i2))

def test_multiImageTiff():
    if not 'TIFF' in im.listFormats():
Esempio n. 5
0
#
#######################################################################

import sys
print >> sys.stderr, "\nexecuting test file", __file__
execfile('set_paths.py')

from nose.tools import assert_equal, raises, assert_raises
import vigra
import numpy as np
from vigra.analysis import *
from vigra.filters import *
import vigra.arraytypes as at

img_rgb_f = at.RGBImage(np.random.rand(100, 200, 3) * 255, dtype=np.float32)
img_scalar_f = at.ScalarImage(np.random.rand(100, 200) * 255, dtype=np.float32)
img_multi_f = at.Vector3Image(np.random.rand(100, 200, 3) * 255,
                              dtype=np.float32)

img_rgb_i = at.RGBImage(np.random.rand(100, 200, 3) * 255, dtype=np.int32)
img_scalar_i = at.ScalarImage(np.random.rand(100, 200) * 255, dtype=np.uint32)
img_scalar_i64 = at.ScalarImage(np.random.rand(199, 199) * 4095,
                                dtype=np.uint64)
img_scalar_ui8 = at.ScalarImage(np.random.rand(100, 200) * 255, dtype=np.uint8)
img_multi_i = at.Vector3Image(np.random.rand(100, 200, 3) * 255,
                              dtype=np.int32)

vol_rgb_f = at.RGBVolume(np.random.rand(100, 200, 60, 3) * 255,
                         dtype=np.float32)
vol_scalar_f = at.ScalarVolume(np.random.rand(100, 200, 50) * 255,
                               dtype=np.float32)