def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__( self, module_manager, vtk.vtkImageCheckerboard(), 'Processing.', ('vtkImageData', 'vtkImageData'), ('vtkImageData',), replaceDoc=True, inputFunctions=None, outputFunctions=None)
def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__(self, module_manager, vtk.vtkImageCheckerboard(), 'Processing.', ('vtkImageData', 'vtkImageData'), ('vtkImageData', ), replaceDoc=True, inputFunctions=None, outputFunctions=None)
def __init__(self, comedi, cfg_dict): self._comedi = comedi self._cfg = cfg_dict rwi,ren = comedi.get_compvis_vtk() self._sv = comedi_utils.CMSliceViewer(rwi, ren) comedi.sync_slice_viewers.add_slice_viewer(self._sv) self._cb = vtk.vtkImageCheckerboard() # we'll store our local bindings here self._d1 = None self._d2m = None
image1.FillBox(0,size,0,size) pad1 = vtk.vtkImageWrapPad() pad1.SetInputConnection(image1.GetOutputPort()) pad1.SetOutputWholeExtent(0,size,0,size,0,10) pad1.Update() image2 = vtk.vtkImageCanvasSource2D() image2.SetNumberOfScalarComponents(3) image2.SetScalarTypeToUnsignedChar() image2.SetExtent(0,size,0,size,0,0) image2.SetDrawColor(0,255,255) image2.FillBox(0,size,0,size) pad2 = vtk.vtkImageWrapPad() pad2.SetInputConnection(image2.GetOutputPort()) pad2.SetOutputWholeExtent(0,size,0,size,0,10) pad2.Update() checkers = vtk.vtkImageCheckerboard() checkers.SetInput1Data(pad1.GetOutput()) checkers.SetInput2Data(pad2.GetOutput()) checkers.SetNumberOfDivisions(11,6,0) mapper=vtk.vtkImageSliceMapper() mapper.SetInputConnection(checkers.GetOutputPort()) mapper.SliceAtFocalPointOn() mapper.SliceFacesCameraOn() imageSlice = vtk.vtkImageSlice() imageSlice.SetMapper(mapper) imageSlice.GetProperty().SetColorLevel(127.5) imageSlice.GetProperty().SetColorWindow(255) renderer=vtk.vtkRenderer() renderer.AddViewProp(imageSlice)
def initView(self, data, widget): image_type = data.getITKImageType() self.image = data.getITKImage() self.space = data.getResolution().tolist() if len(self.space) == 3: self.space = [float(x) / self.space[-1] for x in self.space] self.image.SetSpacing(self.space) self.rescale_filter = itk.RescaleIntensityImageFilter[image_type, image_type].New() self.rescale_filter.SetOutputMinimum(0) self.rescale_filter.SetOutputMaximum(255) self.rescale_filter.SetInput(self.image) self.itk_vtk_converter = itk.ImageToVTKImageFilter[image_type].New() self.itk_vtk_converter.SetInput(self.rescale_filter.GetOutput()) self.image_resample = vtk.vtkImageResample() self.image_resample.SetInput(self.itk_vtk_converter.GetOutput()) data = self.parent.getData() image_type = data.getITKImageType() self.image2 = data.getITKImage() self.space2 = data.getResolution().tolist() if len(self.space2) == 3: self.space2 = [float(x) / self.space2[-1] for x in self.space2] self.image2.SetSpacing(self.space2) shapeList = data.getData().shape y, x = shapeList[-2], shapeList[-1] self.dimension = len(shapeList) == 2 self.rescale_filter2 = itk.RescaleIntensityImageFilter[image_type, image_type].New() self.rescale_filter2.SetOutputMinimum(0) self.rescale_filter2.SetOutputMaximum(255) self.rescale_filter2.SetInput(self.image2) self.itk_vtk_converter2 = itk.ImageToVTKImageFilter[image_type].New() self.itk_vtk_converter2.SetInput(self.rescale_filter2.GetOutput()) self.image_resample2 = vtk.vtkImageResample() self.image_resample2.SetInput(self.itk_vtk_converter2.GetOutput()) self.checkers = vtk.vtkImageCheckerboard() self.checkers.SetInput1(self.image_resample.GetOutput()) self.checkers.SetInput2(self.image_resample2.GetOutput()) self.division = 3 self.checkers.SetNumberOfDivisions(self.division, self.division, 0) self.renderer = vtk.vtkRenderer() self.render_window = widget.GetRenderWindow() self.render_window.AddRenderer(self.renderer) self.reslice_mapper = vtk.vtkImageResliceMapper() self.reslice_mapper.SetInput(self.checkers.GetOutput()) self.reslice_mapper.SliceFacesCameraOn() self.reslice_mapper.SliceAtFocalPointOn() self.reslice_mapper.JumpToNearestSliceOn() self.reslice_mapper.BorderOff() self.reslice_mapper.BackgroundOn() array = data.getData() self.minI = 0 self.maxI = 255 image_property = vtk.vtkImageProperty() image_property.SetColorWindow(self.maxI - self.minI) image_property.SetColorLevel((self.maxI + self.minI) / 2.0) image_property.SetAmbient(0.0) image_property.SetDiffuse(1.0) image_property.SetOpacity(1.0) image_property.SetInterpolationTypeToLinear() self.image_slice = vtk.vtkImageSlice() self.image_slice.SetMapper(self.reslice_mapper) self.image_slice.SetProperty(image_property) self.renderer.AddViewProp(self.image_slice) self.window_interactor = vtk.vtkRenderWindowInteractor() self.interactor_style = vtk.vtkInteractorStyleImage() self.interactor_style.SetInteractionModeToImage3D() self.window_interactor.SetInteractorStyle(self.interactor_style) self.render_window.SetInteractor(self.window_interactor) point_picker = vtk.vtkPointPicker() self.window_interactor.SetPicker(point_picker) self.render_window.GlobalWarningDisplayOff() self.render_window.Render() self.camera = self.renderer.GetActiveCamera() self.camera.ParallelProjectionOn() w, h = self.window_interactor.GetSize() if h * x * self.space[0] < w * y * self.space[1]: scale = y / 2.0 * self.space[1] else: scale = h * x * self.space[0] / 2.0 / w self.camera.SetParallelScale(scale) point = self.camera.GetFocalPoint() dis = self.camera.GetDistance() self.camera.SetViewUp(0, -1, 0) self.camera.SetPosition(point[0], point[1], point[2] - dis) self.renderer.ResetCameraClippingRange() # View of image self.view = 2 self.interactor_style.AddObserver("MouseMoveEvent", self.MouseMoveCallback) self.interactor_style.AddObserver("LeftButtonReleaseEvent", self.LeftButtonReleaseCallback) self.interactor_style.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback) self.interactor_style.AddObserver("MiddleButtonPressEvent", self.MiddleButtonPressCallback) self.interactor_style.AddObserver("RightButtonPressEvent", self.RightButtonPressCallback) self.interactor_style.AddObserver("RightButtonReleaseEvent", self.RightButtonReleaseCallback) self.interactor_style.AddObserver("KeyPressEvent", self.KeyPressCallback) self.interactor_style.AddObserver("CharEvent", self.CharCallback) self.updateAfter() self.render_window.Render()