Ejemplo n.º 1
0
def mosaic3D(imIn, imOut, imWts, grid=m3D.DEFAULT_GRID3D):
    """
    Builds the mosaic 3D image of 'imIn' and puts the results into 'imOut'.
    The watershed line (pixel values set to 255) is stored in the 
    greytone 3D image 'imWts'. A mosaic image is a simple image made of various 
    tiles of uniform grey values. It is built using the watershed of 'imIn' 
    gradient and original markers made of gradient minima which are labelled by
    the maximum value of 'imIn' pixels inside them.
    """

    imWrk1 = m3D.image3DMb(imIn, 1)
    imWrk2 = m3D.image3DMb(imIn)
    m3D.copy3D(imIn, imWrk2)
    im_mark = m3D.image3DMb(imIn, 32)
    se = m3D.structuringElement3D(m3D.getDirections3D(grid), grid)
    m3D.gradient3D(imIn, imOut, se=se)
    m3D.minima3D(imOut, imWrk1, grid=grid)
    m3D.add3D(im_mark, imWrk1, im_mark)
    imWrk1.convert(8)
    m3D.build3D(imWrk1, imWrk2, grid=grid)
    m3D.add3D(im_mark, imWrk2, im_mark)
    m3D.watershedSegment3D(imOut, im_mark, grid=grid)
    m3D.copyBytePlane3D(im_mark, 3, imWts)
    m3D.subConst3D(im_mark, 1, im_mark)
    m3D.copyBytePlane3D(im_mark, 0, imOut)
Ejemplo n.º 2
0
def mosaic3D(imIn, imOut, imWts, grid=m3D.DEFAULT_GRID3D):
    """
    Builds the mosaic 3D image of 'imIn' and puts the results into 'imOut'.
    The watershed line (pixel values set to 255) is stored in the 
    greytone 3D image 'imWts'. A mosaic image is a simple image made of various 
    tiles of uniform grey values. It is built using the watershed of 'imIn' 
    gradient and original markers made of gradient minima which are labelled by
    the maximum value of 'imIn' pixels inside them.
    """
   
    imWrk1 = m3D.image3DMb(imIn, 1)
    imWrk2 = m3D.image3DMb(imIn)
    m3D.copy3D(imIn, imWrk2)
    im_mark = m3D.image3DMb(imIn, 32)
    se = m3D.structuringElement3D(m3D.getDirections3D(grid), grid)
    m3D.gradient3D(imIn, imOut, se=se)
    m3D.minima3D(imOut, imWrk1, grid=grid) 
    m3D.add3D(im_mark, imWrk1, im_mark) 
    imWrk1.convert(8)
    m3D.build3D(imWrk1, imWrk2, grid=grid)
    m3D.add3D(im_mark, imWrk2, im_mark)   
    m3D.watershedSegment3D(imOut, im_mark, grid=grid)
    m3D.copyBytePlane3D(im_mark, 3, imWts)
    m3D.subConst3D(im_mark, 1, im_mark)
    m3D.copyBytePlane3D(im_mark, 0, imOut)
Ejemplo n.º 3
0
def markerControlledWatershed3D(imIn, imMarkers, imOut, grid=m3D.DEFAULT_GRID3D):
    """
    Marker-controlled watershed transform of greyscale or 32-bit 3D image 'imIn'.
    The binary 3D image 'imMarkers' contains the markers which control the
    flooding process. 'imOut' contains the valued watershed.
    """
    
    im_mark = m3D.image3DMb(imIn, 32)
    imWrk = m3D.image3DMb(imIn)
    label3D(imMarkers, im_mark, grid=grid)
    watershedSegment3D(imIn, im_mark, grid=grid)
    m3D.copyBytePlane3D(im_mark, 3, imWrk)
    m3D.logic3D(imWrk, imIn, imOut, 'inf')
Ejemplo n.º 4
0
    def mamba_ws(self, NEED_WL, res_type):
        imDist = image3DMb(*self.dist.shape, 32)
        fillImageWithArray_3D(self.dist, imDist)
        imMarkers = image3DMb(*self.markers.shape, 32)
        fillImageWithArray_3D(self.markers.astype(np.uint32), imMarkers)

        if NEED_WL:
            labels, res = decorator(watershedSegment3D, res_type)(imDist, imMarkers, grid=CUBIC)
        else:
            labels, res = decorator(basinSegment3D,res_type)(imDist, imMarkers, grid=CUBIC)

        tmp = image3DMb(*self.markers.shape, 8)
        copyBytePlane3D(tmp, 3, imMarkers)
        self.labels = getArrayFromImage_3D(imMarkers, self.size)
        return res
Ejemplo n.º 5
0
def markerControlledWatershed3D(imIn,
                                imMarkers,
                                imOut,
                                grid=m3D.DEFAULT_GRID3D):
    """
    Marker-controlled watershed transform of greyscale or 32-bit 3D image 'imIn'.
    The binary 3D image 'imMarkers' contains the markers which control the
    flooding process. 'imOut' contains the valued watershed.
    """

    im_mark = m3D.image3DMb(imIn, 32)
    imWrk = m3D.image3DMb(imIn)
    label3D(imMarkers, im_mark, grid=grid)
    watershedSegment3D(imIn, im_mark, grid=grid)
    m3D.copyBytePlane3D(im_mark, 3, imWrk)
    m3D.logic3D(imWrk, imIn, imOut, 'inf')
Ejemplo n.º 6
0
 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))