[Insight-users] Problem of transforming itk data to vtk.

jiang jiang at TI . Uni-Trier . DE
Wed, 1 Oct 2003 17:26:12 +0200


Hi, Luis,
In order to verify that the data converted from itk to vtk correctly, I
write out the converted data by vtkImageWriter. The code is:
	vtkImageWriter* writer = vtkImageWriter::New();
	writer->SetFileName("Importer");
	writer->SetInput(importer->GetOutput());//importer is vtkImageImport that
import data from itk to vtk.
	writer->SetFileDimensionality(3);
	writer->Write();

Then I read the "Importer" by VolView. The result rendered by VolView is not
correct. So I consider my pipeline from itk to vtk was wrong. However this
pipeline is exactly same as the Auxiliary\vtk\itkImageToVTKImageFilter, the
import part. I don't know how to modify it.
As your suggestion, I try to use itkImageToVTKImageFilter in my program
dirrectly. So I add itkImageToVTKImageFilter.h and
itkImageToVTKImageFilter.txx to my CMakeLists as below:

SET(MyProject_SRCS
... ...
itkImageToVTKImageFilter.txx
)

SET(MyProject_MOC_SRCS
... ...
itkImageToVTKImageFilter.h
)

Then I use itkImageToVTKImageFilter in my program:
	ImageToVTKImageFilter* connector=ImageToVTKImageFilter::New();
	connector->SetInput(reader->GetOutput());//reader is typedef
itk::ImageSeriesReader<ImageNDType>   ReaderType;
	ImageDataSet=vtkImageData::New();
	ImageDataSet=connector->GetOutput();

But some errors occor:
error C2065: 'ImageToVTKImageFilter' : undeclared identifier
 error C2065: 'connector' : undeclared identifier
 error C2653: 'ImageToVTKImageFilter' : is not a class or namespace name
 error C2065: 'New' : undeclared identifier
 error C2106: '=' : left operand must be l-value
 error C2227: left of '->SetInput' must point to class/struct/union
 error C2227: left of '->GetOutput' must point to class/struct/union

And the itkImageToVTKImageFilter.txx can not be compiled by VC++

How can I use itkImageToVTKImageFilter in my program and convert the itk
data to vtk correctly?

Thank you very much!

Chunyan Jiang