• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkImageViewer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

    def __init__(self):
    
        #os.system("pwd")
        if os.path.exists(self.gladeFile):
            theFile = self.gladeFile
        elif os.path.exists("gui/"+self.gladeFile):
            theFile = "gui/"+self.gladeFile
        else:
            theFile = os.path.join(
                distutils.sysconfig.PREFIX,
                'share', 'pbrain', self.gladeFile)

        self.widgets = gtk.glade.XML (theFile)
        self.widgets.signal_autoconnect(GladeHandlers.__dict__)
        #self['entryDir'].set_text('/home/jdhunter/python/examples/vtk/images/')
        self.outDim = 256, 256
        
        self.viewer = vtk.vtkImageViewer()
        
        self.preview = GtkGLExtVTKRenderWindow()
        self.preview.set_size_request(self.outDim[0], self.outDim[1])
        self.preview.show()

        self.renderer = self.viewer.GetRenderer()
        self.preview.GetRenderWindow().AddRenderer(self.renderer)
        self['vboxPreview'].pack_start(self.preview, False, False)
        self['vboxPreview'].reorder_child(self.preview, 1)
开发者ID:alexsavio,项目名称:nidoodles,代码行数:27,代码来源:image_reader.py


示例2: viewVtk

def viewVtk(mat):
    import vtk

    imageData = vtk.vtkImageData()
    imageData.SetDimensions(mat.shape[0], mat.shape[1], 1)
    imageData.SetScalarTypeToUnsignedShort()
    imageData.SetNumberOfScalarComponents(1)
    imageData.AllocateScalars()

    viewer = vtk.vtkImageViewer()
    viewer.SetInput(imageData)
    viewer.SetZSlice(0)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(viewer.GetRenderWindow())

    iren.Initialize()
    iren.Start()

    imageData = vtk.vtkImageSinusoidSource()
    imageData.SetWholeExtent(0, 300, 0, 300, 0, 10)
    imageData.SetAmplitude(63)
    imageData.SetDirection(1, 1, 0)
    imageData.SetPeriod(25)

    viewer = vtk.vtkImageViewer()
    viewer.SetInput(imageData.GetOutput())
    viewer.SetColorWindow(126)
    viewer.SetColorLevel(0)
    viewer.SetZSlice(0)

    def hamschti(obj, event):
        print "Haam:"
        print obj
        print event

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(viewer.GetRenderWindow())
    iren.Initialize()

    interactor = vtk.vtkInteractorStyleImage()
    ##interactor.AddObserver('LeftButtonPressEvent', hamschti)
    iren.SetInteractorStyle(interactor)

    iren.Start()
开发者ID:r35krag0th,项目名称:pysparse,代码行数:45,代码来源:spmatrix_util.py


示例3: View

def View(imagedata):
    viewer = vtk.vtkImageViewer()
    viewer.SetInput(imagedata)
    viewer.SetColorWindow(200)
    viewer.SetColorLevel(100)
    viewer.Render()

    import time
    time.sleep(10)
开发者ID:paulojamorim,项目名称:invesalius3,代码行数:9,代码来源:imagedata_utils.py


示例4: __getattr__

 def __getattr__(self, attr):
     # because the tk part of vtkTkImageViewerWidget must have
     # the only remaining reference to the ImageViewer when
     # it is destroyed, we can't actually store the ImageViewer
     # as an attribute but instead have to get it from the tk-side
     if attr == "_ImageViewer":
         addr = self.tk.call(self._w, "GetImageViewer")[5:]
         return vtk.vtkImageViewer("_%s_vtkImageViewer_p" % addr)
     raise AttributeError, self.__class__.__name__ + " has no attribute named " + attr
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:9,代码来源:vtkTkImageViewerWidget.py


示例5: slotShowDICOMImage

    def slotShowDICOMImage(self, item):
        reader = vtkgdcm.vtkGDCMImageReader()
        dicom_file = unicode(item.data(QtCore.Qt.UserRole).toString())
        reader.SetFileName(dicom_file)
        reader.Update()

        imageViewer = vtk.vtkImageViewer()
        imageViewer.SetInputConnection(reader.GetOutputPort())

        self.qvtkWidget.SetRenderWindow(imageViewer.GetRenderWindow())
        imageViewer.SetupInteractor(self.qvtkWidget.GetRenderWindow().GetInteractor())

        #imageViewer.SetColorLevel(128)
        #imageViewer.SetColorWindow(256)
        imageViewer.SetSize(self.qvtkWidget.geometry().width(), self.qvtkWidget.geometry().height())
开发者ID:avontd2868,项目名称:EHR,代码行数:15,代码来源:ehrnewrecordwindow.py


示例6: __init__

    def __init__(self, master, cnf={}, **kw):
        """
        Constructor.

        Keyword arguments:

          iv -- Use passed image viewer instead of creating a new one.

          double -- If True, generate a double-buffered viewer.
          Defaults to False.

          focus_on_enter -- If True, use a focus-follows-mouse mode.
          Defaults to False where the widget will use a click-to-focus
          mode.
        """
        # load the necessary extensions into tk
        vtkLoadPythonTkWidgets(master.tk)

        try: # use specified vtkImageViewer
            imageViewer = kw['iv']
        except KeyError: # or create one if none specified
            imageViewer = vtk.vtkImageViewer()

        doubleBuffer = 0
        try:
            if kw['double']:
                doubleBuffer = 1
            del kw['double']
        except:
            pass
 
        # check if focus should follow mouse
        if kw.get('focus_on_enter'):
            self._FocusOnEnter = 1
            del kw['focus_on_enter']
        else:
            self._FocusOnEnter = 0

        kw['iv'] = imageViewer.GetAddressAsString("vtkImageViewer")
        Tkinter.Widget.__init__(self, master, 'vtkTkImageViewerWidget',
                                cnf, kw)
        if doubleBuffer:
            imageViewer.GetRenderWindow().DoubleBufferOn()

        self.BindTkImageViewer()
开发者ID:SRabbelier,项目名称:Casam,代码行数:45,代码来源:vtkTkImageViewerWidget.py


示例7: initGUI

    def initGUI(self):
        QtGui.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setWindowTitle("Simple Dicom Viewer")

        #self.dicomReader = vtk.vtkDICOMImageReader()
        #self.dicomReader = vtkgdcm.vtkGDCMImageReader()
        self.show()

        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.ui.numpyLayout.addWidget(self.toolbar)
        self.ui.numpyLayout.addWidget(self.canvas)



        self.vtkWidget = QVTKRenderWindowInteractor(self.ui.imageFrame)
        self.vtkWidget.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        #self.ui.imageLayout.removeWidget(self.ui.dicomSlider)
        self.ui.imageLayout.addWidget(self.vtkWidget)
        #self.ui.imageLayout.addWidget(self.ui.dicomSlider)

        self.disableSlider()

        self.viewer= vtk.vtkImageViewer()
        #self.viewer.SetupInteractor(MyInteractor())
        self.vtkWidget.GetRenderWindow().AddRenderer(self.viewer.GetRenderer())
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
        #self.iren.SetRenderWindow(self.vtkWidget.GetRenderWindow())


        self.drag = False
        self.measuring = False
        self.iren.AddObserver("LeftButtonPressEvent", self.leftClick)
        self.iren.AddObserver("LeftButtonReleaseEvent", self.leftRelease)
        self.iren.AddObserver("EnterEvent", self.mouseEntered)
        self.iren.AddObserver("LeaveEvent", self.mouseLeft)
        self.iren.AddObserver("MouseMoveEvent", self.mouseMoved)
开发者ID:Nefarin,项目名称:SODM,代码行数:40,代码来源:AppWindow.py


示例8: processing

magnify2.SetInputConnection(reader.GetOutputPort())
magnify2.SetMagnificationFactors(IMAGE_MAG_X, IMAGE_MAG_Y, IMAGE_MAG_Z)
magnify2.ReleaseDataFlagOn()

# a filter that does in place processing (magnify ReleaseDataFlagOn)
cursor = vtk.vtkImageCursor3D()
cursor.SetInputConnection(magnify1.GetOutputPort())
cursor.SetCursorPosition(CURSOR_X * IMAGE_MAG_X,
                          CURSOR_Y * IMAGE_MAG_Y,
                          CURSOR_Z * IMAGE_MAG_Z)
cursor.SetCursorValue(255)
cursor.SetCursorRadius(50 * IMAGE_MAG_X)

# stream to increase coverage of in place filter.
# put the two together in one image
imageAppend = vtk.vtkImageAppend()
imageAppend.SetAppendAxis(0)
imageAppend.AddInputConnection(magnify2.GetOutputPort())
imageAppend.AddInputConnection(cursor.GetOutputPort())

viewer = vtk.vtkImageViewer()
viewer.SetInputConnection(imageAppend.GetOutputPort())
viewer.SetZSlice(CURSOR_Z * IMAGE_MAG_Z)
viewer.SetColorWindow(200)
viewer.SetColorLevel(80)
# viewer DebugOn
viewer.Render()
viewer.SetPosition(50, 50)
# make interface
viewer.Render()
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:30,代码来源:TestInPlaceFilter.py


示例9: SetUp

    def SetUp(self):
        """
        Set up cursor3D
        """

        def OnClosing():
            self.root.quit()

        def ViewerDown(tkvw):
            viewer = tkvw.GetImageViewer()
            ViewerSetZSlice(tkvw, viewer.GetZSlice() - 1)

        def ViewerUp(tkvw):
            viewer = tkvw.GetImageViewer()
            ViewerSetZSlice(tkvw, viewer.GetZSlice() + 1)

        def ViewerSetZSlice(tkvw, z):
            viewer = tkvw.GetImageViewer()
            viewer.SetZSlice(z)
            txt = "slice: " + str(z)
            sliceLabel.configure(text=txt)
            tkvw.Render()

        def SetCursorFromViewer(event):
            x = int(event.x)
            y = int(event.y)
            # We have to flip y axis because tk uses upper right origin.
            self.root.update_idletasks()
            height = int(self.tkvw.configure()["height"][4])
            y = height - y
            z = self.tkvw.GetImageViewer().GetZSlice()
            SetCursor(x / IMAGE_MAG_X, y / IMAGE_MAG_Y, z / IMAGE_MAG_Z)

        def SetCursor(x, y, z):

            CURSOR_X = x
            CURSOR_Y = y
            CURSOR_Z = z

            axes.SetOrigin(CURSOR_X, CURSOR_Y, CURSOR_Z)
            imageCursor.SetCursorPosition(CURSOR_X * IMAGE_MAG_X, CURSOR_Y * IMAGE_MAG_Y, CURSOR_Z * IMAGE_MAG_Z)

            self.viewer.Render()
            self.tkrw.Render()

        # Pipeline stuff.
        reader = vtk.vtkSLCReader()
        reader.SetFileName(VTK_DATA_ROOT + "/Data/neghip.slc")
        # Cursor stuff

        magnify = vtk.vtkImageMagnify()
        magnify.SetInputConnection(reader.GetOutputPort())
        magnify.SetMagnificationFactors(IMAGE_MAG_X, IMAGE_MAG_Y, IMAGE_MAG_Z)

        imageCursor = vtk.vtkImageCursor3D()
        imageCursor.SetInputConnection(magnify.GetOutputPort())
        imageCursor.SetCursorPosition(CURSOR_X * IMAGE_MAG_X, CURSOR_Y * IMAGE_MAG_Y, CURSOR_Z * IMAGE_MAG_Z)
        imageCursor.SetCursorValue(255)
        imageCursor.SetCursorRadius(50 * IMAGE_MAG_X)

        axes = vtk.vtkAxes()
        axes.SymmetricOn()
        axes.SetOrigin(CURSOR_X, CURSOR_Y, CURSOR_Z)
        axes.SetScaleFactor(50.0)

        axes_mapper = vtk.vtkPolyDataMapper()
        axes_mapper.SetInputConnection(axes.GetOutputPort())

        axesActor = vtk.vtkActor()
        axesActor.SetMapper(axes_mapper)
        axesActor.GetProperty().SetAmbient(0.5)

        # Image viewer stuff.
        viewer = vtk.vtkImageViewer()
        viewer.SetInputConnection(imageCursor.GetOutputPort())
        viewer.SetZSlice(CURSOR_Z * IMAGE_MAG_Z)
        viewer.SetColorWindow(256)
        viewer.SetColorLevel(128)

        # Create transfer functions for opacity and color.
        opacity_transfer_function = vtk.vtkPiecewiseFunction()
        opacity_transfer_function.AddPoint(20, 0.0)
        opacity_transfer_function.AddPoint(255, 0.2)

        color_transfer_function = vtk.vtkColorTransferFunction()
        color_transfer_function.AddRGBPoint(0, 0, 0, 0)
        color_transfer_function.AddRGBPoint(64, 1, 0, 0)
        color_transfer_function.AddRGBPoint(128, 0, 0, 1)
        color_transfer_function.AddRGBPoint(192, 0, 1, 0)
        color_transfer_function.AddRGBPoint(255, 0, 0.2, 0)

        # Create properties, mappers, volume actors, and ray cast function.
        volume_property = vtk.vtkVolumeProperty()
        volume_property.SetColor(color_transfer_function)
        #         volume_property.SetColor(color_transfer_function[0],
        #                                  color_transfer_function[1],
        #                                  color_transfer_function[2])
        volume_property.SetScalarOpacity(opacity_transfer_function)

        volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()
#.........这里部分代码省略.........
开发者ID:Kitware,项目名称:VTK,代码行数:101,代码来源:cursor3D.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkIntArray函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkImageThreshold函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap