Exemplo n.º 1
0
 def updateim(self):
     # Updates the display (perform a rendering)
     depth = self.im_ref().getDepth()
     volume = 0
     if depth == 1:
         # binary 3D image
         self.planeLabel.config(text="")
         im8 = mamba.imageMb(self.W, self.H, 8)
         self.raw = b""
         for im2D in self.im_ref():
             mamba.convert(im2D, im8)
             self.raw += im8.extractRaw()
             volume += mamba.computeVolume(im2D)
     elif depth == 32:
         # 32-bit 3D image
         if self.master.bplane == 4:
             self.planeLabel.config(text="Plane : all")
             im3D_8 = m3D.image3DMb(self.im_ref(), 8)
             m3D.convert3D(self.im_ref(), im3D_8)
             self.raw = im3D_8.extractRaw()
             volume = m3D.computeVolume3D(self.im_ref())
         else:
             self.planeLabel.config(text="Plane : %d" %
                                    (self.master.bplane))
             im8 = mamba.imageMb(self.W, self.H, 8)
             self.raw = b""
             for im2D in self.im_ref():
                 mamba.copyBytePlane(im2D, self.master.bplane, im8)
                 self.raw += im8.extractRaw()
                 volume += mamba.computeVolume(im2D)
     else:
         # Greyscale image
         self.planeLabel.config(text="")
         self.raw = self.im_ref().extractRaw()
         volume = m3D.computeVolume3D(self.im_ref())
     self.setImagePlaneZ()
     self.setImagePlaneY()
     self.setImagePlaneX()
     self.planex.eraseTarget()
     self.planey.eraseTarget()
     self.planez.eraseTarget()
     self.volLabel.config(text="Volume : %d" % (volume))
     value = self.im_ref().getPixel((self.x, self.y, self.z))
     self.posLabel.config(text="At (%d,%d,%d) = %d" %
                          (self.x, self.y, self.z, value))
Exemplo n.º 2
0
def _dualBuild3D_1(imMask, imInout, grid):
    # Build function for binary 3D images
    if imMask.getDepth()!=1:
        mamba.raiseExceptionOnError(core.MB_ERR_BAD_DEPTH)
    imMask_8 = m3D.image3DMb(imMask, 8)
    imInout_8= m3D.image3DMb(imInout, 8)
    m3D.convert3D(imMask, imMask_8)
    m3D.convert3D(imInout, imInout_8)
    err = core.MB3D_HierarDualBld(imMask_8.mb3DIm, imInout_8.mb3DIm, grid.getCValue())
    mamba.raiseExceptionOnError(err)
    m3D.convert3D(imMask_8, imMask)
    m3D.convert3D(imInout_8, imInout)
Exemplo n.º 3
0
 def updateim(self):
     # Updates the display (perform a rendering)
     depth = self.im_ref().getDepth()
     volume = 0
     if depth==1:
         # binary 3D image
         self.planeLabel.config(text="")
         im8 = mamba.imageMb(self.W, self.H, 8)
         self.raw = b""
         for im2D in self.im_ref():
             mamba.convert(im2D, im8)
             self.raw += im8.extractRaw()
             volume += mamba.computeVolume(im2D)
     elif depth==32:
         # 32-bit 3D image
         if self.master.bplane==4:
             self.planeLabel.config(text="Plane : all")
             im3D_8 = m3D.image3DMb(self.im_ref(), 8)
             m3D.convert3D(self.im_ref(), im3D_8)
             self.raw = im3D_8.extractRaw()
             volume = m3D.computeVolume3D(self.im_ref())
         else:
             self.planeLabel.config(text="Plane : %d" % (self.master.bplane))
             im8 = mamba.imageMb(self.W, self.H, 8)
             self.raw = b""
             for im2D in self.im_ref():
                 mamba.copyBytePlane(im2D, self.master.bplane, im8)
                 self.raw += im8.extractRaw()
                 volume += mamba.computeVolume(im2D)
     else:
         # Greyscale image
         self.planeLabel.config(text="")
         self.raw = self.im_ref().extractRaw()
         volume = m3D.computeVolume3D(self.im_ref())
     self.setImagePlaneZ()
     self.setImagePlaneY()
     self.setImagePlaneX()
     self.planex.eraseTarget()
     self.planey.eraseTarget()
     self.planez.eraseTarget()
     self.volLabel.config(text="Volume : %d" % (volume))
     value = self.im_ref().getPixel((self.x, self.y, self.z))
     self.posLabel.config(text="At (%d,%d,%d) = %d" % (self.x,self.y,self.z,value))
Exemplo n.º 4
0
def _dualBuild3D_1(imMask, imInout, grid):
    # Build function for binary 3D images
    if imMask.getDepth() != 1:
        mamba.raiseExceptionOnError(core.MB_ERR_BAD_DEPTH)
    imMask_8 = m3D.image3DMb(imMask, 8)
    imInout_8 = m3D.image3DMb(imInout, 8)
    m3D.convert3D(imMask, imMask_8)
    m3D.convert3D(imInout, imInout_8)
    err = core.MB3D_HierarDualBld(imMask_8.mb3DIm, imInout_8.mb3DIm,
                                  grid.getCValue())
    mamba.raiseExceptionOnError(err)
    m3D.convert3D(imMask_8, imMask)
    m3D.convert3D(imInout_8, imInout)
 def _convertIntoVTKImage(self):
     # Converts the associated sequence into a VTK image
     # structure to be able to display it using the rendering
     # mechanisms of VTK
     W, H, L = self.im_ref().getSize()
     depth = self.im_ref().getDepth()
 
     if depth==8:
         # 8-bit 3D image
         self.planeLabel.config(text="")
         raw_data = self.im_ref().extractRaw()
     elif depth==32:
         # 32-bit 3D image
         im3D_8 = m3D.image3DMb(self.im_ref(), 8)
         if self.master.bplane==4:
             self.planeLabel.config(text="Plane : all")
             m3D.convert3D(self.im_ref(), im3D_8)
         else:
             self.planeLabel.config(text="Plane : %d" % (self.master.bplane))
             m3D.copyBytePlane3D(self.im_ref(), self.master.bplane, im3D_8)
         raw_data = im3D_8.extractRaw()
     else:
         # binary 3D image
         self.planeLabel.config(text="")
         im8 = mamba.imageMb(W, H, 8)
         raw_data = b""
         for im2D in self.im_ref():
             mamba.convert(im2D, im8)
             raw_data += im8.extractRaw()
     volume = m3D.computeVolume3D(self.im_ref())
     self.vtk_im.CopyImportVoidPointer(raw_data, len(raw_data))
         
     self.vtk_im.SetNumberOfScalarComponents(1)
     extent = self.vtk_im.GetDataExtent()
     self.vtk_im.SetDataExtent(extent[0], extent[0] + W - 1,
                               extent[2], extent[2] + H - 1,
                               extent[4], extent[4] + L - 1)
     self.vtk_im.SetWholeExtent(extent[0], extent[0] + W - 1,
                                extent[2], extent[2] + H - 1,
                                extent[4], extent[4] + L - 1)
     self.volLabel.config(text="Volume = %d" % (volume))