コード例 #1
0
ファイル: tiling_tests.py プロジェクト: skarale25/volumina
    def setUp( self ):
        self.GRAY1 = 60
        self.ds1 = ConstantSource( self.GRAY1 )

        self.GRAY2 = 120
        self.ds2 = ConstantSource( self.GRAY2 )

        self.GRAY3 = 190
        self.ds3 = ConstantSource( self.GRAY3 )

        self.layer1 = GrayscaleLayer( self.ds1, normalize = False )
        self.layer1.visible = False
        self.layer1.opacity = 0.1
        self.ims1 = GrayscaleImageSource( self.ds1, self.layer1 )
        self.layer2 = GrayscaleLayer( self.ds2, normalize = False )
        self.layer2.visible = True
        self.layer2.opacity = 0.3
        self.ims2 = GrayscaleImageSource( self.ds2, self.layer2 )
        self.layer3 = GrayscaleLayer( self.ds3, normalize = False )
        self.layer3.visible = True
        self.layer3.opacity = 1.0
        self.ims3 = GrayscaleImageSource( self.ds3, self.layer3 )

        lsm = LayerStackModel()
        lsm.append(self.layer1)
        lsm.append(self.layer2)
        lsm.append(self.layer3)
        self.lsm = lsm
        sims = StackedImageSources( lsm )
        sims.register( self.layer1, self.ims1 )
        sims.register( self.layer2, self.ims2 )
        sims.register( self.layer3, self.ims3 )
        self.sims = sims
コード例 #2
0
    def createImageSource(self, data_sources):
        if len(data_sources) != 4:
            raise ValueError("Expected 4 data sources got %s" %
                             len(data_sources))

        ds = data_sources.copy()
        for i in range(3):
            if data_sources[i] == None:
                ds[i] = PlanarSliceSource(
                    ConstantSource(self.color_missing_value))
        guarantees_opaqueness = False
        if data_sources[3] == None:
            ds[3] = PlanarSliceSource(ConstantSource(self.alpha_missing_value))
            guarantees_opaqueness = True if self.alpha_missing_value == 255 else False
        src = imsrc.RGBAImageSource(
            ds[0],
            ds[1],
            ds[2],
            ds[3],
            self,
            guarantees_opaqueness=guarantees_opaqueness)
        src.setObjectName(self.name)
        self.nameChanged.connect(lambda x: src.setObjectName(str(x)))
        self.normalizeChanged.connect(lambda: src.setDirty(
            (slice(None, None), slice(None, None))))
        return src
コード例 #3
0
    def setUp( self ):
        super( RGBAImageSourceTest, self ).setUp()
        basedir = os.path.dirname(volumina._testing.__file__)
        self.data = numpy.load(os.path.join(basedir, 'rgba129x104.npy'))
        self.red = _ArraySource2d(self.data[:,:,0])
        self.green = _ArraySource2d(self.data[:,:,1])
        self.blue = _ArraySource2d(self.data[:,:,2])
        self.alpha = _ArraySource2d(self.data[:,:,3])

        self.ims_rgba = RGBAImageSource( self.red, self.green, self.blue, self.alpha, RGBALayer( self.red, self.green, self.blue, self.alpha) )
        self.ims_rgb = RGBAImageSource( self.red, self.green, self.blue, ConstantSource(), RGBALayer(self.red, self.green, self.blue) )
        self.ims_rg = RGBAImageSource( self.red, self.green, ConstantSource(), ConstantSource(), RGBALayer(self.red, self.green ) )
        self.ims_ba = RGBAImageSource( red = ConstantSource(), green = ConstantSource(), blue = self.blue, alpha = self.alpha, layer = RGBALayer( blue = self.blue, alpha = self.alpha ) )
        self.ims_a = RGBAImageSource( red = ConstantSource(), green = ConstantSource(), blue = ConstantSource(), alpha = self.alpha, layer = RGBALayer( alpha = self.alpha ) )
        self.ims_none = RGBAImageSource( ConstantSource(),ConstantSource(),ConstantSource(),ConstantSource(), RGBALayer())
コード例 #4
0
 def testOpaqueness(self):
     ims_opaque = RGBAImageSource(self.red,
                                  self.green,
                                  self.blue,
                                  ConstantSource(),
                                  RGBALayer(self.red,
                                            self.green,
                                            self.blue,
                                            alpha_missing_value=255),
                                  guarantees_opaqueness=True)
     self.assertTrue(ims_opaque.isOpaque())
     ims_notopaque = RGBAImageSource(
         self.red, self.green, self.blue, ConstantSource(),
         RGBALayer(self.red, self.green, self.blue,
                   alpha_missing_value=100))
     self.assertFalse(ims_notopaque.isOpaque())
コード例 #5
0
    def setUp(self):
        self.ds = ConstantSource()

        self.layer1 = GrayscaleLayer(self.ds)
        self.layer1.visible = False
        self.layer1.opacity = 0.1

        self.layer2 = GrayscaleLayer(self.ds)
        self.layer2.visible = True
        self.layer2.opacity = 0.3

        self.layer3 = GrayscaleLayer(self.ds)
        self.layer3.visible = True
        self.layer3.opacity = 1.0
コード例 #6
0
ファイル: tiling_tests.py プロジェクト: skarale25/volumina
    def setUp( self ):
        dataShape = (1, 900, 400, 10, 1) # t,x,y,z,c
        data = np.indices(dataShape)[3].astype(np.uint8) # Data is labeled according to z-index
        self.ds1 = ArraySource( data )
        self.CONSTANT = 13
        self.ds2 = ConstantSource( self.CONSTANT )

        self.layer1 = GrayscaleLayer( self.ds1, normalize=False )
        self.layer1.visible = True
        self.layer1.opacity = 1.0

        self.layer2 = GrayscaleLayer( self.ds2, normalize=False )

        self.lsm = LayerStackModel()
        self.pump = ImagePump( self.lsm, SliceProjection(), sync_along=(0,1,2) )
コード例 #7
0
    def setUp(self):
        self.layerstack = LayerStackModel()
        self.sims = StackedImageSources(self.layerstack)

        self.GRAY = 201
        self.ds = ConstantSource(self.GRAY)
        self.layer = GrayscaleLayer(self.ds)
        self.layerstack.append(self.layer)
        self.ims = imsfac.createImageSource(self.layer, [self.ds])
        self.sims.register(self.layer, self.ims)

        self.scene = ImageScene2D(PositionModel(), (0, 3, 4),
                                  preemptive_fetch_number=0)

        self.scene.stackedImageSources = self.sims
        self.scene.dataShape = (310, 290)
コード例 #8
0
    def setUp(self):
        self.ds = ConstantSource()

        self.layer1 = GrayscaleLayer(self.ds)
        self.layer1.visible = False
        self.layer1.opacity = 0.1
        self.ims1 = GrayscaleImageSource(PlanarSliceSource(self.ds),
                                         self.layer1)
        self.layer2 = GrayscaleLayer(self.ds)
        self.layer2.visible = True
        self.layer2.opacity = 0.3
        self.ims2 = GrayscaleImageSource(PlanarSliceSource(self.ds),
                                         self.layer2)
        self.layer3 = GrayscaleLayer(self.ds)
        self.layer3.visible = True
        self.layer3.opacity = 1.0
        self.ims3 = GrayscaleImageSource(PlanarSliceSource(self.ds),
                                         self.layer3)
コード例 #9
0
 def addRandomLayer():
     o = Layer([ConstantSource()])
     o.name = "Layer %d" % (model.rowCount() + 1)
     o.opacity = numpy.random.rand()
     o.visible = bool(numpy.random.randint(0, 2))
     model.append(o)
コード例 #10
0
if __name__ == "__main__":
    # make the program quit on Ctrl+C
    import signal

    signal.signal(signal.SIGINT, signal.SIG_DFL)

    import sys, numpy

    from PyQt5.QtWidgets import QPushButton, QHBoxLayout, QVBoxLayout
    from volumina.pixelpipeline.datasources import ArraySource, ConstantSource

    app = QApplication(sys.argv)

    model = LayerStackModel()

    o1 = Layer([ConstantSource()])
    o1.name = "Fancy Layer"
    o1.opacity = 0.5
    model.append(o1)

    o2 = Layer([ConstantSource()])
    o2.name = "Some other Layer"
    o2.opacity = 0.25
    o2.numberOfChannels = 3
    model.append(o2)

    o3 = Layer([ConstantSource()])
    o3.name = "Invisible Layer"
    o3.opacity = 0.15
    o3.visible = False
    model.append(o3)