[vtkusers] creating empty vtkImageData in Tcl

Marty Humperdink mhumperdink at yahoo.com
Sun Feb 1 23:18:50 EST 2009



Hello. I'm trying to roughly simulate resolution effects that might be seen when CT scanning an object. My thought was to do the following:

1. import an STL model of the object
2. create an empty vtkImageDate object (with extents chosen based on bounds of stl)
3. use vtkPolyDataToImageStencil and vtkImageStencil mask the STL onto the empty image data
4. then use vtkImageReslice to transform, change resolution, etc
5. use vtkContourFilter to make a new polydata model with "chunkiness" like from CT slice thickness, etc

I'm working in Tcl/Tk. A while back I wrote a similar little program to mask out a CT data with an imported STL. In that case I was reading in Dicom data. Now I seem to be having problems properly creating an empty/blank vtkImageData into which to stencil the STL.

       vtkSTLReader targetSTL  
targetSTL SetFileName $filenameTARGET
puts [[targetSTL GetOutput] GetBounds
#????? what is the correct way to get the model x,y,z bounds? Just getting 1 -1 1 -1 1 -1 here

       vtkImageDatamodelAsImage
modelAsImage SetDimensions 256 256 256
modelAsImage SetOrigin     0.0 0.0 0.0
modelAsImage SetSpacing    1.0 1.0 1.0
modelAsImage SetExtent    0 255 0 255 0 255
modelAsImage SetScalarTypeToUnsignedShort
modelAsImage AllocateScalars

set numBlanks [modelAsImage GetNumberOfPoints]

for {set i 0} {$i<$numBlanks} {incr i} {
[[modelAsImage GetPointData] GetScalars] SetTuple1 $i 0.0
}

vtkPolyDataToImageStencil stlToStencil
stlToStencil SetInput [targetSTL GetOutput]
vtkImageStencil stencil
stencil SetInput [modelAsImage GetOutput]     # ??????? This line gives an error - modelAsImage not established properly?
stencil SetStencil [stlToStencil GetOutput]
stencil ReverseStencilOn
stencil SetBackgroundValue 1000.0
vtkImageReslice reslice1
reslice1 SetInput [stencil GetOutput]
reslice1 SetResliceTransform initPoseTransf 
reslice1 SetInterpolationModeToCubic
reslice1 SetInformationInput [modelAsImage GetOutput] # ??????? This line gives an error - modelAsImage not established properly?

I'm having two problems. First, how can I get the bounds of the imported STL and set the extent of the vtkImageData to these values? When I try to use the GetBounds method -1 1 -1 1 -1 1 is returned - not correct for the imported model.

Second, I keep getting an error at the lines where I call [modelAsImage GetOutput] saying that the GetOutput method doesn't exist or is called with incorrect options. I've been thinking that I must not have created the empty vtkImageData properly. To test this I imported a set of Dicom data instead of trying to create an empty ImageData and it seemed to work (at least ran without errors). 

I would very much appreciate any suggestions. Thank you in advance.
Marty


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090201/76e519e1/attachment.htm>


More information about the vtkusers mailing list