[vtkusers] vtkDistanceWidget and Dicom Images

John Drescher drescherjm at gmail.com
Tue Oct 19 14:26:11 EDT 2010


On Tue, Oct 19, 2010 at 2:11 PM, John Drescher <drescherjm at gmail.com> wrote:
> 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?
>>
>
> Don't create a loop. Put the vtkImageChangeInformation right after the
> reader and before it gets to m_imageDataVTK.
>

Wait a minute. I am doing that myself with this code. That works..

if (fZAxisSpacing > 0.0) {
	double spacing[3];
	m_pImage->GetSpacing(spacing);
	pChangeInfo->SetInput(m_pImage);
	spacing[2] = fZAxisSpacing;
	pChangeInfo->SetOutputSpacing(spacing);
	pChangeInfo->Update();
	m_pImage = pChangeInfo->GetOutput();
}

This changes the z axes spacing because the vtkGDCMImageReader that I
use does not get the spacing correct in that direction for all image
types that I need to read.

John



More information about the vtkusers mailing list