[vtkusers] Re: vtkImagePlaneWidget problem on vtkImageData (C++)
dean.inglis at camris.ca
dean.inglis at camris.ca
Tue Nov 9 08:11:35 EST 2004
Adrian,
if you have tcl wrapping enabled for your vtk build,
(or you could convert to c++), try the following tcl
script for window/level interaction using vtkImageViewer2,
and maybe with your particular image data. Default
window level is usually calculated as:
double* range = image->GetScalaRange();
double window = range[1] - range[0];
double level = 0.5*(range[1] + range[0]);
So, depending on how the scalar values of your data
are distributed, the window level can be weighted
either too high or to low and the image will appear
initially "fogged", too dark (even black) or too light (even white).
Dean
#////////////////////////////////////////////////////////////////////////////////////
package require vtk
vtkBMPReader reader
reader SetFileName $VTK_DATA_ROOT/Data/masonry.bmp
# set the window/level
vtkImageViewer2 viewer
viewer SetInput [reader GetOutput]
viewer SetColorWindow 100.0
viewer SetColorLevel 127.5
vtkRenderWindowInteractor iren
[viewer GetRenderWindow] SetInteractor iren
viewer SetupInteractor iren
viewer Render
# here's how to interact:
# left mouse button left - right controls window
# left mouse button up - down controls level
# press "r" key resets the internal vtkImageMapToWindowLevelColors to its default w/l
# right button zooms image
# shift + "r" resets the zoom
More information about the vtkusers
mailing list