[vtkusers] VTK Model and ITKImageBase itkImage_UC3
David Gobbi
david.gobbi at gmail.com
Sat Nov 20 19:42:47 EST 2010
Hi Sam,
A filter will update whenever its own Update() is called, or when the
Update() method of a downstream filter or data object is called. So, for
example, calling Update() on vtkImageAccumulate() will also call Update() on
the filters before it. Every time Update() is called on a filter, the
filter checks its internal timestamps and only re-executes if some parameter
has changed since its last execution.
Now... about the crash, vtkPolyDataToImageStencil needs to have its Extent
set before it is updated, so that it knows how large of a stencil to create.
This is going to be fixed in the next VTK release. It will get its extent
from its downstream filter (in this case, vtkImageAccumulate) so if you call
Update on vtkImageAccumulate, without calling Update on
vtkPolyDataToImageStencil, then everything should work. If not, you can set
the Extent of vtkPolyDataToImageStencil explicitly:
dicomImage.Update()
modelStencilPolyData.SetOutputWholeExtent(dicomImage.GetDataExtent())
You will want to print the result of GetDataExtent(), because I am not 100%
certain that vtkDICOMReader sets it. The other thing you need to be certain
of is that your model and your DICOM image are in the same coordinate
system. You can call GetOutput().GetBounds() on both of them to make sure
that they cover approximately the same region of physical space.
David
On Sat, Nov 20, 2010 at 5:22 PM, Sam <sistephan at gmail.com> wrote:
>
> David,
>
> Please review my code and let me know if you see something wrong.
>
> Two Issues
> 1. The Update() methods throws AccessViolation Exceptions (don't I need to
> call the update method for these filters to perform work? If not, then at
> what point does a filter peform its work?).
>
> 2. The VoxelCount is 0 which can't be correct.
>
>
> C# Code:
>
> vtkDataObject dicomDataObject = new vtkDataObject();
> vtkDICOMImageReader dicomImage = new vtkDICOMImageReader();
> dicomImage.SetDirectoryName("C:\\DICOMVolume");
> dicomImage.SetOutput(dicomDataObject);
> dicomImage.Update();
> string patientName = patientName = dicomImage.GetPatientName();
> Console.WriteLine("Patient Name: {0} ", patientName); //Prints
> name correctly
>
> vtkPolyDataToImageStencil modelStencilPolyData = new
> vtkPolyDataToImageStencil();
> modelStencilPolyData.SetInput(model); //model is a PolyData
> Object.
>
> modelStencilPolyData.SetOutputSpacing(dicomImage.GetPixelSpacing());
>
> modelStencilPolyData.SetOutputOrigin(dicomImage.GetDataOrigin());
> //modelStencilPolyData.Update(); causes access violation error
>
> vtkImageStencilData modelImageStencil =
> modelStencilPolyData.GetOutput();
>
> vtkImageAccumulate modelAccumulate = new vtkImageAccumulate();
> modelAccumulate.SetInput(dicomDataObject);
> modelAccumulate.SetStencil(modelImageStencil);
> //modelAccumulate.Update(); causes access violation error
>
> int voxelCount = modelAccumulate.GetVoxelCount();
> Console.WriteLine("Voxel Count: {0} ", voxelCount); //Prints
> Zero (Problem!!)
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/VTK-Model-and-ITKImageBase-itkImage-UC3-tp3273888p3274004.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101120/826906e7/attachment.htm>
More information about the vtkusers
mailing list