vtkImageActor

vtkImageActor is used to display picture in 3D render window.
By changing the interactor to a vtkInteractorStyleImage you can limit rotations so that user can operate the 3D render window as a 2D image viewer.


python code:

import vtk

fileName = "/Users/weiyang/Desktop/Untitled.png"
reader = vtk.vtkPNGReader()
reader.SetFileName( fileName )
reader.Update()

actor = vtk.vtkImageActor()
actor.SetInputData( reader.GetOutput() )

ren = vtk.vtkRenderer()
ren.AddActor( actor )

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer( ren )

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow( renWin )
iren.Initialize()

iStyle = vtk.vtkInteractorStyleImage()
iren.SetInteractorStyle( iStyle )

ren.AddActor( actor )
renWin.SetSize( 400, 400 )
renWin.Render()
ren.ResetCameraClippingRange()
renWin.Render()

iren.Start()

vtkImagePlaneWidget

vtkImagePlaneWidget can change position and orientation manually. User can reslice data with different methods such as VTK_NEAREST_RESLICE, VTK_LINEAR_RESLICE, and VTK_CUBIC_RESLICE.
Add the following code before AddActor in the above example.

planeWidgetX = vtk.vtkImagePlaneWidget()
planeWidgetX.SetInteractor( iren )
planeWidgetX.RestrictPlaneToVolumeOn()
planeWidgetX.SetResliceInterpolateToNearestNeighbour()
planeWidgetX.SetInputData( reader.GetOutput() )
planeWidgetX.SetPlaneOrientationToZAxes()
planeWidgetX.SetSliceIndex( 0 )
planeWidgetX.DisplayTextOn()
planeWidgetX.SetResliceInterpolateToNearestNeighbour()
planeWidgetX.On()

An interesting thing to notice is that planeWidgetX need not be added to the renderer as vtkActor object because it’s a widget.


Relevant functions about displaying left-bottom coordinate value are in the following section.

void vtkImagePlaneWidget::ProcessEvents(vtkObject* vtkNotUsed(object),
                                        unsigned long event,
                                        void* clientdata,
                                        void* vtkNotUsed(calldata))

void vtkImagePlaneWidget::OnLeftButtonDown()

void vtkImagePlaneWidget::StartCursor()

void vtkImagePlaneWidget::ManageTextDisplay()

The fourth value in the coordinate result on the gif is CurrentImageValue.
The comment of int vtkImagePlaneWidget::UpdateContinuousCursor(double *q) has mentioned that this->CurrentImageValue = outPD->GetScalars()->GetTuple1(0);, so it has relationship with scalar.

 


0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x