def test_change_spacing(aorta_surface, compare_images):
    name = __name__ + '_test_change_spacing.vti'
    surfToImage = surfacetobinaryimage.vmtkSurfaceToBinaryImage()
    surfToImage.Surface = aorta_surface
    surfToImage.PolyDataToImageDataSpacing = [0.4, 0.4, 0.4]
    surfToImage.Execute()

    assert compare_images(surfToImage.Image, name) == True
def test_change_spacing(aorta_surface, compare_images):
    name = __name__ + '_test_change_spacing.vti'
    surfToImage = surfacetobinaryimage.vmtkSurfaceToBinaryImage()
    surfToImage.Surface = aorta_surface
    surfToImage.PolyDataToImageDataSpacing = [0.4, 0.4, 0.4]
    surfToImage.Execute()
    
    assert compare_images(surfToImage.Image, name) == True
def test_set_inside_outside_values(aorta_surface, compare_images, insidevalue,
                                   outsidevalue, paramid):
    name = __name__ + '_test_set_inside_outside_values_' + paramid + '.vti'
    surfToImage = surfacetobinaryimage.vmtkSurfaceToBinaryImage()
    surfToImage.Surface = aorta_surface
    surfToImage.InsideValue = insidevalue
    surfToImage.OutsideValue = outsidevalue
    surfToImage.Execute()

    assert compare_images(surfToImage.Image, name) == True
def test_set_inside_outside_values(aorta_surface, compare_images,
                                   insidevalue, outsidevalue, paramid):
    name = __name__ + '_test_set_inside_outside_values_' + paramid + '.vti'
    surfToImage = surfacetobinaryimage.vmtkSurfaceToBinaryImage()
    surfToImage.Surface = aorta_surface
    surfToImage.InsideValue = insidevalue
    surfToImage.OutsideValue = outsidevalue
    surfToImage.Execute()
    
    assert compare_images(surfToImage.Image, name) == True
示例#5
0
    def Execute(self):
        if self.Surface == None:
            self.PrintError('Error: No Input Surface.')

        # Step 0: Check if the surface has any unfilled holes in it. if it does, cap them.
        fedges = vtk.vtkFeatureEdges()
        fedges.BoundaryEdgesOn()
        fedges.FeatureEdgesOff()
        fedges.ManifoldEdgesOff()
        fedges.SetInputData(self.Surface)
        fedges.Update()

        ofedges = fedges.GetOutput()
        # if the following is not == 0, then the surface contains unfilled holes.
        numEdges = ofedges.GetNumberOfPoints()
        if numEdges >= 1:
            self.PrintLog('Capping unclosed holes in surface.')
            tempcapper = vmtksurfacecapper.vmtkSurfaceCapper()
            tempcapper.Surface = self.Surface
            tempcapper.LogOn = 0
            tempcapper.Interactive = 0
            tempcapper.Execute()
            self.Surface = tempcapper.Surface

        # Step 1: Convert the input surface into an image mask of unsigned char type and spacing = PolyDataToImageDataSpacing
        #         Where voxels lying inside the surface are set to 255 and voxels outside the image are set to value 0.

        # since we are creating a new image container from nothing, calculate the origin, extent, and dimensions for the
        # vtkImageDataObject from the surface parameters.

        self.PrintLog('Converting Surface to Image Mask')
        binaryImageFilter = vmtksurfacetobinaryimage.vmtkSurfaceToBinaryImage()
        binaryImageFilter.Surface = self.Surface
        binaryImageFilter.InsideValue = 255
        binaryImageFilter.LogOn = 0
        binaryImageFilter.OutsideValue = 0
        binaryImageFilter.PolyDataToImageDataSpacing = self.PolyDataToImageDataSpacing
        binaryImageFilter.Execute()

        # Step 2: Feed into the vtkvmtkMedialCurveFilter
        #         This takes the binary image and computes the average outward flux of the image. This is then
        #         used to compute the skeleton image. It returns a binary image where values of 1 are skeleton points
        #         and values of 0 are outside the skeleton. The execution speed of this algorithm is fairly sensetive to
        #         the extent of the input image.
        self.PrintLog('Extracting Centerline Skeleton from Image Mask...')
        medialCurveFilter = vtkvmtk.vtkvmtkMedialCurveFilter()
        medialCurveFilter.SetInputData(binaryImageFilter.Image)
        medialCurveFilter.SetThreshold(self.Threshold)
        medialCurveFilter.SetSigma(self.Sigma)
        medialCurveFilter.Update()

        self.Image = medialCurveFilter.GetOutput()
示例#6
0
    def Execute(self):
        if self.Surface == None:
            self.PrintError('Error: No Input Surface.')

        # Step 0: Check if the surface has any unfilled holes in it. if it does, cap them. 
        fedges = vtk.vtkFeatureEdges()
        fedges.BoundaryEdgesOn()
        fedges.FeatureEdgesOff()
        fedges.ManifoldEdgesOff()
        fedges.SetInputData(self.Surface)
        fedges.Update()

        ofedges = fedges.GetOutput()
        # if the following is not == 0, then the surface contains unfilled holes. 
        numEdges = ofedges.GetNumberOfPoints()
        if numEdges >= 1:
            self.PrintLog('Capping unclosed holes in surface.')
            tempcapper = vmtksurfacecapper.vmtkSurfaceCapper()
            tempcapper.Surface = self.Surface
            tempcapper.LogOn = 0
            tempcapper.Interactive = 0
            tempcapper.Execute()
            self.Surface = tempcapper.Surface

        # Step 1: Convert the input surface into an image mask of unsigned char type and spacing = PolyDataToImageDataSpacing
        #         Where voxels lying inside the surface are set to 255 and voxels outside the image are set to value 0. 

        # since we are creating a new image container from nothing, calculate the origin, extent, and dimensions for the
        # vtkImageDataObject from the surface parameters.

        self.PrintLog('Converting Surface to Image Mask')
        binaryImageFilter = vmtksurfacetobinaryimage.vmtkSurfaceToBinaryImage()
        binaryImageFilter.Surface = self.Surface
        binaryImageFilter.InsideValue = 255
        binaryImageFilter.LogOn = 0
        binaryImageFilter.OutsideValue = 0
        binaryImageFilter.PolyDataToImageDataSpacing = self.PolyDataToImageDataSpacing
        binaryImageFilter.Execute()

        # Step 2: Feed into the vtkvmtkMedialCurveFilter
        #         This takes the binary image and computes the average outward flux of the image. This is then
        #         used to compute the skeleton image. It returns a binary image where values of 1 are skeleton points
        #         and values of 0 are outside the skeleton. The execution speed of this algorithm is fairly sensetive to
        #         the extent of the input image.
        self.PrintLog('Extracting Centerline Skeleton from Image Mask...')
        medialCurveFilter = vtkvmtk.vtkvmtkMedialCurveFilter()
        medialCurveFilter.SetInputData(binaryImageFilter.Image)
        medialCurveFilter.SetThreshold(self.Threshold)
        medialCurveFilter.SetSigma(self.Sigma)
        medialCurveFilter.Update()

        self.Image = medialCurveFilter.GetOutput()