[vtkusers] correction of spacing

Mathieu Malaterre mathieu.malaterre at gmail.com
Tue Nov 25 08:22:35 EST 2008

On Tue, Nov 25, 2008 at 8:24 AM, Bartosz Wiklak <bwiklak at gmail.com> wrote:
>> Plug a vtkImageChangeInformation object into your pipeline right after your reader. It'll look something like:
>> vtkImageChangeInformation *changer = vtkImageChangeInformation::New();
>> changer->SetOutputSpacing(xSpacing, ySpacing, zSpacing);
>> changer->SetInputConnection(reader->GetOutputPort());
>> ...
>> vtkImageReslice *reslice = vtkImageReslice::New();
>> reslice->SetInputConnection(changer->GetOutputPort());
>> Hope that helps,
> Yes, that is what I needed!

No, this is not what you should be doing.

> I find it quite confusing that SetSpacing does not work as I (new
> user) expected.

VTK is demand driven. If you setup the pipeline you expect it to
re-execute as you set it up.

So set up your VTK pipeline to change the spacing anytime you reexecute.


  // You need to use this class to preserve spacing
  // across pipeline re-execution
  vtkImageChangeInformation *change = vtkImageChangeInformation::New();
  change->SetInput( reader2->GetOutput() );
  change->SetOutputSpacing( spacing2[0], spacing2[1], ippzspacing );

> I don't thing this is gdcm issue, it has nothing to do with dicom. Of
> course it would be better if the reader had proper spacing at the
> beginning.
> This question was stated several times on vtk forum and I did not
> found the wright answer.
> Maybe this case should be stretch out on some FAQ?


More information about the vtkusers mailing list