当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkImageClip函数代码示例

本文整理汇总了Python中vtk.vtkImageClip函数的典型用法代码示例。如果您正苦于以下问题:Python vtkImageClip函数的具体用法?Python vtkImageClip怎么用?Python vtkImageClip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了vtkImageClip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkImageClip(), 'Processing.',
         ('vtkImageData',), ('vtkImageData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkImageClip.py

示例2: captureImageFromView

  def captureImageFromView(self, view, filename):
    view.forceRender()
    # qt.QPixmap().grabWidget(...) would not grab the background
    rw = view.renderWindow()
    wti = vtk.vtkWindowToImageFilter()
    wti.SetInput(rw)
    wti.Update()
    writer = vtk.vtkPNGWriter()
    writer.SetFileName(filename)
    outputImage = wti.GetOutput()
    imageSize = outputImage.GetDimensions()

    if imageSize[0]<2 or imageSize[1]<2:
      # image is too small, most likely it is invalid
      raise ValueError('Capture image from view failed')

    # Make sure image witdth and height is even, otherwise encoding may fail
    imageWidthOdd = (imageSize[0] & 1 == 1)
    imageHeightOdd = (imageSize[1] & 1 == 1)
    if imageWidthOdd or imageHeightOdd:
      imageClipper = vtk.vtkImageClip()
      imageClipper.SetInputConnection(wti.GetOutputPort())
      extent = outputImage.GetExtent()
      imageClipper.SetOutputWholeExtent(extent[0], extent[1]-1 if imageWidthOdd else extent[1],
                                        extent[2], extent[3]-1 if imageHeightOdd else extent[3],
                                        extent[4], extent[5])
      writer.SetInputConnection(imageClipper.GetOutputPort())
    else:
      writer.SetInputConnection(wti.GetOutputPort())

    writer.Write()
开发者ID:MayeulChassagnard,项目名称:Slicer,代码行数:31,代码来源:ScreenCapture.py

示例3: BuildEditedImage

def BuildEditedImage(imagedata, points):
    """
    Editing the original image in accordance with the edit
    points in the editor, it is necessary to generate the
    vtkPolyData via vtkContourFilter
    """
    init_values = None
    for point in points:
        x, y, z = point
        colour = points[point]
        imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour)
        imagedata.Update()

        if not(init_values):
                xi = x
                xf = x
                yi = y
                yf = y
                zi = z
                zf = z
                init_values = 1

        if (xi > x):
            xi = x
        elif(xf < x):
            xf = x

        if (yi > y):
            yi = y
        elif(yf < y):
            yf = y

        if (zi > z):
            zi = z
        elif(zf < z):
            zf = z

    clip = vtk.vtkImageClip()
    clip.SetInput(imagedata)
    clip.SetOutputWholeExtent(xi, xf, yi, yf, zi, zf)
    clip.Update()

    gauss = vtk.vtkImageGaussianSmooth()
    gauss.SetInput(clip.GetOutput())
    gauss.SetRadiusFactor(0.6)
    gauss.Update()

    app = vtk.vtkImageAppend()
    app.PreserveExtentsOn()
    app.SetAppendAxis(2)
    app.SetInput(0, imagedata)
    app.SetInput(1, gauss.GetOutput())
    app.Update()

    return app.GetOutput()
开发者ID:paulojamorim,项目名称:invesalius3,代码行数:55,代码来源:imagedata_utils.py

示例4: RollMap

    def RollMap( self, baseImage ):
#        baseImage.Update()
        if self.world_cut  == self.map_cut: return baseImage
        baseExtent = baseImage.GetExtent()
        baseSpacing = baseImage.GetSpacing()
        x0 = baseExtent[0]
        x1 = baseExtent[1]
        newCut = self.NormalizeMapLon( self.world_cut )
        delCut = newCut - self.map_cut
#        print "  %%%%%% Roll Map %%%%%%: world_cut=%.1f, map_cut=%.1f, newCut=%.1f " % ( float(self.world_cut), float(self.map_cut), float(newCut) )
        imageLen = x1 - x0 + 1
        sliceSize =  imageLen * ( delCut / 360.0 )
        sliceCoord = int( round( x0 + sliceSize) )        
        extent = list( baseExtent ) 
        
        extent[0:2] = [ x0, x0 + sliceCoord - 1 ]
        clip0 = vtk.vtkImageClip()
        if vtk.VTK_MAJOR_VERSION <= 5:  clip0.SetInput( baseImage )
        else:                           clip0.SetInputData( baseImage )                
        clip0.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
        
        extent[0:2] = [ x0 + sliceCoord, x1 ]
        clip1 = vtk.vtkImageClip()
        if vtk.VTK_MAJOR_VERSION <= 5:  clip1.SetInput( baseImage )
        else:                           clip1.SetInputData( baseImage )                
        clip1.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
        
        append = vtk.vtkImageAppend()
        append.SetAppendAxis( 0 )
        append.SetInputConnection ( clip1.GetOutputPort() )
        append.AddInputConnection ( clip0.GetOutputPort() )           
        
        imageInfo = vtk.vtkImageChangeInformation()
        imageInfo.SetInputConnection( append.GetOutputPort() ) 
        imageInfo.SetOutputOrigin( 0.0, 0.0, 0.0 )
        imageInfo.SetOutputExtentStart( 0, 0, 0 )
        imageInfo.SetOutputSpacing( baseSpacing[0], baseSpacing[1], baseSpacing[2] )
        
        imageInfo.Update()
        result = imageInfo.GetOutput() 
        return result
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:41,代码来源:StructuredGridPlot.py

示例5: RollMap

 def RollMap( self, baseImage ):
     baseImage.Update()
     if self.world_cut  == self.map_cut: return baseImage
     baseExtent = baseImage.GetExtent()
     baseSpacing = baseImage.GetSpacing()
     x0 = baseExtent[0]
     x1 = baseExtent[1]
     newCut = NormalizeLon( self.world_cut )
     delCut = NormalizeLon( self.map_cut - newCut )
     imageLen = x1 - x0 + 1
     sliceSize =  imageLen * ( delCut / 360.0 )
     sliceCoord = int( round( x0 + sliceSize) )        
     extent = list( baseExtent ) 
     
     extent[0:2] = [ x0, x0 + sliceCoord - 1 ]
     clip0 = vtk.vtkImageClip()
     clip0.SetInput( baseImage )
     clip0.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
     
     extent[0:2] = [ x0 + sliceCoord, x1 ]
     clip1 = vtk.vtkImageClip()
     clip1.SetInput( baseImage )
     clip1.SetOutputWholeExtent( extent[0], extent[1], extent[2], extent[3], extent[4], extent[5] )
     
     append = vtk.vtkImageAppend()
     append.SetAppendAxis( 0 )
     append.AddInput( clip1.GetOutput() )          
     append.AddInput( clip0.GetOutput() )
     
     imageInfo = vtk.vtkImageChangeInformation()
     imageInfo.SetInputConnection( append.GetOutputPort() ) 
     imageInfo.SetOutputOrigin( 0.0, 0.0, 0.0 )
     imageInfo.SetOutputExtentStart( 0, 0, 0 )
     imageInfo.SetOutputSpacing( baseSpacing[0], baseSpacing[1], baseSpacing[2] )
     
     result = imageInfo.GetOutput() 
     result.Update()
     return result
开发者ID:imclab,项目名称:vistrails,代码行数:38,代码来源:WorldMapModule.py

示例6: SplitIntoSlices

def SplitIntoSlices(vtkImage):
    vtkImageClip = vtk.vtkImageClip()
    vtkImageClip.SetInput(vtkImage)
    vtkImageClip.ClipDataOn()
    dimensions = vtkImage.GetDimensions()
    slices = []
    for z in range(0, dimensions[2]):
        vtkImageClip.SetOutputWholeExtent(0, dimensions[0], 0, dimensions[1], z, z)
        slice = vtk.vtkImageData()
        vtkImageClip.Update()
        slice.DeepCopy(vtkImageClip.GetOutput())
        slices.append(slice)
    del vtkImageClip
    return slices
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:14,代码来源:ImageOperations.py

示例7: __init__

    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._clipper = vtk.vtkImageClip()

        module_utils.setup_vtk_object_progress(self, self._clipper,
                                           'Reading PNG images.')

        self._config.outputWholeExtent = (0,-1,0,-1,0,-1)

        configList = [
            ('OutputWholeExtent:', 'outputWholeExtent', 'tuple:float,6', 'text',
             'The size of the clip volume.')]

        ScriptedConfigModuleMixin.__init__(self, configList)

        self._viewFrame = self._createViewFrame(
            {'Module (self)' : self,
             'vtkImageClip' : self._clipper})

        self.config_to_logic()
        self.syncViewWithLogic()
开发者ID:fvpolpeta,项目名称:devide,代码行数:22,代码来源:myImageClip.py

示例8: vtkGetDataRoot

from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

# Simple example that used to crash when an UpdateExtent request
# from one algorithm is overwritten by a smaller UpdateExtent
# request from another algorithm.  The COMBINED_UPDATE_EXTENT
# key was added to vtkStreamingDemandDrivenPipeline to fix the
# bug that caused the crash.
# read an image that has an extent of 0 255 0 255 0 0
reader = vtk.vtkPNGReader()
reader.SetDataSpacing(0.8,0.8,1.5)
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/fullhead15.png")
# Uncomment this to make the crash disappear
#reader Update
# clip the image down to 0 127 0 127 0 0
clip = vtk.vtkImageClip()
clip.SetInputConnection(reader.GetOutputPort())
clip.SetOutputWholeExtent(0,127,0,127,0,0)
# darken the background
darken = vtk.vtkImageShiftScale()
darken.SetInputConnection(reader.GetOutputPort())
darken.SetScale(0.2)
# do an operation on the clipped and unclipped data
blend = vtk.vtkImageBlend()
blend.SetInputConnection(darken.GetOutputPort())
blend.AddInputConnection(clip.GetOutputPort())
viewer = vtk.vtkImageViewer()
viewer.SetInputConnection(blend.GetOutputPort())
viewer.SetColorWindow(2000)
viewer.SetColorLevel(1000)
viewer.Render()
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:MultipleUpdateExtents.py

示例9: str

renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# create pipeline
#
PIECE = 0
NUMBER_OF_PIECES = 8
reader = vtk.vtkImageReader()
reader.SetDataByteOrderToLittleEndian()
reader.SetDataExtent(0,63,0,63,1,64)
reader.SetFilePrefix("" + str(VTK_DATA_ROOT) + "/Data/headsq/quarter")
reader.SetDataMask(0x7fff)
reader.SetDataSpacing(1.6,1.6,1.5)
clipper = vtk.vtkImageClip()
clipper.SetInputConnection(reader.GetOutputPort())
clipper.SetOutputWholeExtent(30,36,30,36,30,36)
clipper2 = vtk.vtkImageClip()
clipper2.SetInputConnection(reader.GetOutputPort())
clipper2.SetOutputWholeExtent(30,36,30,36,30,36)
tris = vtk.vtkDataSetTriangleFilter()
tris.SetInputConnection(clipper.GetOutputPort())
tris2 = vtk.vtkDataSetTriangleFilter()
tris2.SetInputConnection(clipper2.GetOutputPort())
geom = vtk.vtkGeometryFilter()
geom.SetInputConnection(tris.GetOutputPort())
pf = vtk.vtkProgrammableFilter()
pf.SetInputConnection(tris2.GetOutputPort())
def remove_ghosts():
    input = pf.GetInput()
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:testDataSetTriangleFilter.py

示例10: testimageMCAll

    def testimageMCAll(self):

        # Create the RenderWindow, Renderer and both Actors
        #
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)

        # create pipeline
        #
        slc = vtk.vtkStructuredPointsReader()
        slc.SetFileName(VTK_DATA_ROOT + "/Data/ironProt.vtk")

        colors = ["flesh", "banana", "grey", "pink", "carrot", "gainsboro", "tomato", "gold", "thistle", "chocolate"]

        types = ["UnsignedChar", "Char", "Short", "UnsignedShort", "Int", "UnsignedInt", "Long", "UnsignedLong", "Float", "Double"]

        i = 1
        c = 0
        clip = list()
        cast = list()
        iso = list()
        mapper = list()
        actor = list()

        colorWrapper = self.Colors()

        for idx, vtkType in enumerate(types):
            clip.append(vtk.vtkImageClip())
            clip[idx].SetInputConnection(slc.GetOutputPort())
            clip[idx].SetOutputWholeExtent(-1000, 1000, -1000, 1000, i, i + 5)
            i += 5
            cast.append(vtk.vtkImageCast())
            eval('cast[idx].SetOutputScalarTypeTo' + vtkType + '()')
            cast[idx].SetInputConnection(clip[idx].GetOutputPort())
            cast[idx].ClampOverflowOn()

            iso.append(vtk.vtkMarchingContourFilter())
            iso[idx].SetInputConnection(cast[idx].GetOutputPort())
            iso[idx].GenerateValues(1, 30, 30)

            mapper.append(vtk.vtkPolyDataMapper())
            mapper[idx].SetInputConnection(iso[idx].GetOutputPort())
            mapper[idx].ScalarVisibilityOff()

            actor.append(vtk.vtkActor())
            actor[idx].SetMapper(mapper[idx])
        #    actor[idx].Actor.GetProperty().SetDiffuseColor(lindex.colors.c.lindex.colors.c+1.lindex.colors.c+1)
            actor[idx].GetProperty().SetDiffuseColor(colorWrapper.GetRGBColor(colors[c]))
            actor[idx].GetProperty().SetSpecularPower(30)
            actor[idx].GetProperty().SetDiffuse(.7)
            actor[idx].GetProperty().SetSpecular(.5)
            c += 1
            ren.AddActor(actor[idx])


        outline = vtk.vtkOutlineFilter()
        outline.SetInputConnection(slc.GetOutputPort())
        outlineMapper = vtk.vtkPolyDataMapper()
        outlineMapper.SetInputConnection(outline.GetOutputPort())
        outlineActor = vtk.vtkActor()
        outlineActor.SetMapper(outlineMapper)
        outlineActor.VisibilityOff()

        # Add the actors to the renderer, set the background and size
        #
        ren.AddActor(outlineActor)
        ren.SetBackground(0.9, .9, .9)
        ren.ResetCamera()
        ren.GetActiveCamera().SetViewAngle(30)
        ren.GetActiveCamera().Elevation(20)
        ren.GetActiveCamera().Azimuth(20)
        ren.GetActiveCamera().Zoom(1.5)
        ren.ResetCameraClippingRange()

        renWin.SetSize(400, 400)

        # render and interact with data

        iRen = vtk.vtkRenderWindowInteractor()
        iRen.SetRenderWindow(renWin);
        renWin.Render()

        img_file = "imageMCAll.png"
        vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
        vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:86,代码来源:imageMCAll.py

示例11: clipInput

 def clipInput( self, extent ):
     self.clipper = vtk.vtkImageClip()
     self.clipper.AddInput( self._input )
     self.clipper.SetOutputWholeExtent( extent )
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:4,代码来源:ConfigurationFunctions.py

示例12: clipInput

 def clipInput( self, extent ):
     self.clipper = vtk.vtkImageClip()
     if vtk.VTK_MAJOR_VERSION <= 5:  self.clipper.AddInput( self._input )
     else:                           self.clipper.AddInputData( self._input )
     self.clipper.SetOutputWholeExtent( extent )
开发者ID:arulalant,项目名称:uvcdat,代码行数:5,代码来源:ConfigurationFunctions.py

示例13: testContour3DAll

    def testContour3DAll(self):

        # On older Macs, 10 is too low. Due to what looks like a driver bug
        # spectral lighting behaves sort of weird and produces small differences
        threshold = 30

        # Create the RenderWindow, Renderer and both Actors
        #
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.AddRenderer(ren)

        # create pipeline
        #
        slc = vtk.vtkStructuredPointsReader()
        slc.SetFileName(VTK_DATA_ROOT + "/Data/ironProt.vtk")

        actorColors = ["flesh", "banana", "grey", "pink", "carrot", "gainsboro", "tomato", "gold", "thistle", "chocolate"]

        types = ["UnsignedChar", "Char", "Short", "UnsignedShort", "Int", "UnsignedInt", "Long", "UnsignedLong", "Float", "Double"]

        i = 1
        c = 0

        clip = list()
        cast = list()
        iso = list()
        mapper = list()
        actor = list()

        colors = self.Colors()

        for idx, vtkType in enumerate(types):
            clip.append(vtk.vtkImageClip())
            clip[idx].SetInputConnection(slc.GetOutputPort())
            clip[idx].SetOutputWholeExtent(-1000, 1000, -1000, 1000, i, i + 5)

            i += 5

            cast.append(vtk.vtkImageCast())
            eval("cast[idx].SetOutputScalarTypeTo" + vtkType)
            cast[idx].SetInputConnection(clip[idx].GetOutputPort())
            cast[idx].ClampOverflowOn()

            iso.append(vtk.vtkContourFilter())
            iso[idx].SetInputConnection(cast[idx].GetOutputPort())
            iso[idx].GenerateValues(1, 30, 30)
            iso[idx].ComputeScalarsOff()
            iso[idx].ComputeGradientsOff()

            mapper.append(vtk.vtkPolyDataMapper())
            mapper[idx].SetInputConnection(iso[idx].GetOutputPort())
            mapper[idx].ImmediateModeRenderingOn()

            actor.append(vtk.vtkActor())
            actor[idx].SetMapper(mapper[idx])
            eval('actor[idx].GetProperty().SetDiffuseColor(colors.GetRGBColor("' + actorColors[idx] + '"))')
            actor[idx].GetProperty().SetSpecularPower(30)
            actor[idx].GetProperty().SetDiffuse(.7)
            actor[idx].GetProperty().SetSpecular(.5)

            c += 3

            ren.AddActor(actor[idx])


        outline = vtk.vtkOutlineFilter()
        outline.SetInputConnection(slc.GetOutputPort())
        outlineMapper = vtk.vtkPolyDataMapper()
        outlineMapper.SetInputConnection(outline.GetOutputPort())
        outlineActor = vtk.vtkActor()
        outlineActor.SetMapper(outlineMapper)
        outlineActor.VisibilityOff()

        # Add the actors to the renderer, set the background and size
        #
        ren.AddActor(outlineActor)
        ren.SetBackground(0.9, .9, .9)
        ren.ResetCamera()
        ren.GetActiveCamera().SetViewAngle(30)
        ren.GetActiveCamera().Elevation(20)
        ren.GetActiveCamera().Azimuth(20)
        ren.GetActiveCamera().Zoom(1.5)
        ren.ResetCameraClippingRange()

        renWin.SetSize(400, 400)

        # render and interact with data

        iRen = vtk.vtkRenderWindowInteractor()
        iRen.SetRenderWindow(renWin);
        renWin.Render()


        img_file = "contour3DAll.png"
        vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
        vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:97,代码来源:contour3DAll.py

示例14: _BuildPipeline

    def _BuildPipeline(self):
        """_BuildPipeline - Builds the visualization pipeline"""

        image = component.getUtility(ICurrentImage)

        # update image (VTK-6 compatible)
        image.Update()

        # image reslice object
        reslice = vtk.vtkImageReslice()
        reslice.SetInterpolationModeToCubic()
        reslice.ReleaseDataFlagOn()
        reslice.SetInputConnection(image.GetOutputPort())
        if self._transform:
            reslice.SetTransform(self._transform)

        # get extents, spacings, etc
        in_extent = image.GetExtent()
        in_spacing = image.GetSpacing()
        in_origin = image.GetOrigin()

        # get stencil data
        stencil_data = image.GetStencilData()

        # Set image resample factor
        f = self.gui.m_sliderSurfaceQuality.GetValue() / 100.0
        if f == 0.0:
            f = 0.001

        # Set surface decimation factor
        decf = self.gui.m_sliderDecimationFactor.GetValue() / 100.0

        # Enable/Disable stencil usage
        if self.gui.m_checkBoxClipping.GetValue() is True and stencil_data:
            if vtk.vtkVersion().GetVTKMajorVersion() > 5:
                reslice.SetStencilData(stencil_data)
            else:
                reslice.SetStencil(stencil_data)
            reslice.SetBackgroundLevel(image.GetScalarRange()[0])
            ext = stencil_data.GetExtent()
        else:
            ext = in_extent
            if vtk.vtkVersion().GetVTKMajorVersion() > 5:
                reslice.SetStencilData(None)
            else:
                reslice.SetStencil(None)

        # expand extent slightly - account for downsampling later too
        fudge = int(math.ceil(1.0 / f))
        ext = [ext[0] - fudge, ext[1] + fudge, ext[2] - fudge, ext[3] + fudge, ext[4] - fudge, ext[5] + fudge]

        reslice.SetOutputExtent(ext)

        # set default origin/spacing -- these two lines work...
        reslice.SetOutputSpacing(in_spacing)
        reslice.SetOutputOrigin(in_origin)

        # do we need to downsample the image?
        if f < 1.0:
            resample = vtk.vtkImageResample()
            resample.SetInputConnection(reslice.GetOutputPort())
            resample.ReleaseDataFlagOn()
            for i in range(3):
                resample.SetAxisMagnificationFactor(i, f)
            obj = resample
        else:
            obj = reslice

        # do we need to smooth the image?
        if self.gui.m_checkBoxImageSmoothing.GetValue() == True:
            smooth = vtk.vtkImageGaussianSmooth()
            smooth.SetStandardDeviation(1.0)
            smooth.ReleaseDataFlagOn()
            smooth.SetInputConnection(obj.GetOutputPort())
            obj = smooth

        clip = vtk.vtkImageClip()
        clip.SetInputConnection(obj.GetOutputPort())

        # setup contour filter
        cf = vtk.vtkMarchingCubes()
        cf.SetNumberOfContours(1)
        val = float(self.gui.m_textCtrlImageThreshold.GetValue())
        cf.SetValue(0, val)
        cf.SetComputeScalars(0)
        cf.SetComputeNormals(0)
        cf.SetInputConnection(clip.GetOutputPort())

        # decimate surface
        decimate = vtk.vtkDecimatePro()
        decimate.SetInputConnection(cf.GetOutputPort())
        decimate.PreserveTopologyOn()
        decimate.SetTargetReduction(decf)

        # To cut down on memory consumption, we use the clip object
        # to process the image a chunk at a time.  By default we
        # use 20 chunks -- but if the chunks are too small, we'll adjust this
        # number

        clip.UpdateInformation()
#.........这里部分代码省略.........
开发者ID:andyTsing,项目名称:MicroView,代码行数:101,代码来源:IsoSurfaceDisplay.py

示例15: getBoundedMap

    def getBoundedMap( self, baseImage, dataLocation, map_cut_size ):
        baseImage.Update()
        baseExtent = baseImage.GetExtent()
        baseSpacing = baseImage.GetSpacing()
        x0 = baseExtent[0]
        x1 = baseExtent[1]
        y0 = baseExtent[2]
        y1 = baseExtent[3]
        imageLen = [ x1 - x0 + 1, y1 - y0 + 1 ]
        selectionDim = [ map_cut_size[0]/2, map_cut_size[1]/2 ]
        dataXLoc = NormalizeLon( dataLocation[0] ) 
        imageInfo = vtk.vtkImageChangeInformation()
        dataYbounds = [ dataLocation[1]-selectionDim[1], dataLocation[1]+selectionDim[1] ]
        vertExtent = [ y0, y1 ]
        bounded_dims = None
        if dataYbounds[0] > -90.0:
            yOffset = dataYbounds[0] + 90.0
            extOffset = int( round( ( yOffset / 180.0 ) * imageLen[1] ) )
            vertExtent[0] = y0 + extOffset
            self.y0 = dataYbounds[0]
        if dataYbounds[1] < 90.0:
            yOffset = 90.0 - dataYbounds[1]
            extOffset = int( round( ( yOffset / 180.0 ) * imageLen[1] ) )
            vertExtent[1] = y1 - extOffset
                   
        if (( dataXLoc > selectionDim[0] ) and ( dataXLoc < ( 360 - selectionDim[0]) )):

            cut0 = dataXLoc - selectionDim[0] 
            sliceSize =  imageLen[0] * ( cut0 / 360.0 )
            sliceCoord = int( round( x0 + sliceSize) )        
            extent = list( baseExtent )         
            extent[0] = x0 + sliceCoord - 1
        
            cut1 = dataXLoc + selectionDim[0] 
            sliceSize =  imageLen[0] * ( cut1 / 360.0 )
            sliceCoord = int( round( x0 + sliceSize) )       
            extent[1] = x0 + sliceCoord
            clip = vtk.vtkImageClip()
            clip.SetInput( baseImage )
            clip.SetOutputWholeExtent( extent[0], extent[1], vertExtent[0], vertExtent[1], extent[4], extent[5] )
            self.x0 = cut0
            bounded_dims = ( extent[1] - extent[0] + 1, vertExtent[1] - vertExtent[0] + 1 )

            imageInfo.SetInputConnection( clip.GetOutputPort() ) 
            
        else:
            cut0 = NormalizeLon( dataXLoc + selectionDim[0] )
            sliceSize =  imageLen[0] * ( cut0 / 360.0 )
            sliceCoord = int( round( x0 + sliceSize) )        
            extent = list( baseExtent )         
            extent[0:2] = [ x0, x0 + sliceCoord - 1 ]
            clip0 = vtk.vtkImageClip()
            clip0.SetInput( baseImage )
            clip0.SetOutputWholeExtent( extent[0], extent[1], vertExtent[0], vertExtent[1], extent[4], extent[5] )
            size0 = extent[1] - extent[0] + 1
        
            cut1 = NormalizeLon( dataLocation[0] - selectionDim[0] )
            sliceSize =  imageLen[0] * ( cut1 / 360.0 )
            sliceCoord = int( round( x0 + sliceSize) )       
            extent[0:2] = [ x0 + sliceCoord, x1 ]
            clip1 = vtk.vtkImageClip()
            clip1.SetInput( baseImage )
            clip1.SetOutputWholeExtent( extent[0], extent[1], vertExtent[0], vertExtent[1], extent[4], extent[5] )
            size1 = extent[1] - extent[0] + 1
            self.x0 = cut1
        
            append = vtk.vtkImageAppend()
            append.SetAppendAxis( 0 )
            append.AddInput( clip1.GetOutput() )          
            append.AddInput( clip0.GetOutput() )
            bounded_dims = ( size0 + size1, vertExtent[1] - vertExtent[0] + 1 )
            
            imageInfo.SetInputConnection( append.GetOutputPort() ) 
            
        imageInfo.SetOutputOrigin( 0.0, 0.0, 0.0 )
        imageInfo.SetOutputExtentStart( 0, 0, 0 )
        imageInfo.SetOutputSpacing( baseSpacing[0], baseSpacing[1], baseSpacing[2] )
        
        result = imageInfo.GetOutput() 
        result.Update()
        return result, bounded_dims
开发者ID:imclab,项目名称:vistrails,代码行数:81,代码来源:WorldMapModule.py


注:本文中的vtk.vtkImageClip函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。