[vtkusers] How extract a 2D slice from a volume using vtkImageReslice??
adexe
adexe at ctm.ulpgc.es
Mon Aug 29 07:30:11 EDT 2005
Hi, I'm trying to extract a 2D slice from a volume but it's not
working...
I've:
reader
(vtkImageReader)---volume_view(vtkImageData)---reslice(vtkImageReslice)---viewer(vtkImageViewer)
I'want to extract only a slice from volume and view it! The next code is
an example of what I was trying to do. The number of z slice I want to
cut in the following code is 40:
/
/
/
/
/package require vtk/
/package require vtkinteraction/
/
/
/
/
/vtkImageReader reader/
/ reader SetDataByteOrderToLittleEndian/
/ reader SetDataScalarTypeToUnsignedShort/
/ reader SetFilePattern "%s.%03d"/
/ reader SetFilePrefix "/mnt/home/adexe/exeda/data/Images/I"/
/ reader SetDataExtent 0 255 0 255 1 160/
/ reader Update/
/
/
/
vtkImageData volume_view /
/ volume_view ShallowCopy [reader GetOutput]/
/
/
/vtkImageReslice reslice/
/
/
/
vtkMatrix4x4 axesTransform/
/ /
/ axesTransform Identity/
/ #x axis column/
/ axesTransform SetElement 0 0 0/
/ axesTransform SetElement 1 0 1/
/ axesTransform SetElement 2 0 40/
/ axesTransform SetElement 3 0 0.0/
/ #y axis column/
/ axesTransform SetElement 0 1 1/
/ axesTransform SetElement 1 1 0/
/ axesTransform SetElement 2 1 40/
/ axesTransform SetElement 3 1 0.0/
/ #z axis column/
/ axesTransform SetElement 0 2 0/
/ axesTransform SetElement 1 2 0/
/ axesTransform SetElement 2 2 1/
/ axesTransform SetElement 3 2 0.0/
/ #origin column/
/package require vtk/
/package require vtkinteraction/
/
/
/
/
/vtkImageReader reader/
/ reader SetDataByteOrderToLittleEndian/
/ reader SetDataScalarTypeToUnsignedShort/
/ reader SetFilePattern "%s.%03d"/
/ reader SetFilePrefix "/mnt/home/adexe/exeda/data/Images/I"/
/ reader SetDataExtent 0 255 0 255 1 160/
/ reader Update/
/
/
/
vtkImageData volume_view /
/ volume_view ShallowCopy [reader GetOutput]/
/
/
/vtkImageReslice reslice/
/
/
/
vtkMatrix4x4 axesTransform/
/ /
/ axesTransform Identity/
/ #x axis column/
/ axesTransform SetElement 0 0 0/
/ axesTransform SetElement 1 0 1/
/ axesTransform SetElement 2 0 40/
/ axesTransform SetElement 3 0 0.0/
/ #y axis column/
/ axesTransform SetElement 0 1 1/
/ axesTransform SetElement 1 1 0/
/ axesTransform SetElement 2 1 40/
/ axesTransform SetElement 3 1 0.0/
/ #z axis column/
/ axesTransform SetElement 0 2 0/
/ axesTransform SetElement 1 2 0/
/ axesTransform SetElement 2 2 1/
/ axesTransform SetElement 3 2 0.0/
/ #origin column/
/ axesTransform SetElement 0 3 0/
/ axesTransform SetElement 1 3 0/
/ axesTransform SetElement 2 3 40/
/ axesTransform SetElement 3 3 1.0/
/
reslice SetResliceAxes axesTransform/
/ reslice SetInput volume_view/
/ reslice SetOutputExtent 0 255 0 255 0 0/
/ /
/
vtkImageViewer viewer/
/ viewer SetInput [reslice GetOutput]/
/ viewer SetColorLevel 1000/
/ viewer SetColorWindow 800/
/ viewer Render/
/
/
/ axesTransform SetElement 0 3 0/
/ axesTransform SetElement 1 3 0/
/ axesTransform SetElement 2 3 40/
/ axesTransform SetElement 3 3 1.0/
/
reslice SetResliceAxes axesTransform/
/ reslice SetInput volume_view/
/ reslice SetOutputExtent 0 255 0 255 0 0/
/ /
/
vtkImageViewer viewer/
/ viewer SetInput [reslice GetOutput]/
/ viewer SetColorLevel 1000/
/ viewer SetColorWindow 800/
/ viewer Render/
/
/
Thanks in advance.
Adexe.
More information about the vtkusers
mailing list