Exemplo n.º 1
0
class TestObjectsSegment(TestThresholdOneLevel):
    @unittest.skipIf(not haveGraphCut(), "opengm not available")
    def setUp(self):
        super(TestObjectsSegment, self).setUp()
        self.curOperator = 2
        self.usePreThreshold = True

    # time axes not implemented
    @unittest.expectedFailure
    def testEvenFunnierAxes(self):
        super(TestObjectsSegment, self).testEvenFunnierAxes()

    # NoOp uses threshold value -> not meaningful for graphcut
    @unittest.skip("Makes no sense with graph cut")
    def testNoOp(self):
        super(TestGraphCut, self).testNoOp()
Exemplo n.º 2
0
        oper5d.MinSize.setValue(1)
        oper5d.MaxSize.setValue(vol.size)
        oper5d.SingleThreshold.setValue(128)
        oper5d.SmootherSigma.setValue({'x': 0.0, 'y': 0.0, 'z': 0.0})
        oper5d.CurOperator.setValue(self.curOperator)
        oper5d.UsePreThreshold.setValue(self.usePreThreshold)

        #for i in range(vol.shape[3]):
        for i in range(2, 5):  # just test some sample slices (runtime :)
            oper5d.Channel.setValue(i)
            out5d = oper5d.Output[:].wait()
            out5d[out5d > 0] = 1
            numpy.testing.assert_array_equal(out5d.squeeze(), desiredResult[..., i, :])


@unittest.skipIf(not haveGraphCut(), "opengm not available")
class TestObjectsSegment(TestThresholdOneLevel):
    def setUp(self):
        super(TestObjectsSegment, self).setUp()
        self.curOperator = 2
        self.usePreThreshold = True

    # time axes not implemented
    @unittest.expectedFailure
    def testEvenFunnierAxes(self):
        super(TestObjectsSegment, self).testEvenFunnierAxes()

    # NoOp uses threshold value -> not meaningful for graphcut
    @unittest.skip("Makes no sense with graph cut")
    def testNoOp(self):
        super(TestGraphCut, self).testNoOp()
Exemplo n.º 3
0
    vol[0, 5:10, 5:10, 5:10, :] = np.random.rand(1, 5, 5, 5, c) * 0.39 + 0.6
    vol[0, 13:18, 13:18, 13:18, :] = np.random.rand(1, 5, 5, 5, c) * 0.39 + 0.6
    vol[2, 7:12, 7:12, 7:12, :] = np.random.rand(1, 5, 5, 5, c) * 0.39 + 0.6

    labels[0, 5:10, 5:10, 5:10, :] = 1
    labels[0, 13:18, 13:18, 13:18, :] = 2
    labels[2, 7:12, 7:12, 7:12, :] = 1

    # convert to the thresholding operators internal axes order
    fullVolume = vigra.taggedView(vol, axistags='tzyxc')
    fullLabels = vigra.taggedView(labels, axistags='tzyxc')

    return (fullVolume, fullLabels)


if haveGraphCut():
    from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import OpObjectsSegment, OpGraphCut

    class TestOpGraphCut(unittest.TestCase):
        def setUp(self):
            self.tinyVolume, self.labels = getTinyTestVolume()

        def testComplete(self):
            graph = Graph()
            op = OpGraphCut(graph=graph)
            piper = OpArrayPiper(graph=graph)
            piper.Input.setValue(self.tinyVolume)
            op.Prediction.connect(piper.Output)

            out = op.CachedOutput[...].wait()
            out = vigra.taggedView(out, axistags=op.Output.meta.axistags)
Exemplo n.º 4
0
    vol[0, 5:10, 5:10, 5:10, :] = np.random.rand(1, 5, 5, 5, c) * 0.39 + 0.6
    vol[0, 13:18, 13:18, 13:18, :] = np.random.rand(1, 5, 5, 5, c) * 0.39 + 0.6
    vol[2, 7:12, 7:12, 7:12, :] = np.random.rand(1, 5, 5, 5, c) * 0.39 + 0.6

    labels[0, 5:10, 5:10, 5:10, :] = 1
    labels[0, 13:18, 13:18, 13:18, :] = 2
    labels[2, 7:12, 7:12, 7:12, :] = 1

    # convert to the thresholding operators internal axes order
    fullVolume = vigra.taggedView(vol, axistags="tzyxc")
    fullLabels = vigra.taggedView(labels, axistags="tzyxc")

    return (fullVolume, fullLabels)


if haveGraphCut():
    from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import OpObjectsSegment, OpGraphCut


@pytest.mark.skipif(not haveGraphCut(), reason="GraphCut not available")
class TestOpGraphCut(unittest.TestCase):
    def setUp(self):
        self.tinyVolume, self.labels = getTinyTestVolume()

    def testComplete(self):
        graph = Graph()
        op = OpGraphCut(graph=graph)
        piper = OpArrayPiper(graph=graph)
        piper.Input.setValue(self.tinyVolume)
        op.Prediction.connect(piper.Output)
Exemplo n.º 5
0
# workflows and plugins which are not covered under the GNU
# General Public License.
#
# See the LICENSE file for details. License information is also available
# on the ilastik web site at:
# 		   http://ilastik.org/license.html
##############################################################################


import unittest
import numpy as np
import vigra

from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import haveGraphCut

have_opengm = haveGraphCut()

from numpy.testing.utils import assert_array_equal, assert_array_almost_equal, assert_array_less
from nose import SkipTest

from lazyflow.graph import Graph
from lazyflow.operators.opArrayPiper import OpArrayPiper

if have_opengm:
    from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import OpObjectsSegment, OpGraphCut


def getTestVolume():
    t, c = 3, 2
    shape = (t, 120, 100, 90, c)
    vol = np.zeros(shape, dtype=np.float32)
Exemplo n.º 6
0
# In addition, as a special exception, the copyright holders of
# ilastik give you permission to combine ilastik with applets,
# workflows and plugins which are not covered under the GNU
# General Public License.
#
# See the LICENSE file for details. License information is also available
# on the ilastik web site at:
#		   http://ilastik.org/license.html
##############################################################################

import unittest
import numpy as np
import vigra

from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import haveGraphCut
have_opengm = haveGraphCut()

from numpy.testing.utils import assert_array_equal,\
    assert_array_almost_equal, assert_array_less
from nose import SkipTest

from lazyflow.graph import Graph
from lazyflow.operators.opArrayPiper import OpArrayPiper

if have_opengm:
    from ilastik.applets.thresholdTwoLevels.opGraphcutSegment\
        import OpObjectsSegment, OpGraphCut


def getTestVolume():
    t, c = 3, 2
Exemplo n.º 7
0
        oper5d.MinSize.setValue(1)
        oper5d.MaxSize.setValue(vol.size)
        oper5d.SingleThreshold.setValue(128)
        oper5d.SmootherSigma.setValue({'x': 0.0, 'y': 0.0, 'z': 0.0})
        oper5d.CurOperator.setValue(self.curOperator)
        oper5d.UsePreThreshold.setValue(self.usePreThreshold)

        #for i in range(vol.shape[3]):
        for i in range(2, 5):  # just test some sample slices (runtime :)
            oper5d.Channel.setValue(i)
            out5d = oper5d.Output[:].wait()
            out5d[out5d > 0] = 1
            numpy.testing.assert_array_equal(out5d.squeeze(), desiredResult[..., i, :])


@unittest.skipIf(not haveGraphCut(), "opengm not available")
class TestObjectsSegment(TestThresholdOneLevel):
    def setUp(self):
        super(TestObjectsSegment, self).setUp()
        self.curOperator = 2
        self.usePreThreshold = True

    # time axes not implemented
    @unittest.expectedFailure
    def testEvenFunnierAxes(self):
        super(TestObjectsSegment, self).testEvenFunnierAxes()

    # NoOp uses threshold value -> not meaningful for graphcut
    @unittest.skip("Makes no sense with graph cut")
    def testNoOp(self):
        super(TestGraphCut, self).testNoOp()
Exemplo n.º 8
0
    vol[0, 5:10, 5:10, 5:10, :] = np.random.rand(1, 5, 5, 5, c)*0.39+0.6
    vol[0, 13:18, 13:18, 13:18, :] = np.random.rand(1, 5, 5, 5, c)*0.39+0.6
    vol[2, 7:12, 7:12, 7:12, :] = np.random.rand(1, 5, 5, 5, c)*0.39+0.6

    labels[0, 5:10, 5:10, 5:10, :] = 1
    labels[0, 13:18, 13:18, 13:18, :] = 2
    labels[2, 7:12, 7:12, 7:12, :] = 1

    # convert to the thresholding operators internal axes order
    fullVolume = vigra.taggedView(vol, axistags='tzyxc')
    fullLabels = vigra.taggedView(labels, axistags='tzyxc')

    return (fullVolume, fullLabels)


if haveGraphCut():
    from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import OpObjectsSegment, OpGraphCut


@pytest.mark.skipif(not haveGraphCut(), reason="GraphCut not available")
class TestOpGraphCut(unittest.TestCase):

    def setUp(self):
        self.tinyVolume, self.labels = getTinyTestVolume()

    def testComplete(self):
        graph = Graph()
        op = OpGraphCut(graph=graph)
        piper = OpArrayPiper(graph=graph)
        piper.Input.setValue(self.tinyVolume)
        op.Prediction.connect(piper.Output)
Exemplo n.º 9
0
class TestGraphCut(TestObjectsSegment):
    @unittest.skipIf(not haveGraphCut(), "opengm not available")
    def setUp(self):
        super(TestGraphCut, self).setUp()
        self.usePreThreshold = False
Exemplo n.º 10
0
    vol[0, 5:10, 5:10, 5:10, :] = np.random.rand(1, 5, 5, 5, c)*0.39+0.6
    vol[0, 13:18, 13:18, 13:18, :] = np.random.rand(1, 5, 5, 5, c)*0.39+0.6
    vol[2, 7:12, 7:12, 7:12, :] = np.random.rand(1, 5, 5, 5, c)*0.39+0.6

    labels[0, 5:10, 5:10, 5:10, :] = 1
    labels[0, 13:18, 13:18, 13:18, :] = 2
    labels[2, 7:12, 7:12, 7:12, :] = 1

    # convert to the thresholding operators internal axes order
    fullVolume = vigra.taggedView(vol, axistags='tzyxc')
    fullLabels = vigra.taggedView(labels, axistags='tzyxc')

    return (fullVolume, fullLabels)


if haveGraphCut():
    from ilastik.applets.thresholdTwoLevels.opGraphcutSegment import OpObjectsSegment, OpGraphCut

    class TestOpGraphCut(unittest.TestCase):
     
        def setUp(self):
            self.tinyVolume, self.labels = getTinyTestVolume()
     
        def testComplete(self):
            graph = Graph()
            op = OpGraphCut(graph=graph)
            piper = OpArrayPiper(graph=graph)
            piper.Input.setValue(self.tinyVolume)
            op.Prediction.connect(piper.Output)

            out = op.CachedOutput[...].wait()