[Insight-users] itkImageToVTKImageFilter not updating entirely

Charlotte Curtis c.f.curtis at gmail.com
Thu Jun 25 12:35:22 EDT 2009


There seems to be a bit of an issue with itkImageToVTKImageFilter: the
image information isn't entirely being updated when "Update" is called
downstream.  The image data itself does get updated, but (for example)
the min/max intensity values do not.  The odd thing is, it will update
the third time (I'm running my pipeline from a GUI and if I click the
"run" button 3 times, the image finally displays properly).

This behaviour seems to have been reported several years ago
(http://www.itk.org/pipermail/insight-users/2003-March/003110.html),
but it doesn't look to have been resolved.  I took a look at the
source code for the filter, and it seems that the "Update" method just
calls Update on the importer component.  If I copy and paste exactly
the code from the filter, as follows:

vtkImageImport *importer = vtkImageImport::New();
itk::VTKImageExport< ImageType2D >::Pointer exporter =
itk::VTKImageExport< ImageType2D >::New();

importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
importer->SetSpacingCallback(exporter->GetSpacingCallback());
importer->SetOriginCallback(exporter->GetOriginCallback());
importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
importer->SetCallbackUserData(exporter->GetCallbackUserData());

exporter->SetInput(image);
exporter->Update();

and then explicitly call Update on the importer as well:

importer->Update();

Everything works properly.  I'm fine with just using this code in my
program, but perhaps something should be fixed in
itkImageToVTKImageFilter?  I don't know if adding "importer->Update()"
to the source would be the proper way of doing things (seems kind of
like a workaround), or if the UpdateDataCallback method needs to be
changed.

Thanks,

Charlotte


More information about the Insight-users mailing list