コード例 #1
0
    def testDeleteLabel2(self):
        """
        Another test to check behavior after deleting an entire label class from the sparse array.
        This one ensures that different blocks have different max label values before the delete occurs.
        """
        op = self.op
        slicing = self.slicing
        data = self.data

        # assert op.maxLabel.value == 2

        # Choose slicings that do NOT intersect with any of the previous data or with each other
        # The goal is to make sure that the data for each slice ends up in a separate block
        slicing1 = numpy.s_[0:1, 60:65, 0:10, 3:7, 0:1]
        slicing2 = numpy.s_[0:1, 90:95, 0:90, 3:7, 0:1]

        expectedData = self.data[...]

        labels1 = numpy.ndarray(slicing2shape(slicing1), dtype=numpy.uint8)
        labels1[...] = 1
        op.Input[slicing1] = labels1
        expectedData[slicing1] = labels1

        labels2 = numpy.ndarray(slicing2shape(slicing2), dtype=numpy.uint8)
        labels2[...] = 2
        op.Input[slicing2] = labels2
        expectedData[slicing2] = labels2

        # Sanity check:
        # Does the data contain our new labels?
        assert (op.Output[...].wait() == expectedData).all()
        assert expectedData.max() == 2
        # assert op.maxLabel.value == 2

        # Delete label 1
        op.deleteLabel.setValue(1)
        outputData = op.Output[...].wait()

        # Expected: All 1s removed, all 2s converted to 1s
        expectedData = numpy.where(expectedData == 1, 0, expectedData)
        expectedData = numpy.where(expectedData == 2, 1, expectedData)
        expectedData = numpy.ma.masked_array(expectedData,
                                             mask=self.data.mask,
                                             fill_value=self.data.fill_value,
                                             shrink=False)

        assert numpy.all(outputData == expectedData)
        assert numpy.all(outputData.mask == expectedData.mask)
        assert numpy.all(outputData.fill_value == expectedData.fill_value)
コード例 #2
0
    def testDeleteLabel2(self):
        """
        Another test to check behavior after deleting an entire label class from the sparse array.
        This one ensures that different blocks have different max label values before the delete occurs.
        """
        op = self.op
        slicing = self.slicing
        data = self.data

        #assert op.maxLabel.value == 2

        # Choose slicings that do NOT intersect with any of the previous data or with each other
        # The goal is to make sure that the data for each slice ends up in a separate block
        slicing1 = sl[0:1, 60:65, 0:10, 3:7, 0:1]
        slicing2 = sl[0:1, 90:95, 0:90, 3:7, 0:1]

        expectedData = self.data[...]

        labels1 = numpy.ndarray(slicing2shape(slicing1), dtype=numpy.uint8)
        labels1[...] = 1
        op.Input[slicing1] = labels1
        expectedData[slicing1] = labels1

        labels2 = numpy.ndarray(slicing2shape(slicing2), dtype=numpy.uint8)
        labels2[...] = 2
        op.Input[slicing2] = labels2
        expectedData[slicing2] = labels2

        # Sanity check:
        # Does the data contain our new labels?
        assert (op.Output[...].wait() == expectedData).all()
        assert expectedData.max() == 2
        #assert op.maxLabel.value == 2

        # Delete label 1
        op.deleteLabel.setValue(1)
        outputData = op.Output[...].wait()

        # Expected: All 1s removed, all 2s converted to 1s
        expectedData = numpy.where(expectedData == 1, 0, expectedData)
        expectedData = numpy.where(expectedData == 2, 1, expectedData)
        expectedData = numpy.ma.masked_array(expectedData,
                                             mask=self.data.mask,
                                             fill_value=self.data.fill_value,
                                             shrink=False)

        assert numpy.all(outputData == expectedData)
        assert numpy.all(outputData.mask == expectedData.mask)
        assert numpy.all(outputData.fill_value == expectedData.fill_value)
コード例 #3
0
    def setup(self):
        graph = Graph()
        op = OpCompressedUserLabelArray(graph=graph)
        arrayshape = (1, 100, 100, 10, 1)
        op.inputs["shape"].setValue(arrayshape)
        blockshape = (1, 10, 10, 10, 1
                      )  # Why doesn't this work if blockshape is an ndarray?
        op.inputs["blockShape"].setValue(blockshape)
        op.eraser.setValue(100)

        dummyData = vigra.VigraArray(arrayshape,
                                     axistags=vigra.defaultAxistags("txyzc"),
                                     dtype=numpy.uint8)
        op.Input.setValue(dummyData)

        slicing = numpy.s_[0:1, 1:15, 2:36, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = (3 * numpy.random.random(inDataShape)).astype(numpy.uint8)
        op.Input[slicing] = inputData

        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData

        # Sanity check...
        assert (op.Output[:].wait()[slicing] == data[slicing]).all()

        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #4
0
    def setup(self):
        graph = Graph()
        op = OpCompressedUserLabelArray(graph=graph)
        arrayshape = (1,100,100,10,1)
        op.inputs["shape"].setValue( arrayshape )
        blockshape = (1,10,10,10,1) # Why doesn't this work if blockshape is an ndarray?
        op.inputs["blockShape"].setValue( blockshape )
        op.eraser.setValue(100)

        dummyData = vigra.VigraArray(arrayshape, axistags=vigra.defaultAxistags('txyzc'))
        op.Input.setValue( dummyData )

        slicing = sl[0:1, 1:15, 2:36, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
        op.Input[slicing] = inputData
        
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData

        # Sanity check...
        assert (op.Output[:].wait()[slicing] == data[slicing]).all()

        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #5
0
    def testSetInSlot(self):
        logger.info("Generating sample data...")
        sampleData = numpy.indices((100, 200, 150), dtype=numpy.float32).sum(0)
        sampleData = sampleData.view(vigra.VigraArray)
        sampleData.axistags = vigra.defaultAxistags('xyz')

        graph = Graph()
        opData = OpArrayPiper(graph=graph)
        opData.Input.setValue(sampleData)

        op = OpCompressedCache(parent=None, graph=graph)
        #logger.debug("Setting block shape...")
        op.BlockShape.setValue([100, 75, 50])
        op.Input.connect(opData.Output)

        assert op.Output.ready()

        slicing = numpy.s_[0:100, 0:75, 0:50]
        expectedData = numpy.ones(slicing2shape(slicing), dtype=int)

        # This is what we're testing.
        #logger.debug("Forcing external data...")
        op.Input[slicing] = expectedData

        #logger.debug("Requesting data...")
        readData = op.Output[slicing].wait()

        #logger.debug("Checking data...")
        assert (readData == expectedData).all(), "Incorrect output!"
コード例 #6
0
    def testEraseBlock(self):
        """
        If we use the eraser to remove all labels from a block,
        it should be removed from the CleanBlocks slot.
        """
        op = self.op
        slicing = self.slicing
        inData = self.inData
        data = self.data

        # BEFORE (convert to tuple)
        clean_blocks_before = [ (tuple(a),tuple(b)) for (a,b) in op.CleanBlocks.value ]
        
        block_slicing = sl[0:1, 10:20, 10:20, 0:10, 0:1]
        block_roi = ((0,10,10,0,0), (1,20,20,10,1))
        
        eraser_data = 100 * numpy.ones( slicing2shape(block_slicing), dtype=numpy.uint8 )
        op.Input[block_slicing] = eraser_data
        
        expected_data = data.copy()
        expected_data[block_slicing] = 0
        
        # quick sanity check: the data was actually cleared by the eraser
        assert (op.Output[:].wait() == expected_data).all()

        # AFTER (convert to tuple)
        clean_blocks_after = [ (tuple(a),tuple(b)) for (a,b) in op.CleanBlocks.value ]
        
        before_set = set(map(tuple, clean_blocks_before))
        after_set = set(map(tuple, clean_blocks_after))
        
        assert before_set - set([block_roi]) == after_set
コード例 #7
0
    def testSetInSlot(self):
        logger.info("Generating sample data...")
        sampleData = numpy.indices((100, 200, 150), dtype=numpy.float32).sum(0)
        sampleData = sampleData.view( vigra.VigraArray )
        sampleData.axistags = vigra.defaultAxistags('xyz')
        
        graph = Graph()
        opData = OpArrayPiper( graph=graph )
        opData.Input.setValue( sampleData )
        
        op = OpCompressedCache( parent=None, graph=graph )
        #logger.debug("Setting block shape...")
        op.BlockShape.setValue( [100, 75, 50] )
        op.Input.connect( opData.Output )
        
        assert op.Output.ready()
        
        slicing = numpy.s_[ 0:100, 0:75, 0:50 ]
        expectedData = numpy.ones( slicing2shape(slicing), dtype=int )

        # This is what we're testing.
        #logger.debug("Forcing external data...")
        op.Input[slicing] = expectedData
        
        #logger.debug("Requesting data...")
        readData = op.Output[slicing].wait()
        
        #logger.debug("Checking data...")    
        assert (readData == expectedData).all(), "Incorrect output!"
コード例 #8
0
 def testOutputCrash(self):
     """
     Bare-minimum test: Just make sure we can request the output without crashing.
     """
     slicing = sl[0:1, 0:5, 6:20, 30:40, 0:1]
     result = self.op.Output[slicing].wait()
     assert result.shape == slicing2shape(slicing)
コード例 #9
0
    def testEraseBlock(self):
        """
        If we use the eraser to remove all labels from a block,
        it should be removed from the CleanBlocks slot.
        """
        op = self.op
        slicing = self.slicing
        inData = self.inData
        data = self.data

        # BEFORE (convert to tuple)
        clean_blocks_before = [(tuple(a), tuple(b))
                               for (a, b) in op.CleanBlocks.value]

        block_slicing = numpy.s_[0:1, 10:20, 10:20, 0:10, 0:1]
        block_roi = ((0, 10, 10, 0, 0), (1, 20, 20, 10, 1))

        eraser_data = 100 * numpy.ones(slicing2shape(block_slicing),
                                       dtype=numpy.uint8)
        op.Input[block_slicing] = eraser_data

        expected_data = data.copy()
        expected_data[block_slicing] = 0

        # quick sanity check: the data was actually cleared by the eraser
        assert (op.Output[:].wait() == expected_data).all()

        # AFTER (convert to tuple)
        clean_blocks_after = [(tuple(a), tuple(b))
                              for (a, b) in op.CleanBlocks.value]

        before_set = set(map(tuple, clean_blocks_before))
        after_set = set(map(tuple, clean_blocks_after))

        assert before_set - set([block_roi]) == after_set
コード例 #10
0
    def setup(self):
        graph = Graph()
        try:
            import blist
        except ImportError:
            raise unittest.SkipTest

        from lazyflow.operators.opBlockedSparseLabelArray import OpBlockedSparseLabelArray
        op = OpBlockedSparseLabelArray(graph=graph)
        arrayshape = (1,100,100,10,1)
        op.inputs["shape"].setValue( arrayshape )
        blockshape = (1,10,10,10,1) # Why doesn't this work if blockshape is an ndarray?
        op.inputs["blockShape"].setValue( blockshape )
        op.eraser.setValue(100)

        dummyData = vigra.VigraArray(arrayshape, axistags=vigra.defaultAxistags('txyzc'))
        op.Input.setValue( dummyData )

        slicing = sl[0:1, 1:15, 2:36, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
        op.Input[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData
        
        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #11
0
    def setup(self):
        graph = Graph()
        op = OpCompressedUserLabelArray(graph=graph)
        arrayshape = (1,100,100,10,1)
        op.inputs["shape"].setValue( arrayshape )
        blockshape = (1,10,10,10,1) # Why doesn't this work if blockshape is an ndarray?
        op.inputs["blockShape"].setValue( blockshape )
        op.eraser.setValue(100)

        op.Input.meta.axistags = vigra.defaultAxistags('txyzc')
        op.Input.meta.has_mask = True
        dummyData = numpy.zeros(arrayshape, dtype=numpy.uint8)
        dummyData = numpy.ma.masked_array(dummyData, mask=numpy.ma.getmaskarray(dummyData), fill_value=numpy.uint8(0), shrink=False)
        op.Input.setValue( dummyData )

        slicing = sl[0:1, 1:15, 2:36, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
        inputData = numpy.ma.masked_array(inputData, mask=numpy.ma.getmaskarray(inputData), fill_value=numpy.uint8(0), shrink=False)
        inputData[:, 0] = numpy.ma.masked
        op.Input[slicing] = inputData
        data = numpy.ma.zeros(arrayshape, dtype=numpy.uint8, fill_value=numpy.uint8(0))
        data[slicing] = inputData

        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #12
0
 def testOutputCrash(self):
     """
     Bare-minimum test: Just make sure we can request the output without crashing.
     """
     slicing = sl[0:1, 0:5, 6:20, 30:40, 0:1]
     result = self.op.Output[slicing].wait()
     assert result.shape == slicing2shape(slicing)
コード例 #13
0
    def testEraseAll(self):
        """
        Test behavior when all labels of a particular class are erased.
        Note that this is not the same as deleting a label class, but should have the same effect on the output slots.
        """
        op = self.op
        slicing = self.slicing
        data = self.data

        # assert op.maxLabel.value == 2

        newSlicing = list(slicing)
        newSlicing[1] = slice(1, 2)

        # Add some new labels for a class that hasn't been seen yet (3)
        threeData = numpy.ndarray(slicing2shape(newSlicing), dtype=numpy.uint8)
        threeData[...] = 3
        op.Input[newSlicing] = threeData
        expectedData = data[...]
        expectedData[newSlicing] = 3

        # Sanity check: Are the new labels in the data?
        outputData = op.Output[...].wait()
        assert numpy.all(outputData == expectedData)
        assert numpy.all(outputData.mask == expectedData.mask)
        assert numpy.all(outputData.fill_value == expectedData.fill_value)
        assert expectedData.max() == 3
        # assert op.maxLabel.value == 3

        # Now erase all the 3s
        eraserData = numpy.ones(slicing2shape(newSlicing),
                                dtype=numpy.uint8) * 100
        op.Input[newSlicing] = eraserData
        expectedData = data[...]
        expectedData[newSlicing] = 0

        # The data we erased should be zeros
        outputData = op.Output[...].wait()
        assert numpy.all(outputData == expectedData)
        assert numpy.all(outputData.mask == expectedData.mask)
        assert numpy.all(outputData.fill_value == expectedData.fill_value)

        # The maximum label should be reduced, because all the 3s were removed.
        assert expectedData.max() == 2
コード例 #14
0
    def testEraseAll(self):
        """
        Test behavior when all labels of a particular class are erased.
        Note that this is not the same as deleting a label class, but should have the same effect on the output slots.
        """
        op = self.op
        slicing = self.slicing
        data = self.data

        #assert op.maxLabel.value == 2

        newSlicing = list(slicing)
        newSlicing[1] = slice(1,2)

        # Add some new labels for a class that hasn't been seen yet (3)
        threeData = numpy.ndarray(slicing2shape(newSlicing), dtype=numpy.uint8)
        threeData[...] = 3
        op.Input[newSlicing] = threeData
        expectedData = data[...]
        expectedData[newSlicing] = 3

        # Sanity check: Are the new labels in the data?
        outputData = op.Output[...].wait()
        assert numpy.all(outputData == expectedData)
        assert numpy.all(outputData.mask == expectedData.mask)
        assert numpy.all(outputData.fill_value == expectedData.fill_value)
        assert expectedData.max() == 3
        #assert op.maxLabel.value == 3

        # Now erase all the 3s
        eraserData = numpy.ones(slicing2shape(newSlicing), dtype=numpy.uint8) * 100
        op.Input[newSlicing] = eraserData
        expectedData = data[...]
        expectedData[newSlicing] = 0

        # The data we erased should be zeros
        outputData = op.Output[...].wait()
        assert numpy.all(outputData == expectedData)
        assert numpy.all(outputData.mask == expectedData.mask)
        assert numpy.all(outputData.fill_value == expectedData.fill_value)

        # The maximum label should be reduced, because all the 3s were removed.
        assert expectedData.max() == 2
コード例 #15
0
    def testWithSeeds(self):
        """
        Bare-minimum test: Just make sure we can request the output without crashing.
        """
        seeds = numpy.zeros(self.inputData.shape, dtype=numpy.uint32)
        self.op.SeedImage.setValue(seeds)

        slicing = sl[0:1, 0:5, 6:20, 30:40, 0:1]
        result = self.op.Output[slicing].wait()

        assert result.shape == slicing2shape(slicing)
コード例 #16
0
    def testWithSeeds(self):
        """
        Bare-minimum test: Just make sure we can request the output without crashing.
        """
        seeds = numpy.zeros( self.inputData.shape, dtype=numpy.uint32 )
        self.op.SeedImage.setValue( seeds )

        slicing = sl[0:1, 0:5, 6:20, 30:40, 0:1]
        result = self.op.Output[slicing].wait()

        assert result.shape == slicing2shape(slicing)
コード例 #17
0
    def testWithFullSeeds(self):
        """
        If every pixel is seeded, there's nothing for the watershed to do.
        Output should be a copy of the seeds
        """
        # Random seed data
        seeds = 4 * numpy.random.random(self.inputData.shape)
        seeds = seeds.astype(numpy.uint32)
        seeds += 1

        self.op.SeedImage.setValue(seeds)

        slicing = sl[0:1, 0:5, 6:20, 30:40, 0:1]
        result = self.op.Output[slicing].wait()

        assert result.shape == slicing2shape(slicing)
        assert (result == seeds[slicing]).all()
コード例 #18
0
    def testWithFullSeeds(self):
        """
        If every pixel is seeded, there's nothing for the watershed to do.
        Output should be a copy of the seeds
        """
        # Random seed data
        seeds = 4 * numpy.random.random( self.inputData.shape )
        seeds = seeds.astype(numpy.uint32)
        seeds += 1
        
        self.op.SeedImage.setValue( seeds )

        slicing = sl[0:1, 0:5, 6:20, 30:40, 0:1]
        result = self.op.Output[slicing].wait()

        assert result.shape == slicing2shape(slicing)
        assert (result == seeds[slicing]).all()
コード例 #19
0
    def setup(self):
        graph = Graph()
        op = OpSparseLabelArray(graph=graph)
        arrayshape = numpy.array([1, 10, 10, 10, 1])
        op.inputs["shape"].setValue(tuple(arrayshape))
        op.eraser.setValue(100)

        slicing = sl[0:1, 1:5, 2:6, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = (3 * numpy.random.random(inDataShape)).astype(numpy.uint8)
        op.Input[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData

        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #20
0
    def setup(self):
        graph = Graph()
        op = OpSparseLabelArray(graph=graph)
        arrayshape = numpy.array([1,10,10,10,1])
        op.inputs["shape"].setValue( tuple(arrayshape) )
        op.eraser.setValue(100)

        slicing = sl[0:1, 1:5, 2:6, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
        op.Input[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData
        
        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #21
0
    def testSetInSlot_masked(self):
        logger.info("Generating sample data...")
        sampleData = numpy.indices((100, 200, 150), dtype=numpy.float32).sum(0)
        sampleData = sampleData.view(numpy.ma.masked_array)
        sampleData.set_fill_value(numpy.float32(numpy.nan))
        sampleData[0] = numpy.ma.masked

        graph = Graph()
        opData = OpArrayPiper(graph=graph)
        opData.Input.meta.has_mask = True
        opData.Input.meta.axistags = vigra.defaultAxistags("xyz")
        opData.Input.setValue(sampleData)

        op = OpCompressedCache(parent=None, graph=graph)
        # logger.debug("Setting block shape...")
        op.BlockShape.setValue([100, 75, 50])
        op.Input.connect(opData.Output)

        assert op.Output.ready()

        slicing = numpy.s_[0:100, 0:75, 0:50]
        expectedData = numpy.ma.ones(slicing2shape(slicing), dtype=int)
        sampleData.set_fill_value(numpy.float32(numpy.nan))
        expectedData[0] = numpy.ma.masked

        # This is what we're testing.
        # logger.debug("Forcing external data...")
        op.Input[slicing] = expectedData

        # logger.debug("Requesting data...")
        readData = op.Output[slicing].wait()

        # logger.debug("Checking data...")
        assert (
            (readData == expectedData).all()
            and (readData.mask == expectedData.mask).all()
            and (
                (readData.fill_value == expectedData.fill_value)
                | (numpy.isnan(readData.fill_value) & numpy.isnan(expectedData.fill_value))
            ).all()
        ), "Incorrect output!"
コード例 #22
0
    def setup(self):
        graph = Graph()
        
        op = OpDenseLabelArray(graph=graph)
        arrayshape = (1,100,100,10,1)

        op.EraserLabelValue.setValue(100)

        dummyData = vigra.VigraArray(arrayshape, axistags=vigra.defaultAxistags('txyzc'))
        op.MetaInput.setValue( dummyData )

        slicing = sl[0:1, 1:15, 2:36, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
        op.LabelSinkInput[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData
        
        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #23
0
    def testSetInSlot_masked(self):
        logger.info("Generating sample data...")
        sampleData = numpy.indices((100, 200, 150), dtype=numpy.float32).sum(0)
        sampleData = sampleData.view(numpy.ma.masked_array)
        sampleData.set_fill_value(numpy.float32(numpy.nan))
        sampleData[0] = numpy.ma.masked

        graph = Graph()
        opData = OpArrayPiper(graph=graph)
        opData.Input.meta.has_mask = True
        opData.Input.meta.axistags = vigra.defaultAxistags('xyz')
        opData.Input.setValue(sampleData)

        op = OpCompressedCache(parent=None, graph=graph)
        #logger.debug("Setting block shape...")
        op.BlockShape.setValue([100, 75, 50])
        op.Input.connect(opData.Output)

        assert op.Output.ready()

        slicing = numpy.s_[0:100, 0:75, 0:50]
        expectedData = numpy.ma.ones(slicing2shape(slicing), dtype=int)
        sampleData.set_fill_value(numpy.float32(numpy.nan))
        expectedData[0] = numpy.ma.masked

        # This is what we're testing.
        #logger.debug("Forcing external data...")
        op.Input[slicing] = expectedData

        #logger.debug("Requesting data...")
        readData = op.Output[slicing].wait()

        #logger.debug("Checking data...")
        assert (readData == expectedData).all() and \
               (readData.mask == expectedData.mask).all() and \
               ((readData.fill_value == expectedData.fill_value) |
                (numpy.isnan(readData.fill_value) & numpy.isnan(expectedData.fill_value))).all(),\
            "Incorrect output!"
コード例 #24
0
    def setup(self):
        graph = Graph()

        op = OpDenseLabelArray(graph=graph)
        arrayshape = (1, 100, 100, 10, 1)

        op.EraserLabelValue.setValue(100)

        dummyData = vigra.VigraArray(arrayshape,
                                     axistags=vigra.defaultAxistags("txyzc"))
        op.MetaInput.setValue(dummyData)

        slicing = numpy.s_[0:1, 1:15, 2:36, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = (3 * numpy.random.random(inDataShape)).astype(numpy.uint8)
        op.LabelSinkInput[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData

        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #25
0
    def setup(self):
        try:
            import blist
        except ImportError:
            raise unittest.SkipTest 
        
        from lazyflow.operators.opSparseLabelArray import OpSparseLabelArray
        graph = Graph()
        op = OpSparseLabelArray(graph=graph)
        arrayshape = numpy.array([1,10,10,10,1])
        op.inputs["shape"].setValue( tuple(arrayshape) )
        op.eraser.setValue(100)

        slicing = sl[0:1, 1:5, 2:6, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = ( 3*numpy.random.random(inDataShape) ).astype(numpy.uint8)
        op.Input[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData
        
        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #26
0
    def setup(self):
        try:
            import blist
        except ImportError:
            raise unittest.SkipTest

        from lazyflow.operators.opSparseLabelArray import OpSparseLabelArray
        graph = Graph()
        op = OpSparseLabelArray(graph=graph)
        arrayshape = numpy.array([1, 10, 10, 10, 1])
        op.inputs["shape"].setValue(tuple(arrayshape))
        op.eraser.setValue(100)

        slicing = sl[0:1, 1:5, 2:6, 3:7, 0:1]
        inDataShape = slicing2shape(slicing)
        inputData = (3 * numpy.random.random(inDataShape)).astype(numpy.uint8)
        op.Input[slicing] = inputData
        data = numpy.zeros(arrayshape, dtype=numpy.uint8)
        data[slicing] = inputData

        self.op = op
        self.slicing = slicing
        self.inData = inputData
        self.data = data
コード例 #27
0
ファイル: adaptors.py プロジェクト: burgerdev/lazyflow
 def __getitem__(self, slicing):
     sl3d = (slicing[1], slicing[2], slicing[3])
     ret = np.zeros(slicing2shape(slicing), dtype=self.dtype)
     ret[0, :, :, :, 0] = self.a[tuple(sl3d)]
     return ret
コード例 #28
0
ファイル: adaptors.py プロジェクト: thatcher/lazyflow
 def __getitem__(self, slicing):
     sl3d = (slicing[1], slicing[2], slicing[3])
     ret = np.zeros(slicing2shape(slicing), dtype=self.dtype)
     ret[0, :, :, :, 0] = self.a[tuple(sl3d)]
     return ret