本文整理汇总了Python中vtk.vtkImageActor函数的典型用法代码示例。如果您正苦于以下问题:Python vtkImageActor函数的具体用法?Python vtkImageActor怎么用?Python vtkImageActor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkImageActor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.interactor = None
self.image_original = None
self.image_threshold = None
self.render = None
self.lut = vtk.vtkLookupTable()
self.lut_original = vtk.vtkLookupTable()
self.image_color = vtk.vtkImageMapToColors()
self.blend = blend = vtk.vtkImageBlend()
self.map = map = vtk.vtkImageMapper()
self.actor = actor = vtk.vtkImageActor()
self.actor2 = actor2 = vtk.vtkImageActor()
self.actor3 = actor3 = vtk.vtkImageActor()
self.image_color_o = vtk.vtkImageMapToColors()
self.operation_type = 0
self.w = None
self.slice = 0
self.clicked = 0
self.orientation = AXIAL
self.w = (200, 1200)
开发者ID:151706061,项目名称:invesalius3,代码行数:27,代码来源:editor.py
示例2: __init__
def __init__(self, ren):
self.volume = self.LoadVolume()
self.ren = ren
# next initialize the pipeline
self.slicer = vtk.vtkImageReslice()
self.slicer.SetInput( self.volume )
self.slicer.SetOutputDimensionality(2)
# the next filter provides a mechanism for slice selection
self.selector = SliceSelector(self.volume)
self.slicer.SetResliceAxes( self.selector.GetDirectionCosines() )
self.slicer.SetResliceAxesOrigin( self.selector.GetAxesOrigin() )
# setup link for adjusting the contrast of the image
r = self.volume.GetScalarRange()
self.lutBuilder = LUTBuilder(r[0],r[1],1)
lut = self.lutBuilder.Build()
self.colors = vtk.vtkImageMapToColors()
self.colors.SetInputConnection( self.slicer.GetOutputPort() )
self.colors.SetLookupTable( lut )
self.actor = vtk.vtkImageActor()
self.actor.SetInput( self.colors.GetOutput() )
开发者ID:ewong718,项目名称:freesurfer,代码行数:25,代码来源:ImagePipeline.py
示例3: __init__
def __init__(self):
""" Class constructor """
# Initialize the OpenCV object responsible for acquire the images
self.capture = cv2.VideoCapture(0)
# Initialize the VTK object that is going to translate the image
self.image = vtk.vtkImageImport()
self.image.SetDataScalarTypeToUnsignedChar()
# Three color layers
self.image.SetNumberOfScalarComponents(3)
# Image dimensions
width, height = self.size
self.image.SetDataExtent(0, width-1, 0, height-1, 0, 0)
self.image.SetWholeExtent(0, width-1, 0, height-1, 0, 0)
self.update()
# Initialize render and assign the deepest layer
self.render = vtk.vtkRenderer()
self.render.SetLayer(0)
self.render.InteractiveOff()
# In VTK renders objects are shown through actors, like in a movie
self.image_actor = vtk.vtkImageActor()
image_port = self.image.GetOutputPort()
self.image_actor.GetMapper().SetInputConnection(image_port)
# Place actor into action
self.render.AddActor(self.image_actor)
开发者ID:asrob-uc3m,项目名称:augmented-fpv,代码行数:31,代码来源:background.py
示例4: Execute
def Execute(self):
if self.Image == None:
self.PrintError('Error: no Image.')
if not self.vmtkRenderer:
self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
self.vmtkRenderer.Initialize()
self.OwnRenderer = 1
if self.Type == 'freehand':
self.ImageTracerWidget = vtk.vtkImageTracerWidget()
elif self.Type == 'contour':
self.ImageTracerWidget = vtk.vtkContourWidget()
self.ImageTracerWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.SliderWidget = vtk.vtkSliderWidget()
self.SliderWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.ImageActor = vtk.vtkImageActor()
self.vmtkRenderer.RenderWindowInteractor.AddObserver("KeyPressEvent", self.Keypress)
self.Display()
if self.OwnRenderer:
self.vmtkRenderer.Deallocate()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:27,代码来源:vmtkimagelinetracer.py
示例5: removeActor
def removeActor(self):
logging.debug("In VTKImageView::removeActor()")
self.render.RemoveActor(self.actor)
self.actor = vtk.vtkImageActor()
self.render.AddActor(self.actor)
self.render.ResetCamera()
self.Render()
开发者ID:aevum,项目名称:moonstone,代码行数:7,代码来源:vtkimageview.py
示例6: put_img_on_canvas
def put_img_on_canvas(self,filename,zoom=1,xOffset=0,yOffset=0,*args,**kargs):
readerFactory = vtk.vtkImageReader2Factory()
reader = readerFactory.CreateImageReader2(filename)
reader.SetFileName(filename)
reader.Update()
imageData = reader.GetOutput()
a = vtk.vtkImageActor()
a.GetMapper().SetInputConnection(reader.GetOutputPort())
origin = imageData.GetOrigin()
spc = imageData.GetSpacing()
ext = imageData.GetExtent()
ren = vtk.vtkRenderer()
r,g,b = self.canvas.backgroundcolor
ren.SetBackground(r/255.0, g/255.0, b/255.0)
cam = ren.GetActiveCamera()
cam.ParallelProjectionOn()
width = (ext[1]-ext[0])*spc[0]
height = (ext[3]-ext[2])*spc[1]
xoff = width*xOffset/zoom/200.
yoff = height*yOffset/zoom/200.
xc = origin[0] + .5*(ext[0]+ext[1])*spc[0]
yc = origin[1] + .5*(ext[2]+ext[3])*spc[1]
yd = (ext[3]-ext[2])*spc[1]
d = cam.GetDistance()
cam.SetParallelScale(.5*yd/zoom)
cam.SetFocalPoint(xc+xoff,yc+yoff,0.)
cam.SetPosition(xc+xoff,yc+yoff,d)
ren.AddActor(a)
self.renWin.AddRenderer(ren)
self.renWin.Render()
return
开发者ID:arulalant,项目名称:uvcdat,代码行数:31,代码来源:VTKPlots.py
示例7: Execute
def Execute(self):
if self.Image == None:
self.PrintError("Error: no Image.")
if not self.vmtkRenderer:
self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
self.vmtkRenderer.Initialize()
self.OwnRenderer = 1
self.vmtkRenderer.RegisterScript(self)
if self.Type == "freehand":
self.ImageTracerWidget = vtk.vtkImageTracerWidget()
elif self.Type == "contour":
self.ImageTracerWidget = vtk.vtkContourWidget()
self.ImageTracerWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.SliderWidget = vtk.vtkSliderWidget()
self.SliderWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.ImageActor = vtk.vtkImageActor()
self.vmtkRenderer.AddKeyBinding("n", "Next.", self.NextCallback)
self.vmtkRenderer.AddKeyBinding("p", "Previous.", self.PreviousCallback)
self.vmtkRenderer.AddKeyBinding("i", "Interact.", self.InteractCallback)
self.Display()
if self.OwnRenderer:
self.vmtkRenderer.Deallocate()
开发者ID:tangui,项目名称:vmtk,代码行数:31,代码来源:vmtkimagelinetracer.py
示例8: ShowSlice
def ShowSlice(self, index = 0):
dicom = self.dicom_list[index]
# UPDATE GUI
## Text related to size
value = STR_SIZE %(dicom.image.size[0], dicom.image.size[1])
self.text_image_size.SetValue(value)
## Text related to slice position
if not(dicom.image.spacing):
value1 = ''
else:
value1 = STR_SPC %(dicom.image.spacing[2])
if dicom.image.orientation_label == 'AXIAL':
value2 = STR_LOCAL %(dicom.image.position[2])
elif dicom.image.orientation_label == 'CORONAL':
value2 = STR_LOCAL %(dicom.image.position[1])
elif dicom.image.orientation_label == 'SAGITTAL':
value2 = STR_LOCAL %(dicom.image.position[0])
else:
value2 = ''
value = "%s\n%s" %(value1, value2)
self.text_image_location.SetValue(value)
## Text related to patient/ acquisiiton data
value = STR_PATIENT %(dicom.patient.id,\
dicom.acquisition.protocol_name)
self.text_patient.SetValue(value)
## Text related to acquisition date and time
value = STR_ACQ % (dicom.acquisition.date,
dicom.acquisition.time)
self.text_acquisition.SetValue(value)
rdicom = vtkgdcm.vtkGDCMImageReader()
rdicom.SetFileName(dicom.image.file)
rdicom.Update()
# ADJUST CONTRAST
window_level = dicom.image.level
window_width = dicom.image.window
colorer = vtk.vtkImageMapToWindowLevelColors()
colorer.SetInputConnection(rdicom.GetOutputPort())
colorer.SetWindow(float(window_width))
colorer.SetLevel(float(window_level))
colorer.Update()
if self.actor is None:
self.actor = vtk.vtkImageActor()
self.renderer.AddActor(self.actor)
# PLOT IMAGE INTO VIEWER
self.actor.SetInputData(colorer.GetOutput())
self.renderer.ResetCamera()
self.interactor.Render()
# Setting slider position
self.slider.SetValue(index)
开发者ID:151706061,项目名称:invesalius3,代码行数:60,代码来源:dicom_preview_panel.py
示例9: __init__
def __init__(self, image_handler):
self._name = 'Image View'
self._view = PythonQt.dd.ddQVTKWidgetView()
self._image_handler = image_handler
self._image = vtk.vtkImageData()
self._prev_attrib = None
# Initialize the view.
self._view.installImageInteractor()
# Add actor.
self._image_actor = vtk.vtkImageActor()
vtk_SetInputData(self._image_actor, self._image)
self._image_actor.SetVisibility(False)
self._view.renderer().AddActor(self._image_actor)
self._view.orientationMarkerWidget().Off()
self._view.backgroundRenderer().SetBackground(0, 0, 0)
self._view.backgroundRenderer().SetBackground2(0, 0, 0)
self._depth_mapper = None
# Add timer.
self._render_timer = TimerCallback(
targetFps=60,
callback=self.render)
self._render_timer.start()
开发者ID:RobotLocomotion,项目名称:drake,代码行数:27,代码来源:show_image.py
示例10: _makeImagePlane
def _makeImagePlane(imageData) :
''' Takes a vtkImageData object and
returns a plane textured with that image
and a camera for the background renderer
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/BackgroundImage
was the basis for this function
'''
imageActor = vtk.vtkImageActor()
if vtk.VTK_MAJOR_VERSION <= 5 :
imageActor.SetInput(imageData)
else :
imageActor.SetInputData(imageData)
origin = imageData.GetOrigin()
spacing = imageData.GetSpacing()
extent = imageData.GetExtent()
camera = vtk.vtkCamera()
camera.ParallelProjectionOn()
xc = origin[0] + 0.5*(extent[0] + extent[1])*spacing[0]
yc = origin[1] + 0.5*(extent[2] + extent[3])*spacing[1]
yd = (extent[3] - extent[2] + 1)*spacing[1]
d = camera.GetDistance()
camera.SetParallelScale(0.5*yd)
camera.SetFocalPoint(xc,yc,0.0)
camera.SetPosition(xc,yc,d)
return camera, imageActor
开发者ID:gnastacast,项目名称:dvrk-vtk-registration,代码行数:30,代码来源:vtkTools.py
示例11: create_slice_window
def create_slice_window(self):
renderer = vtk.vtkRenderer()
renderer.SetLayer(0)
cam = renderer.GetActiveCamera()
overlay_renderer = vtk.vtkRenderer()
overlay_renderer.SetLayer(1)
overlay_renderer.SetActiveCamera(cam)
overlay_renderer.SetInteractive(0)
self.interactor.GetRenderWindow().SetNumberOfLayers(2)
self.interactor.GetRenderWindow().AddRenderer(overlay_renderer)
self.interactor.GetRenderWindow().AddRenderer(renderer)
actor = vtk.vtkImageActor()
# TODO: Create a option to let the user set if he wants to interpolate
# the slice images.
#actor.InterpolateOff()
slice_data = sd.SliceData()
slice_data.SetOrientation(self.orientation)
slice_data.renderer = renderer
slice_data.overlay_renderer = overlay_renderer
slice_data.actor = actor
slice_data.SetBorderStyle(sd.BORDER_ALL)
renderer.AddActor(actor)
renderer.AddActor(slice_data.text.actor)
renderer.AddViewProp(slice_data.box_actor)
return slice_data
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:28,代码来源:viewer_slice.py
示例12: Execute
def Execute(self):
if self.Image == None:
self.PrintError('Error: no Image.')
if not self.vmtkRenderer:
self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
self.vmtkRenderer.Initialize()
self.OwnRenderer = 1
self.vmtkRenderer.RegisterScript(self)
if self.Type == 'freehand':
self.ImageTracerWidget = vtk.vtkImageTracerWidget()
elif self.Type == 'contour':
self.ImageTracerWidget = vtk.vtkContourWidget()
self.ImageTracerWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.SliderWidget = vtk.vtkSliderWidget()
self.SliderWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
self.ImageActor = vtk.vtkImageActor()
self.vmtkRenderer.AddKeyBinding('n','Next.',self.NextCallback)
self.vmtkRenderer.AddKeyBinding('p','Previous.',self.PreviousCallback)
self.vmtkRenderer.AddKeyBinding('i','Interact.', self.InteractCallback)
self.Display()
if self.OwnRenderer:
self.vmtkRenderer.Deallocate()
开发者ID:ChaliZhg,项目名称:vmtk,代码行数:31,代码来源:vmtkimagelinetracer.py
示例13: buildPipeline
def buildPipeline(self):
""" execute() -> None
Dispatch the vtkRenderer to the actual rendering widget
"""
module = self.getRegisteredModule()
world_map = None # wmod.forceGetInputFromPort( "world_map", None ) if wmod else None
opacity = wmod.forceGetInputFromPort( "opacity", 0.4 ) if wmod else 0.4
map_border_size = wmod.forceGetInputFromPort( "map_border_size", 20 ) if wmod else 20
self.y0 = -90.0
dataPosition = None
if world_map == None:
self.map_file = defaultMapFile
self.map_cut = defaultMapCut
else:
self.map_file = world_map[0].name
self.map_cut = world_map[1]
self.world_cut = wmod.forceGetInputFromPort( "world_cut", -1 ) if wmod else getFunctionParmStrValues( module, "world_cut", -1 )
roi_size = [ self.roi[1] - self.roi[0], self.roi[3] - self.roi[2] ]
map_cut_size = [ roi_size[0] + 2*map_border_size, roi_size[1] + 2*map_border_size ]
data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
if self.world_cut == -1:
if (self.roi <> None):
if roi_size[0] > 180:
self.ComputeCornerPosition()
self.world_cut = NormalizeLon( self.x0 )
else:
dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
else:
self.world_cut = self.map_cut
self.imageInfo = vtk.vtkImageChangeInformation()
image_reader = vtk.vtkJPEGReader()
image_reader.SetFileName( self.map_file )
baseImage = image_reader.GetOutput()
new_dims = None
if dataPosition == None:
baseImage = self.RollMap( baseImage )
new_dims = baseImage.GetDimensions()
else:
baseImage, new_dims = self.getBoundedMap( baseImage, dataPosition, map_cut_size )
scale = [ map_cut_size[0]/new_dims[0], map_cut_size[1]/new_dims[1], 1 ]
# printArgs( " baseMap: ", extent=baseImage.GetExtent(), spacing=baseImage.GetSpacing(), origin=baseImage.GetOrigin() )
self.baseMapActor = vtk.vtkImageActor()
self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
self.baseMapActor.SetScale( scale )
self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
self.baseMapActor.SetOpacity( opacity )
# self.baseMapActor.SetDisplayExtent( -1, 0, 0, 0, 0, 0 )
#Positioning map at location %s, size = %s, roi = %s" % ( str( ( self.x0, self.y0) ), str( map_cut_size ), str( ( NormalizeLon( self.roi[0] ), NormalizeLon( self.roi[1] ), self.roi[2], self.roi[3] ) ) )
self.baseMapActor.SetPosition( self.x0, self.y0, 0.1 )
self.baseMapActor.SetInput( baseImage )
self.renderer.AddActor( self.baseMapActor )
开发者ID:imclab,项目名称:vistrails,代码行数:58,代码来源:WorldMapModule.py
示例14: __init_vtk
def __init_vtk(self):
actor = vtk.vtkImageActor()
self.actor = actor
text_image_size = vtku.Text()
text_image_size.SetPosition(const.TEXT_POS_LEFT_UP)
text_image_size.SetValue("")
text_image_size.SetSize(const.TEXT_SIZE_SMALL)
self.text_image_size = text_image_size
text_image_location = vtku.Text()
text_image_location.SetVerticalJustificationToBottom()
text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN)
text_image_location.SetValue("")
text_image_location.SetSize(const.TEXT_SIZE_SMALL)
self.text_image_location = text_image_location
text_patient = vtku.Text()
text_patient.SetJustificationToRight()
text_patient.SetPosition(const.TEXT_POS_RIGHT_UP)
text_patient.SetValue("")
text_patient.SetSize(const.TEXT_SIZE_SMALL)
self.text_patient = text_patient
text_acquisition = vtku.Text()
text_acquisition.SetJustificationToRight()
text_acquisition.SetVerticalJustificationToBottom()
text_acquisition.SetPosition(const.TEXT_POS_RIGHT_DOWN)
text_acquisition.SetValue("")
text_acquisition.SetSize(const.TEXT_SIZE_SMALL)
self.text_acquisition = text_acquisition
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.AddActor(text_image_size.actor)
renderer.AddActor(text_image_location.actor)
renderer.AddActor(text_patient.actor)
renderer.AddActor(text_acquisition.actor)
self.renderer = renderer
style = vtk.vtkInteractorStyleImage()
interactor = wxVTKRenderWindowInteractor(self.panel, -1,
size=wx.Size(340,340))
interactor.GetRenderWindow().AddRenderer(renderer)
interactor.SetInteractorStyle(style)
interactor.Render()
self.interactor = interactor
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(interactor, 1, wx.GROW|wx.EXPAND)
sizer.Fit(self.panel)
self.panel.SetSizer(sizer)
self.Layout()
self.Update()
开发者ID:151706061,项目名称:invesalius,代码行数:55,代码来源:dicom_preview_panel.py
示例15: build
def build( self, **args ):
if self.enableBasemap:
# print " @@@ MapManager: build "
world_map = None
dataPosition = None
if world_map == None:
self.map_file = defaultMapFile
self.map_cut = defaultMapCut
else:
self.map_file = world_map[0].name
self.map_cut = world_map[1]
# data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
if self.world_cut == -1:
if (self.roi <> None):
if self.roi_size[0] > 180:
self.ComputeCornerPosition()
self.world_cut = self.NormalizeMapLon( self.x0 )
else:
dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
else:
self.world_cut = self.map_cut
self.imageInfo = vtk.vtkImageChangeInformation()
self.image_reader = vtk.vtkJPEGReader()
self.image_reader.SetFileName( self.map_file )
self.image_reader.Update()
world_image = self.image_reader.GetOutput()
self.sphericalBaseImage = self.RollMap( world_image )
new_dims, scale = None, None
if dataPosition == None:
self.baseImage = self.RollMap( world_image )
new_dims = self.baseImage.GetDimensions()
scale = [ 360.0/new_dims[0], 180.0/new_dims[1], 1 ]
self.width = 360.0
else:
self.baseImage, new_dims = self.getBoundedMap( world_image, dataPosition )
scale = [ self.map_cut_size[0]/new_dims[0], self.map_cut_size[1]/new_dims[1], 1 ]
self.width = self.map_cut_size[0]
self.baseMapActor = vtk.vtkImageActor()
self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
self.baseMapActor.SetScale( scale )
self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
self.baseMapActor.SetOpacity( self.map_opacity )
mapCorner = [ self.x0, self.y0 ]
self.baseMapActor.SetPosition( mapCorner[0], mapCorner[1], 0.05 )
extent = self.baseImage.GetExtent()
# print " @@@ baseImage.GetExtent: ", str( extent )
# print " @@@ baseImage.Position: ", str( self.x0 )
# print " @@@ baseImage.Size: ", str( self.map_cut_size )
if vtk.VTK_MAJOR_VERSION <= 5: self.baseMapActor.SetInput(self.baseImage)
else: self.baseMapActor.SetInputData(self.baseImage)
self.mapCenter = [ self.x0 + self.map_cut_size[0]/2.0, self.y0 + self.map_cut_size[1]/2.0 ]
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:55,代码来源:MapManager.py
示例16: setImage
def setImage(self, dicomfile):
logging.debug("In VTKImageView::setImage()")
if dicomfile:
if os.path.exists(dicomfile):
self.reader = vtkgdcm.vtkGDCMImageReader()
self.reader.SetFileName(dicomfile)
self.reader.Update()
vtkImageData = self.reader.GetOutput()
vtkImageData.UpdateInformation()
srange = vtkImageData.GetScalarRange()
cast = vtk.vtkImageCast()
cast.SetInput(vtkImageData)
cast.SetOutputScalarType(4)
cast.Update()
cast.GetOutput().SetUpdateExtentToWholeExtent()
table = vtk.vtkLookupTable()
table.SetNumberOfColors(256)
table.SetHueRange(0.0, 0.0)
table.SetSaturationRange(0.0, 0.0)
table.SetValueRange(0.0, 1.0)
table.SetAlphaRange(1.0, 1.0)
table.SetRange(srange)
table.SetRampToLinear()
table.Build()
color = vtk.vtkImageMapToColors()
color.SetLookupTable(table)
color.SetInputConnection(cast.GetOutputPort())
color.Update()
self.cast = vtk.vtkImageMapToWindowLevelColors()
self.cast.SetOutputFormatToLuminance()
self.cast.SetInputConnection(color.GetOutputPort())
self.cast.SetWindow(255.0)
self.cast.SetLevel(127.0)
self.cast.Update()
self.cast.UpdateWholeExtent()
self.render.RemoveActor(self.actor)
self.actor = vtk.vtkImageActor()
self.actor.SetInput(self.cast.GetOutput())
self.render.AddActor(self.actor)
self.render.ResetCamera()
self.Render()
else:
self.render.RemoveActor(self.actor)
self.Render()
else:
self.render.RemoveActor(self.actor)
self.Render()
开发者ID:aevum,项目名称:moonstone,代码行数:53,代码来源:vtkimageview.py
示例17: build
def build( self, **args ):
if self.enableBasemap:
world_map = None
dataPosition = None
if world_map == None:
self.map_file = defaultMapFile
self.map_cut = defaultMapCut
else:
self.map_file = world_map[0].name
self.map_cut = world_map[1]
roi_size = [ self.roi[1] - self.roi[0], self.roi[3] - self.roi[2] ]
map_cut_size = [ roi_size[0] + 2*self.map_border_size, roi_size[1] + 2*self.map_border_size ]
if map_cut_size[0] > 360.0: map_cut_size[0] = 360.0
if map_cut_size[1] > 180.0: map_cut_size[1] = 180.0
# data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
if self.world_cut == -1:
if (self.roi <> None):
if roi_size[0] > 180:
self.ComputeCornerPosition()
self.world_cut = self.NormalizeMapLon( self.x0 )
else:
dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
else:
self.world_cut = self.map_cut
self.imageInfo = vtk.vtkImageChangeInformation()
self.image_reader = vtk.vtkJPEGReader()
self.image_reader.SetFileName( self.map_file )
self.image_reader.Update()
world_image = self.image_reader.GetOutput()
self.sphericalBaseImage = self.RollMap( world_image )
new_dims, scale = None, None
if dataPosition == None:
self.baseImage = self.RollMap( world_image )
new_dims = self.baseImage.GetDimensions()
scale = [ 360.0/new_dims[0], 180.0/new_dims[1], 1 ]
else:
self.baseImage, new_dims = self.getBoundedMap( world_image, dataPosition, map_cut_size, self.map_border_size )
scale = [ map_cut_size[0]/new_dims[0], map_cut_size[1]/new_dims[1], 1 ]
self.baseMapActor = vtk.vtkImageActor()
self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
self.baseMapActor.SetScale( scale )
self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
self.baseMapActor.SetOpacity( self.map_opacity )
mapCorner = [ self.x0, self.y0 ]
self.baseMapActor.SetPosition( mapCorner[0], mapCorner[1], 0.1 )
if vtk.VTK_MAJOR_VERSION <= 5: self.baseMapActor.SetInput(self.baseImage)
else: self.baseMapActor.SetInputData(self.baseImage)
self.mapCenter = [ self.x0 + map_cut_size[0]/2.0, self.y0 + map_cut_size[1]/2.0 ]
开发者ID:UV-CDAT,项目名称:UVIS_DV3D,代码行数:52,代码来源:MapManager.py
示例18: ShowSlice
def ShowSlice(self, index = 0):
bitmap = self.bitmap_list[index]
# UPDATE GUI
## Text related to size
value = STR_SIZE %(bitmap[3], bitmap[4])
self.text_image_size.SetValue(value)
value1 = ''
value2 = ''
value = "%s\n%s" %(value1, value2)
self.text_image_location.SetValue(value)
#self.text_patient.SetValue(value)
self.text_patient.SetValue('')
#self.text_acquisition.SetValue(value)
self.text_acquisition.SetValue('')
n_array = bitmap_reader.ReadBitmap(bitmap[0])
image = converters.to_vtk(n_array, spacing=(1,1,1),\
slice_number=1, orientation="AXIAL")
# ADJUST CONTRAST
window_level = n_array.max()/2
window_width = n_array.max()
colorer = vtk.vtkImageMapToWindowLevelColors()
colorer.SetInputData(image)
colorer.SetWindow(float(window_width))
colorer.SetLevel(float(window_level))
colorer.Update()
if self.actor is None:
self.actor = vtk.vtkImageActor()
self.renderer.AddActor(self.actor)
# PLOT IMAGE INTO VIEWER
self.actor.SetInputData(colorer.GetOutput())
self.renderer.ResetCamera()
self.interactor.Render()
# Setting slider position
self.slider.SetValue(index)
开发者ID:paulojamorim,项目名称:invesalius3,代码行数:50,代码来源:bitmap_preview_panel.py
示例19: __init__
def __init__(self, parent=None):
logging.debug("In VTKImageView::__init__()")
super(VTKImageView, self).__init__(parent)
self.setWindowTitle(constant.TITLE_PROGRAM)
self.actor = vtk.vtkImageActor()
self.textActors = []
self.render = vtk.vtkRenderer()
self.render.AddActor(self.actor)
self.interactorStyle = vtk.vtkInteractorStyleImage()
self.SetInteractorStyle(self.interactorStyle)
self.window = self.GetRenderWindow()
self.window.AddRenderer(self.render)
开发者ID:aevum,项目名称:moonstone,代码行数:16,代码来源:vtkimageview.py
示例20: __init__
def __init__(self):
self.colour = (0.0, 0.0, 1.0)
self.opacity = 1
self.size = 15.0
self.orientation = "AXIAL"
self.spacing = (1, 1, 1)
if vtk.vtkVersion().GetVTKVersion() > '5.8.0':
self.mapper = vtk.vtkImageSliceMapper()
cursor_property = vtk.vtkImageProperty()
cursor_property.SetInterpolationTypeToNearest()
self.actor = vtk.vtkImageSlice()
self.actor.SetMapper(self.mapper)
self.actor.SetProperty(cursor_property)
else:
self.actor = vtk.vtkImageActor()
self.mapper = None
self._build_actor()
self._calculate_area_pixels()
开发者ID:dragonlet,项目名称:invesalius3,代码行数:18,代码来源:cursor_actors.py
注:本文中的vtk.vtkImageActor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论