Beispiel #1
0
    def segmentation(self, points, useSnake = True): 
        
        ## make ellipse
        if len(points)==0:
            print "the input points size is ZERO!"
            return None
        
        Initial_ellipsePoints = ImageProcessing.FindEllipse(points)
        
        self._convex_xy = Initial_ellipsePoints # back up the data

        outPoints = []
        
        if self._state == False:
            for i in range(self._volume_data.shape[2]): # iterating through the vertical stacks
                print "uncropped: " + str(i)
                slice_snake = np.empty([Initial_ellipsePoints.shape[0],3]) # Make N by 3 points
                
                if useSnake == True:
                    snake = ImageProcessing.ActiveEllipse(self._volume_data[:,:,i], Initial_ellipsePoints)
                else:
                    snake = Initial_ellipsePoints
                    
                slice_snake[:,0] = snake[:,0] # create 3d points
                slice_snake[:,1] = snake[:,1]
                slice_snake[:,2] = i
                outPoints.append(slice_snake)
                
        elif self._state == True:
            for i in range(self._start, self._end+1): # iterating through the vertical stacks
                print "cropped: " + str(i)
                slice_snake = np.empty([Initial_ellipsePoints.shape[0],3]) # Make N by 3 points 
                
                if useSnake == True:
                    snake = ImageProcessing.ActiveEllipse(self._volume_data[:,:,i], Initial_ellipsePoints)
                else:
                    snake = Initial_ellipsePoints
                    
                slice_snake[:,0] = snake[:,0] # create 3d points
                slice_snake[:,1] = snake[:,1]
                slice_snake[:,2] = i
                outPoints.append(slice_snake)
                
        for i in range(len(outPoints)): # reshape the list
            if i == 0: fb = outPoints[i]  
            else: fb = np.concatenate((fb,outPoints[i]),axis=0)
            
        self._periPoint = fb