[vtkusers] How extract a 2D slice from a volume using vtkImageReslice??

Amy Squillacote amy.squillacote at kitware.com
Tue Aug 30 08:34:29 EDT 2005


At 03:36 AM 8/30/2005, adexe wrote:
>Hi Adexe,
>
>Use the SetZSlice method in vtkImageViewer.
>
>- Amy
>
>
>
>Thanks Ami, but I want to extract a slice x, y or z to view 
>it...then I'll try to process it and apply operations such as 
>erosion dilation, erosion and thresholding.
>
>
>thanks in advance.
>
>-Adexe

Then try vtkExtractVOI, and set the VOI (extent) appropriately to 
extract the slice you want.
- Amy


>/At 07:30 AM 8/29/2005, adexe wrote:
>
>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. /
>_______________________________________________
>This is the private VTK discussion list. Please keep messages 
>on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list