../vtkSource/contrib/examplesTcl/TestReslice.tcl

Jon Klingensmith klingej at bme.ri.ccf.org
Mon Feb 28 11:23:07 EST 2000


I am trying to use vtkImageReslice to view various slices in a volume of
data.  However, in the TestReslice.tcl example, the rotations are
performed once on the data and then the vtkImageViewer::SetZSlice method
is used to slice through the data with a slider control.  Is it possible
to use vtkImageReslice in this same way, but control the rotation angles
interactively? I have set up a pipeline and interface to do this, but
the rotations do not work in the manner I expected.  The z rotation
works fine, but if I change x and y, the data rotates right out of the
field of view.  However, if I just change the rotation in the pipeline
manually, it works correctly and I can slice through the data at any x,
y, or z angle, I just haven't been able to control the angles
interactively.

Can anyone help me with this?  My pipeline is attached below with the
tcl/tk interface also.

Thanks,
Jon

---------------------------------------------------------------------------------

catch {load vtktcl}
# Simple viewer for images.

source vtkImageInclude.tcl

set xRot 0
set yRot 0
set zRot 0

# Image pipeline
vtkImageReader reader
 reader ReleaseDataFlagOff
 reader SetDataByteOrderToLittleEndian
 reader SetFileDimensionality 3
 reader SetDataExtent 0 63 0 63 0 255
 reader SetDataOrigin -32 -32 -128
 reader SetDataSpacing 1.0 1.0 0.24
 reader SetFileName "us3_proba.vol"
 reader SetDataScalarTypeToUnsignedChar
 reader UpdateWholeExtent

vtkTransform transform
 transform RotateX $xRot
 transform RotateY $yRot
 transform RotateZ $zRot

vtkImageReslice reslice
 reslice SetInput [reader GetOutput]
 reslice SetResliceTransform transform
 reslice InterpolateOn
 reslice SetOutputSpacing 0.3 0.3 0.3
 reslice SetBackgroundLevel 127

vtkImageViewer viewer
 viewer SetInput [reslice GetOutput]
 viewer SetZSlice 60
 viewer GrayScaleHintOn
 viewer SetColorWindow 255
 viewer SetColorLevel 127
 viewer Render

source Interface.tcl
#source Interface2.tcl
------------------------------------------------------------------------------------

# a simple user interface that manipulates window level.
# places in the tcl top window.  Looks for object named viewer

# Take window level parameters from viewer
proc InitializeInterface {} {
 global viewer sliceNumber xRot yRot zRot

 # Get parameters from viewer
 set w [viewer GetColorWindow]
 set l [viewer GetColorLevel]
 set sliceNumber [viewer GetZSlice]
 set zMin [viewer GetWholeZMin]
 set zMax [viewer GetWholeZMax]

 # frame for slice/window/level
 frame .image -borderwidth 3 -relief ridge
 label .image.l -text "Slice & Window/Level" \
  -borderwidth 2 -relief raised

 scale .image.slice -from $zMin -to $zMax -orient horizontal \
  -command SetSlice -variable sliceNumber -label slice

 scale .image.window -from 1 -to [expr $w * 2]  -orient horizontal \
  -command SetWindow -variable window -label window

 scale .image.level -from [expr $l - $w] -to [expr $l + $w] \
  -orient horizontal -command SetLevel -label level

 # resolutions less than 1.0
 if {$w < 10} {
  set res [expr 0.05 * $w]
  .image.window configure -resolution $res -from $res -to [expr 2.0 *
$w]
  .image.level configure -resolution $res \
   -from [expr 0.0 + $l - $w] -to [expr 0.0 + $l + $w]
 }

 .image.window set $w
 .image.level set $l
 pack .image.l .image.slice .image.window .image.level

 # frame for changing the rotation of data set
 frame .rotate -borderwidth 3 -relief ridge
 label .rotate.l -text "Rotation" \
  -borderwidth 2 -relief raised

 set xRotSlide $xRot
 set yRotSlide $yRot
 set zRotSlide $zRot

 scale .rotate.x -from -180 -to 180 -orient horizontal \
  -variable xRotSlide -command SetXRotate -label "x rotation"

 scale .rotate.y -from -180 -to 180 -orient horizontal \
  -variable yRotSlide -command SetYRotate -label "y rotation"

 scale .rotate.z -from -180 -to 180 -orient horizontal \
  -variable zRotSlide -command SetZRotate -label "z rotation"

 pack .rotate.l .rotate.x .rotate.y .rotate.z
 pack .image .rotate -side left

}

proc SetSlice slice {
 global viewer
 viewer SetZSlice $slice
 viewer Render
}

proc SetWindow window {
 global viewer
 viewer SetColorWindow $window
 viewer Render
}

proc SetLevel level {
 global viewer
 viewer SetColorLevel $level
 viewer Render
}

proc SetXRotate { rotate } {
 global viewer xRot yRot zRot
 transform RotateX [expr 0 - $xRot]
 transform RotateX $rotate
 set xRot $rotate
 reslice SetResliceTransform transform
 viewer Render
}

proc SetYRotate { rotate } {
 global viewer xRot yRot zRot
 transform RotateY [expr 0 - $yRot]
 transform RotateY $rotate
 set yRot $rotate
 reslice SetResliceTransform transform
 viewer Render
}

proc SetZRotate { rotate } {
 global viewer xRot yRot zRot
 transform RotateZ [expr 0 - $zRot]
 transform RotateZ $rotate
 set zRot $rotate
 reslice SetResliceTransform transform
 viewer Render
}

InitializeInterface
viewer Render
----------------------------------------------------------------------------------



--
Jon D. Klingensmith
Department of Biomedical Engineering
The Cleveland Clinic Foundation
Lab Phone: 216-445-0591
http://www.lerner.ccf.org/bme/ip/


--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list