[Insight-users] [vtkusers] BUG IN vtkImageReslice

Lodron, Gerald Gerald.Lodron at joanneum.at
Thu Jan 14 10:54:37 EST 2010




Hi,

My code is very complicated and too large for a small visualization, but i simple make these steps:


I have two grayscale 3D CT images, convert them from signed short to float and register them with an ITK demon registration filter. The output (the deformation field) is of DeformationFieldType

typedef typename itk::Vector< float, 3 >								VectorPixelType;
typedef typename itk::OrientedImage<  VectorPixelType, 3 >					DeformationFieldType;

So a three dimensional vector image. The result must be right because when I wrap the source image the registration looks good. Now i wanted to display this deformation field, therefor i converted it to vtk using itk::ImageToVTKImageFilter<DeformationFieldType>. The output is a vtkImageData object with 3 dimension and 3 components.

I want to visualize the stuff using a 2D cut plane through the 3D data, so i am using vtkImageReslice (i did it already to visualize my 3d grayscale CT image and it worked). So i used it as following:


	Int a = vtkImageDataOfDeformation->GetNumberOfScalarComponents();//=3

	m_DeformationReslice = vtkImageReslice::New();
	m_DeformationReslice->SetOutputDimensionality(2);
	m_DeformationReslice->SetInterpolationModeToLinear();
	m_DeformationReslice->SetInput(vtkImageDataOfDeformation);
	m_DeformationReslice->SetResliceAxes(myResliceAxis);
 
	Int b = DeformationReslice->GetOutput()->GetNumberOfScalarComponents();//=1


Also note that the vtkImageData has an Origin, pixel spacing etc. from the dicom.

Now i use this workaround which works:

		m_DeformationExtractorX = vtkImageExtractComponents::New();
		m_DeformationExtractorX->SetInputConnection(vtkImageDataOfDeformation->GetProducerPort());
		m_DeformationExtractorX->SetComponents(0);

		m_DeformationExtractorY = vtkImageExtractComponents::New();
		m_DeformationExtractorY->SetInputConnection(m_vtkImageDataOfDeformation->GetProducerPort());
		m_DeformationExtractorY->SetComponents(1);

		m_DeformationExtractorZ = vtkImageExtractComponents::New();
		m_DeformationExtractorZ->SetInputConnection(m_vtkImageDataOfDeformation->GetProducerPort());
		m_DeformationExtractorZ->SetComponents(2);

		m_DeformationResliceX = vtkImageReslice::New();
		m_DeformationResliceX->SetOutputDimensionality(2);
		m_DeformationResliceX->SetInterpolationModeToLinear();
		m_DeformationResliceX->SetInput(m_DeformationExtractorX->GetOutput());
		m_DeformationResliceX->SetResliceAxes(myResliceAxis);

		m_DeformationResliceY = vtkImageReslice::New();
		m_DeformationResliceY->SetOutputDimensionality(2);
		m_DeformationResliceY->SetInterpolationModeToLinear();
		m_DeformationResliceY->SetInput(m_DeformationExtractorY->GetOutput());
		m_DeformationResliceY->SetResliceAxes(myResliceAxis);

		m_DeformationResliceZ = vtkImageReslice::New();
		m_DeformationResliceZ->SetOutputDimensionality(2);
		m_DeformationResliceZ->SetInterpolationModeToLinear();
		m_DeformationResliceZ->SetInput(m_DeformationExtractorZ->GetOutput());
		m_DeformationResliceZ->SetResliceAxes(myResliceAxis);
		
		m_DeformationAppend1 = vtkImageAppendComponents::New();
		m_DeformationAppend1->SetInput(0,m_DeformationResliceX->GetOutput());
		m_DeformationAppend1->SetInput(1,m_DeformationResliceY->GetOutput());

		m_DeformationAppend2 = vtkImageAppendComponents::New();
		m_DeformationAppend2->SetInput(0,m_DeformationAppend1->GetOutput());
		m_DeformationAppend2->SetInput(1,m_DeformationResliceZ->GetOutput());

		vtkImageData* 2DSlice = m_DeformationAppend2->GetOutput();	//2D slice with 3d Vectors/Component image

Maybe you can send me your code?

I have also problems visualizing it with glyphs3D, i make such a strange thing:

		m_DeformationAppend2->GetOutput()->Update();
		m_DeformationAppend2->GetOutput()->GetPointData()->SetVectors(m_DeformationAppend2->GetOutput()->GetPointData()->GetScalars());
		m_DeformationAppend2->GetOutput()->GetPointData()->SetScalars(NULL);

To convert the stuff into a vector image, any ideas how to make that better?

		m_Arrow = vtkArrowSource::New();
		m_DeformationGlyph = vtkGlyph3D::New();
		m_DeformationGlyph->SetInput(m_DeformationAppend2->GetOutput());
		m_DeformationGlyph->SetScaleModeToScaleByVector();
		m_DeformationGlyph->SetColorModeToColorByVector();  
		m_DeformationGlyph->OrientOn();
		m_DeformationGlyph->SetVectorModeToUseVector();
		m_DeformationGlyph->ClampingOff();
		m_DeformationGlyph->SetSourceConnection( m_Arrow->GetOutputPort() );

		m_DeformationMapper = vtkPolyDataMapper::New();
		m_DeformationMapper->SetInputConnection(m_DeformationGlyph->GetOutputPort());

		m_DeformationActor = vtkActor::New();
		m_DeformationActor->SetMapper(m_DeformationMapper);
		m_Renderer->AddActor(m_DeformationActor);

		GetRenderWindow()->Render();
	
		m_Interactor->Initialize();

Would be great if you could give me some tipps!

 

-----Ursprüngliche Nachricht-----
Von: David Gobbi [mailto:david.gobbi at gmail.com] 
Gesendet: Donnerstag, 14. Jänner 2010 16:28
An: Lodron, Gerald
Cc: vtkusers at vtk.org
Betreff: Re: [vtkusers] BUG IN vtkImageReslice

Hi Gerald,

Can you send a short program that demonstrates this bug?  I use vtkImageReslice on multi-component data all the time, and I have never seen anything like this.

  David


On Thu, Jan 14, 2010 at 5:55 AM, Lodron, Gerald <Gerald.Lodron at joanneum.at> wrote:
>
> Hello
>
> I use a vtkImageReslice to slice a vtkImageData with 3 scalar components. The result/output only has one sinlge component instead of three.
>
> Best regards


More information about the Insight-users mailing list