当前位置: 首页>>代码示例>>Python>>正文


Python vigra.taggedView函数代码示例

本文整理汇总了Python中vigra.taggedView函数的典型用法代码示例。如果您正苦于以下问题:Python taggedView函数的具体用法?Python taggedView怎么用?Python taggedView使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了taggedView函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _label

    def _label(self, roi, result):
        result = vigra.taggedView(result, axistags=self.Output.meta.axistags)
        # get the background values
        bg = self.Background[...].wait()
        bg = vigra.taggedView(bg, axistags=self.Background.meta.axistags)
        bg = bg.withAxes(*'ct')
        assert np.all(self.Background.meta.shape[3:] ==
                      self.Input.meta.shape[3:]),\
            "Shape of background values incompatible to shape of Input"

        # do labeling in parallel over channels and time slices
        pool = RequestPool()

        start = np.asarray(roi.start, dtype=np.int)
        stop = np.asarray(roi.stop, dtype=np.int)
        for ti, t in enumerate(range(roi.start[4], roi.stop[4])):
            start[4], stop[4] = t, t+1
            for ci, c in enumerate(range(roi.start[3], roi.stop[3])):
                start[3], stop[3] = c, c+1
                newRoi = SubRegion(self.Output,
                                   start=tuple(start), stop=tuple(stop))
                resView = result[..., ci, ti].withAxes(*'xyz')
                req = Request(partial(self._label3d, newRoi,
                                      bg[c, t], resView))
                pool.add(req)

        logger.debug(
            "{}: Computing connected components for ROI {} ...".format(
                self.name, roi))
        pool.wait()
        pool.clean()
        logger.debug("{}: Connected components computed.".format(
            self.name))
开发者ID:burcin,项目名称:lazyflow,代码行数:33,代码来源:opLabelVolume.py

示例2: test1

def test1():
    vol = np.zeros((1, 2, 3, 4, 5), dtype=np.uint8)
    vol1 = vigra.taggedView(vol, axistags='txyzc')
    vol2 = vigra.taggedView(vol, axistags='czyxt')

    g = Graph()

    pipe1 = OpArrayPiper(graph=g)
    pipe1.Input.setValue(vol1)
    pipe2 = OpArrayPiper(graph=g)
    pipe2.Input.setValue(vol2)

    slicer = OpMultiArraySlicer(graph=g)
    slicer.AxisFlag.setValue('c')
    op = OperatorWrapper(TestOp, graph=g)
    op.Input.connect(slicer.Slices)
    stacker = OpMultiArrayStacker(graph=g)
    stacker.AxisFlag.setValue('c')
    stacker.Images.connect(op.Output)

    stacker.AxisIndex.setValue(0)
    slicer.Input.connect(pipe1.Output)
    print(stacker.Output.meta.getTaggedShape())

    print()

    stacker.AxisIndex.setValue(0)
    slicer.Input.connect(pipe2.Output)
    print(stacker.Output.meta.getTaggedShape())
开发者ID:burgerdev,项目名称:turbo-dangerzone,代码行数:29,代码来源:opWrap.py

示例3: testFunnyAxes

    def testFunnyAxes(self):
        vol = self.data.withAxes(*'ztxcy')
        g = Graph()
        oper = OpThresholdOneLevel(graph=g)
        oper.MinSize.setValue(self.minSize)
        oper.MaxSize.setValue(self.maxSize)
        oper.Threshold.setValue(0.5)
        oper.InputImage.setValue(vol)

        output = oper.Output[:].wait()
        assert numpy.all(output.shape == vol.shape)

        clusters = self.generateData((self.nx, self.ny, self.nz, self.nc))
        output = vigra.taggedView(output, axistags=oper.Output.meta.axistags)
        output = output.withAxes(*'xyzc')

        cluster1 = numpy.logical_and(output, clusters[0])
        assert numpy.any(cluster1 != 0)

        oper.MinSize.setValue(5)
        output = oper.Output[:].wait()
        cluster1 = numpy.logical_and(output, clusters[0])
        assert numpy.all(cluster1 == 0)

        cluster4 = numpy.logical_and(output.squeeze(), clusters[3])
        assert numpy.all(cluster4 == 0)

        cluster5 = numpy.logical_and(output.squeeze(), clusters[2])
        assert numpy.all(cluster5 == 0)
        oper.Threshold.setValue(0.2)
        output = oper.Output[:].wait()
        output = vigra.taggedView(output, axistags=oper.Output.meta.axistags)
        output = output.withAxes(*'xyzc')
        cluster5 = numpy.logical_and(output.squeeze(), clusters[2])
        assert numpy.any(cluster5 != 0)
开发者ID:burcin,项目名称:ilastik,代码行数:35,代码来源:testThresholdTwoLevels.py

示例4: setUp

 def setUp(self):
     g = Graph()
     rawimg = np.random.randint(0, 255, (2, 10, 10, 10, 1))
     binimg = rawimg>100
     cc0 = vigra.analysis.labelVolumeWithBackground(binimg[0,:, :, :, 0].astype(np.uint8))
     cc1 = vigra.analysis.labelVolumeWithBackground(binimg[1,:, :, :, 0].astype(np.uint8))
     nobj = np.max(cc0)+1+np.max(cc1)+1
     segmimg = np.zeros(rawimg.shape, cc0.dtype)
     segmimg[0,:, : , :, 0] = cc0[:]
     segmimg[1,:, :, :,0] = cc1[:]
     rawimg = vigra.taggedView(rawimg, 'txyzc')
     binimg = vigra.taggedView(rawimg, 'txyzc')
     segmimg = vigra.taggedView(segmimg, 'txyzc')
     
     self.features = {"Bad Plugin": {"bad_feature_1": {}, "bad_feature_2":{}}}
     self.featureArrays = {0: {"Bad Plugin":{"bad_feature_1": np.array(range(nobj)), \
                                            "bad_feature_2": np.array(range(nobj))}},
                           1: {"Bad Plugin":{"bad_feature_1": np.array(range(nobj)), \
                                            "bad_feature_2": np.array(range(nobj))}}}
     
     self.op = OpObjectClassification(graph = g)
     self.op.RawImages.setValues([rawimg])
     self.op.BinaryImages.setValues([binimg])
     self.op.SegmentationImages.setValues([segmimg])
     self.op.ObjectFeatures.setValues([self.featureArrays])
     self.op.ComputedFeatureNames.setValue(self.features)
     self.op.SelectedFeatures.setValue(self.features)
开发者ID:kkiefer,项目名称:ilastik,代码行数:27,代码来源:testOperators.py

示例5: testCircular

    def testCircular(self):
        g = Graph()

        op = OpLazyCC(graph=g)
        op.ChunkShape.setValue((3, 3, 1))

        vol = np.asarray(
            [
                [0, 0, 0, 0, 0, 0, 0, 0, 0],
                [0, 1, 1, 1, 0, 1, 1, 1, 0],
                [0, 1, 0, 0, 0, 0, 0, 1, 0],
                [0, 1, 0, 0, 0, 0, 0, 1, 0],
                [0, 1, 0, 0, 0, 0, 0, 1, 0],
                [0, 1, 0, 0, 0, 0, 0, 1, 0],
                [0, 1, 0, 0, 0, 0, 0, 1, 0],
                [0, 1, 1, 1, 1, 1, 1, 1, 0],
                [0, 0, 0, 0, 0, 0, 0, 0, 0],
            ],
            dtype=np.uint8,
        )
        vol1 = vigra.taggedView(vol, axistags="yx")
        vol2 = vigra.taggedView(vol, axistags="xy")
        vol3 = vigra.taggedView(np.flipud(vol), axistags="yx")
        vol4 = vigra.taggedView(np.flipud(vol), axistags="xy")

        for v in (vol1, vol2, vol3, vol4):
            op.Input.setValue(v)
            for x in [0, 3, 6]:
                for y in [0, 3, 6]:
                    if x == 3 and y == 3:
                        continue
                    op.Input.setDirty(slice(None))
                    out = op.Output[x : x + 3, y : y + 3].wait()
                    print(out.squeeze())
                    assert out.max() == 1
开发者ID:ilastik,项目名称:lazyflow,代码行数:35,代码来源:testOpLazyConnectedComponents.py

示例6: relabel

    def relabel(key_label_mapping):
        import numpy

        (subvolume, labels) = key_label_mapping

        # grab broadcast offset
        offset = numpy.uint64( subvolume_offsets.value[subvolume.sv_index] )

        # check for body mask labels and protect from renumber
        fix_bodies = []
        
        labels = labels + offset 
        
        # make sure 0 is 0
        labels[labels == offset] = 0

        # create default map 
        labels_view = vigra.taggedView(labels.astype(numpy.uint64), 'zyx')
        mapping_col = numpy.sort( vigra.analysis.unique(labels_view) )
        label_mappings = dict(zip(mapping_col, mapping_col))
       
        # create maps from merge list
        for mapping in master_merge_list.value:
            if mapping[0] in label_mappings:
                label_mappings[mapping[0]] = mapping[1]

        # apply maps
        new_labels = numpy.empty_like( labels, dtype=numpy.uint64 )
        new_labels_view = vigra.taggedView(new_labels, 'zyx')
        vigra.analysis.applyMapping(labels_view, label_mappings, allow_incomplete_mapping=True, out=new_labels_view)
        return (subvolume, new_labels)
开发者ID:janelia-flyem,项目名称:DVIDSparkServices,代码行数:31,代码来源:morpho.py

示例7: testSingletonZ

    def testSingletonZ(self):
        vol = np.zeros((82, 70, 1, 5, 5), dtype=np.uint8)
        vol = vigra.taggedView(vol, axistags='xyzct')

        blocks = np.zeros(vol.shape, dtype=np.uint8)
        blocks[30:50, 40:60, :, 2:4, 3:5] = 1
        blocks[30:50, 40:60, :, 2:4, 0:2] = 2
        blocks[60:70, 30:40, :, :, :] = 3

        vol[blocks == 1] = 255
        vol[blocks == 2] = 255
        vol[blocks == 3] = 255

        op = OpLabelVolume(graph=Graph())
        op.Method.setValue(self.method)
        op.Input.setValue(vol)

        out = op.Output[...].wait()
        tags = op.Output.meta.getTaggedShape()
        print(tags)
        out = vigra.taggedView(out, axistags="".join([s for s in tags]))

        for c in range(out.shape[3]):
            for t in range(out.shape[4]):
                print("t={}, c={}".format(t, c))
                assertEquivalentLabeling(blocks[..., c, t], out[..., c, t])
开发者ID:CVML,项目名称:lazyflow,代码行数:26,代码来源:testOpLabelVolume.py

示例8: testOptimalInit

    def testOptimalInit(self):
        x = np.asarray([0, 0, 1, 1, .5])
        y = np.asarray([0, 1, 0, 1, .5])
        vol = np.zeros((5, 2), dtype=np.float32)
        vol[:, 0] = x
        vol[:, 1] = y
        vol = vigra.taggedView(vol, axistags='tc')

        z = x*(1-y) + y*(1-x)
        z = vigra.taggedView(z[:, np.newaxis], axistags='tc')

        nvis = 2
        ncent = 5
        layers = [Sigmoid(layer_name='bumps', irange=0, dim=2*nvis*ncent),
                  Sigmoid(layer_name='cents', irange=0, dim=ncent),
                  Linear(layer_name='out', irange=0, dim=1)]
        mlp = MLP(layers=layers, nvis=nvis)

        init = OptimalInitializer.build({}, graph=Graph())
        init.Data.setValue(vol)
        init.Target.setValue(z)
        init.init_model(mlp)

        op = OpForwardLayers(layers[:], graph=Graph())
        op.Input.setValue(vol)

        z_pred = op.Output[..., 0].wait().squeeze()
        assert max(z_pred[0], z_pred[3]) < z_pred[4]
        assert min(z_pred[1], z_pred[2]) > z_pred[4]
开发者ID:burgerdev,项目名称:hostload,代码行数:29,代码来源:testInitializers.py

示例9: testBasic3

    def testBasic3(self):
        a = numpy.ones((1, 100, 101))
        a = a[..., None]
        a = vigra.taggedView(a, "tyxc")

        r = numpy.array([[0, 0, 0], [1, 3, 4]]).T.copy()

        ar = a.copy()
        for each_r in r:
            nanshe.util.xnumpy.index_axis_at_pos(nanshe.util.xnumpy.index_axis_at_pos(ar, 0, each_r[0]), -1, each_r[-1])[:] = 0


        graph = Graph()

        opPrep = OpArrayPiper(graph=graph)
        opPrep.Input.setValue(ar)

        op = OpNansheRemoveZeroedLinesCached(graph=graph)
        op.Input.connect(opPrep.Output)

        op.ErosionShape.setValue([21, 1])
        op.DilationShape.setValue([1, 3])


        b = op.Output[...].wait()
        b = vigra.taggedView(b, "tyxc")

        assert((a == b).all())
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:28,代码来源:testOpNansheRemoveZeroedLines.py

示例10: testBasic

    def testBasic(self):
        features = numpy.indices( (100,100) ).astype(numpy.float32) + 0.5
        features = numpy.rollaxis(features, 0, 3)
        features = vigra.taggedView(features, 'xyc')
        labels = numpy.zeros( (100,100,1), dtype=numpy.uint8 )
        labels = vigra.taggedView(labels, 'xyc')
        
        labels[10,10] = 1
        labels[10,11] = 1
        labels[20,20] = 2
        labels[20,21] = 2
        
        graph = Graph()
        opFeatureMatrixCache = OpFeatureMatrixCache(graph=graph)
        opFeatureMatrixCache.FeatureImage.setValue(features)
        opFeatureMatrixCache.LabelImage.setValue(labels)
        opFeatureMatrixCache.NonZeroLabelBlocks.setValue(0)
        
        labels_and_features = opFeatureMatrixCache.LabelAndFeatureMatrix.value
        assert labels_and_features.shape == (0,3), "Empty feature matrix has wrong shape: {}".format( labels_and_features.shape )
        
        opFeatureMatrixCache.LabelImage.setDirty( numpy.s_[10:11, 10:12] )
        opFeatureMatrixCache.LabelImage.setDirty( numpy.s_[20:21, 20:22] )
        opFeatureMatrixCache.LabelImage.setDirty( numpy.s_[30:31, 30:32] )

        labels_and_features = opFeatureMatrixCache.LabelAndFeatureMatrix.value
        assert labels_and_features.shape == (4,3)
        assert (labels_and_features[:,0] == 1).sum() == 2
        assert (labels_and_features[:,0] == 2).sum() == 2

        # Can't check for equality because feature blocks can be in a random order.
        # Just check that all features are present, regardless of order.
        for feature_vec in [[10.5, 10.5], [10.5, 11.5], [20.5, 20.5], [20.5, 21.5]]:
            assert feature_vec in labels_and_features[:,1:]
开发者ID:ilastikdev,项目名称:lazyflow,代码行数:34,代码来源:testOpFeatureMatrixCache.py

示例11: testBasic2

    def testBasic2(self):
        a = numpy.ones((100, 101, 102))
        a = a[..., None]
        a = vigra.taggedView(a, "tyxc")

        graph = Graph()

        opPrep = OpArrayPiper(graph=graph)
        opPrep.Input.setValue(a)

        op = OpNansheExtractF0Cached(graph=graph)
        op.Input.connect(opPrep.Output)

        op.HalfWindowSize.setValue(20)
        op.WhichQuantile.setValue(0.5)
        op.TemporalSmoothingGaussianFilterStdev.setValue(5.0)
        op.SpatialSmoothingGaussianFilterStdev.setValue(5.0)
        op.Bias.setValue(100)
        op.BiasEnabled.setValue(True)

        b = op.dF_F[...].wait()
        b = vigra.taggedView(b, "tyxc")

        assert(a.shape == b.shape)

        assert((b == 0).all())
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:26,代码来源:testOpNansheExtractF0.py

示例12: testBasic2

    def testBasic2(self):
        a = numpy.zeros((2,2,2,), dtype=int)
        a[1,1,1] = 1
        a[0,0,0] = 1
        a = a[..., None]
        a = vigra.taggedView(a, "tyxc")

        expected_b = a.astype(float)
        expected_b = vigra.taggedView(expected_b, "tyxc")


        graph = Graph()
        op = OpConvertTypeCached(graph=graph)

        opPrep = OpArrayPiper(graph=graph)
        opPrep.Input.setValue(a)

        op.Input.connect(opPrep.Output)
        op.Dtype.setValue(float)

        b = op.Output[...].wait()
        b = vigra.taggedView(b, "tyxc")


        assert((b == expected_b).all())
开发者ID:JaimeIvanCervantes,项目名称:ilastik,代码行数:25,代码来源:testOpConvertType.py

示例13: test_regionradii

    def test_regionradii(self):
        # Create a volume of flat superpixels, where every slice
        # is the same (except for the actual sp ids)
        num_sp_per_slice = 200
        slice_superpixels = generate_random_voronoi((100,200), num_sp_per_slice)
        
        superpixels = np.zeros( shape=((10,) + slice_superpixels.shape), dtype=np.uint32 )
        for z in range(10):
            superpixels[z] = slice_superpixels + z*num_sp_per_slice
        superpixels = vigra.taggedView(superpixels, 'zyx')

        rag_flat = Rag( superpixels, flat_superpixels=True )
        
        values = np.random.random(size=(superpixels.shape)).astype(np.float32)
        values = vigra.taggedView(values, 'zyx')
        
        flat_features_df = rag_flat.compute_features(values, ['standard_flatedge_regionradii'], edge_group='z')

        # Now compute the radii using a normal 'dense' rag
        rag_dense = Rag( superpixels )
        dense_features_df = rag_dense.compute_features(values, ['edgeregion_edge_regionradii'])

        # Both methods should be reasonably close.
        combined_features_df = pd.merge(flat_features_df, dense_features_df, how='left', on=['sp1', 'sp2'])
        assert np.isclose(combined_features_df['standard_flatedge_regionradii_0'], combined_features_df['edgeregion_edge_regionradii_0'], atol=0.001).all()
        assert np.isclose(combined_features_df['standard_flatedge_regionradii_1'], combined_features_df['edgeregion_edge_regionradii_1'], atol=0.001).all()
开发者ID:stuarteberg,项目名称:ilastikrag,代码行数:26,代码来源:test_standard_flatedge_accumulator.py

示例14: execute

    def execute(self, slot, subindex, roi, result):
        assert len(roi.start) == len(roi.stop) == len(self.Output.meta.shape)
        assert slot == self.Output

        t_ind = self.RawVolume.axistags.index('t')
        assert t_ind < len(self.RawVolume.meta.shape)

        # loop over requested time slices
        for res_t_ind, t in enumerate(xrange(roi.start[t_ind],
                                             roi.stop[t_ind])):
            
            # Process entire spatial volume
            s = [slice(None) for i in range(len(self.RawVolume.meta.shape))]
            s[t_ind] = slice(t, t+1)
            s = tuple(s)
            rawVolume = self.RawVolume[s].wait()
            rawVolume = vigra.taggedView(
                rawVolume, axistags=self.RawVolume.meta.axistags)
            labelVolume = self.LabelVolume[s].wait()
            labelVolume = vigra.taggedView(
                labelVolume, axistags=self.LabelVolume.meta.axistags)
    
            # Convert to 4D (preserve axis order)
            axes4d = self.RawVolume.meta.getTaggedShape().keys()
            axes4d = filter(lambda k: k in 'xyzc', axes4d)
            rawVolume = rawVolume.withAxes(*axes4d)
            labelVolume = labelVolume.withAxes(*axes4d)
            acc = self._extract(rawVolume4d, labelVolume4d)
            result[res_t_ind] = acc
        
        return result
开发者ID:burgerdev,项目名称:turbo-dangerzone,代码行数:31,代码来源:opRegFeat5d.py

示例15: testBasic

    def testBasic(self):
        features = numpy.indices((100, 100)).astype(numpy.float32) + 0.5
        features = numpy.rollaxis(features, 0, 3)
        features = vigra.taggedView(features, "xyc")
        labels = numpy.zeros((100, 100, 1), dtype=numpy.uint8)
        labels = vigra.taggedView(labels, "xyc")

        labels[10, 10] = 1
        labels[10, 11] = 1
        labels[20, 20] = 2
        labels[20, 21] = 2

        graph = Graph()
        opFeatureMatrixCache = OpFeatureMatrixCache(graph=graph)
        opFeatureMatrixCache.FeatureImage.setValue(features)
        opFeatureMatrixCache.LabelImage.setValue(labels)

        opFeatureMatrixCache.LabelImage.setDirty(numpy.s_[10:11, 10:12])
        opFeatureMatrixCache.LabelImage.setDirty(numpy.s_[20:21, 20:22])
        opFeatureMatrixCache.LabelImage.setDirty(numpy.s_[30:31, 30:32])

        opTrain = OpTrainClassifierFromFeatureVectors(graph=graph)
        opTrain.ClassifierFactory.setValue(ParallelVigraRfLazyflowClassifierFactory(100))
        opTrain.MaxLabel.setValue(2)
        opTrain.LabelAndFeatureMatrix.connect(opFeatureMatrixCache.LabelAndFeatureMatrix)

        assert opTrain.Classifier.ready()

        trained_classifier = opTrain.Classifier.value

        # This isn't much of a test at the moment...
        assert isinstance(
            trained_classifier, ParallelVigraRfLazyflowClassifier
        ), "classifier is of the wrong type: {}".format(type(trained_classifier))
开发者ID:CVML,项目名称:lazyflow,代码行数:34,代码来源:testOpTrainClassifierFromFeatureVectors.py


注:本文中的vigra.taggedView函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。