def testWithCustomBackground(self):
        graph = Graph()
        # OpDummyData needs an input array to decide what shape/dtype/axes to make the output
        a = numpy.ndarray(shape=(2, 100, 100, 100, 3), dtype=numpy.uint32)
        v = a.view(vigra.VigraArray)
        v.axistags = vigra.defaultAxistags('txyzc')

        # OpDummyData provides a simple binary image with a bunch of thick diagonal planes.
        opData = OpDummyData(graph=graph)
        opData.Input.setValue(v)
        assert opData.Output.ready()
        assert opData.Output.meta.axistags is not None

        # Each diagonal plane should get it's own label...
        op = OpCachedLabelImage(graph=graph)
        op.Input.connect(opData.Output)
        op.BackgroundLabels.setValue(
            [0, 1, 0])  # Use inverted background for the second channel
        assert op.Output.ready()

        data = opData.Output[:].wait()
        labels = op.Output[:].wait()
        channel = 0
        #logger.debug( "data-c0:\n{}".format( str(data[0,:80:5,:80:5,0,channel])) )
        #logger.debug( "labels-c0:\n{}".format( str(labels[0,:80:5,:80:5,0,channel])) )

        channel = 1
        #logger.debug( "data-c1:\n{}".format( str(data[0,:80:5,:80:5,0,channel])) )
        #logger.debug( "labels-c1:\n{}".format( str(labels[0,:80:5,:80:5,0,channel])) )

        assert labels[0, 0, 0, 0, 0] == 1
        assert labels[
            0, 0, 0, 0,
            1] == 0, "Expected inverted background for the second channel"
    def testBasic(self):
        graph = Graph()
        # OpDummyData needs an input array to decide what shape/dtype/axes to make the output
        a = numpy.ndarray(shape=(2, 100, 100, 100, 3), dtype=numpy.uint32)
        v = a.view(vigra.VigraArray)
        v.axistags = vigra.defaultAxistags('txyzc')

        # OpDummyData provides a simple binary image with a bunch of thick diagonal planes.
        opData = OpDummyData(graph=graph)
        opData.Input.setValue(v)
        assert opData.Output.ready()
        assert opData.Output.meta.axistags is not None

        data = opData.Output[:].wait()
        #logger.debug( "data:\n{}".format( str(data[0,:80:5,:80:5,0,0])) )

        # Each diagonal plane should get it's own label...
        op = OpCachedLabelImage(graph=graph)
        op.Input.connect(opData.Output)
        assert op.Output.ready()

        labels = op.Output[:].wait()
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     super(OpBlockwiseFilesetReader, self).__init__(*args, **kwargs)
     self._blockwiseFileset = None
     self._opDummyData = OpDummyData(parent=self)
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     super(OpExportedImageProvider, self).__init__(*args, **kwargs)
     self._opReader = None
     self._opDummyData = OpDummyData(parent=self)