[Insight-users] vtk polydata import / export

Luis Ibanez luis . ibanez at kitware . com
Tue, 15 Jul 2003 11:04:00 -0400


Hi Imho,

Could you please try the following:

in your pipeline

vtkPolydata->vtkImageData->vtkExporter->itkImporter

add an ITK writer after the itkImporter

   itkImporter->itkImageFileWriter

and save the data in a MetaImage format
(which support pixel type float).

The use the ImageViewer application available
in InsightApplications in order to check the
content of the image.

You could also use a VTK image format
and use VTK for checking the content of
the file.

The point of the test is to verify if the
image is being imported correctly into ITK.


Please let us know what you find.


   Thanks


     Luis



--------------
imho wrote:
> Hi Luis,
> the error that I have is a runtime error, I didn't add it because I have
> a message in front of it, and I can't copy paste it. Now I send you a
> print screen :) Maybe I didn't understand it rightly.
> 
> The pixelType that I've for ITK is float :
> ...
> const unsigned int Dimension = 3;
> class registrationITK
> {
> public:
> ...
>     typedef float PixelType;
>     typedef itk::Image<PixelType, Dimension> ImageType;
> ...
> private :
> ...
>     ImageType::Pointer imageSource;
>     ImageType::Pointer imageTarget;
> 
> }
> 
> thanks for your help
> 
> Imho.
> 
> 
> 
> Luis Ibanez wrote:
> 
>>
>> Hi Imho,
>>
>> Your description is a bit confusing.
>>
>> You may want to verify your processing stage by stage.
>>
>> A pipeline:
>>
>> vtkExporter-->itkImporter-->itkExporter-->vtkImporter
>>
>> Should work without problem.
>>
>> You may want to verify that you are using compatible
>> pixel types. What is the pixel type that you are using
>> for instantiating the ITK images ?
>>
>> >
>> > back in vtk I still have a vtkImageData error.
>> >
>> What is the error message that you get for vtkImageData ?
>> is this a compilation error ? a link error ? or a runtime error ?
>>
>> Posting the error message can always help   :-)
>>
>>
>>
>>    Luis
>>
>>
>>
>> ---------------
>> imho wrote:
>>
>>> Hi Luis,
>>>
>>> I've succeed converting vtkPolyData to vtkImageData, it deforms my 
>>> vtkPolyData and is very slow but I'll try other parameters...
>>> the principal is that I have a vtkImageData to put in the exporter / 
>>> importer pipe-line.
>>> And there I have a problem. itk returns a null imageData, so I've 
>>> tried a simple pipe-line to itk where I do nothing, just this :
>>>
>>> ------------------------------------------
>>> in itk class :
>>> registrationITK::registrationITK(vtkImageImport* vtkImporter, 
>>> vtkImageExport *vtkExporter, vtkImageExport *vtkExporter2)
>>> {      itkImporter = ImageImportType::New();
>>>    itkImporter2 = ImageImportType::New();
>>>    itkExporter = ImageExportType::New();
>>>
>>>    itkExporter->SetInput(itkImporter->GetOutput());
>>>      ConnectPipelines(vtkExporter, itkImporter);
>>>    ConnectPipelines(vtkExporter2, itkImporter2);
>>>    ConnectPipelines(itkExporter, vtkImporter);            
>>> itkImporter->Update();
>>>    itkImporter2->Update();
>>> }
>>> -------------------------------
>>> in vtk class :
>>> ...
>>>
>>>    vtkImporter4 = vtkImageImport::New();
>>> ...
>>>    vtkExporter4 = vtkImageExport::New();
>>>    vtkExporter5 = vtkImageExport::New();
>>>
>>>    poly[0] = vtkPolyData::New();
>>>    poly[1] = vtkPolyData::New();
>>>    polyLive = vtkPolyData::New();
>>>
>>>    imageModel = vtkImageData::New();
>>>    imageModelLive= vtkImageData::New();
>>>
>>>    polyToImage = vtkImplicitModeller::New();
>>>    polyLiveToImage = vtkImplicitModeller::New();
>>> ...
>>>        polyToImage->SetInput(poly[0]);
>>>        polyLiveToImage->SetInput(polyLive);
>>>              polyToImage->SetSampleDimensions(10, 10, 10);
>>>        polyToImage->SetMaximumDistance(0.25);
>>>           polyLiveToImage->SetSampleDimensions(10, 10, 10);
>>>        polyLiveToImage->SetMaximumDistance(0.25);
>>>
>>>        imageModel = polyToImage->GetOutput();
>>>        imageModelLive = polyLiveToImage->GetOutput();
>>>                      vtkExporter4->SetInput(imageModel);
>>>        vtkExporter5->SetInput(imageModelLive);
>>>
>>>        regITK = new registrationITK(vtkImporter4, vtkExporter4, 
>>> vtkExporter5);
>>>
>>>        cast->SetInput(vtkImporter4->GetOutput());
>>>        castTo3D->SetInput(vtkImporter4->GetOutput());
>>>
>>>        isRegITK = true;
>>>
>>> ...
>>>        poly[0]->CopyStructure(ApplyDemonRegistration());
>>> ------------------------------------------------
>>> vtkPolyData* sourceControlVTK::ApplyDemonRegistration()
>>> {
>>>    vtkPolyData* pol = vtkPolyData::New();
>>>
>>> //  regITK->InitDemonRegistration(progress); // dans controlQt
>>>      imageModel = vtkImporter4->GetOutput();
>>>    pol = imageToPolyMaker->makePoly(imageModel);
>>>    return pol;
>>>
>>> }
>>>
>>> back in vtk I still have a vtkImageData error.
>>> So I resume, when I do :
>>> vtkPolyData->vtkImageData->vtkPolyData
>>> my poly is'nt allright but I have something to show
>>>
>>> but if I do :
>>> vtkPolyData->vtkImageData->vtkExporter->itkImporter->itkExporter->vtkImporter->vtkImagedata->vtkPolyData 
>>> with or without the demonFilter
>>> I have nothing back :/
>>> I surely do something wrong, but I can't find what.
>>> Maybe you can help me (again).
>>>
>>> thanks a lot.
>>>
>>> Imho.
>>>
>>
>> .
>>
> 
> 
> ------------------------------------------------------------------------
>