[vtkusers] vtkDistanceWidget and Dicom Images

John Drescher drescherjm at gmail.com
Tue Oct 19 14:30:39 EDT 2010


On Tue, Oct 19, 2010 at 2:06 PM, Leonardo M. Ramé <l.rame at griensu.com> wrote:
> On 2010-10-19 13:53:19 -0400, David Doria wrote:
>> >
>> > I'm going crazy trying to find an example on the web, could you give me
>> > one?
>>
>>
>> This explains the filter:
>> http://www.vtk.org/doc/nightly/html/classvtkImageChangeInformation.html
>>
>> And this demonstrates it:
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CenterAnImage
>>
>> David
>
> Thanks, after checking the examples I come up with this:
>
> // get pixel spacing and apply to image
> double lPixelSpacing;
> m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
> m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing,lPixelSpacing);
>
> // change image information
> vtkImageChangeInformation * in = vtkImageChangeInformation::New();
> in->SetInput(m_imageDataVTK);
> in->SetOutputSpacing(1.0, 1.0, 1.0);
> in->Update();
> m_imageDataVTK = in->GetOutput();
> ...
>
> Aparently in->SetOutputSpacing is reverting the changes that SetSpacing
> did. The measurement is multiplied by 5 (1 / 0.20), and I'm getting the
> same results like if I don't apply SetSpacing.
>
> Any hint?

Wait a minute. I meant that you need to set your spacing with
vtkImageChangeInformation only. So in this case you need to specify
0.20 not 1.0. You should not use SetSpacing on images directly because
the pipeline will reset the change the next update.

John



More information about the vtkusers mailing list