[vtk-developers] [VTK 0012684]: vtkImageImport has problems with PipelineMtime and upstream changes.

Mantis Bug Tracker mantis at public.kitware.com
Fri Oct 28 12:02:52 EDT 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://vtk.org/Bug/view.php?id=12684 
====================================================================== 
Reported By:                John Stark
Assigned To:                
====================================================================== 
Project:                    VTK
Issue ID:                   12684
Category:                   (No Category)
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     backlog
Project:                    TBD 
Type:                       incorrect functionality 
Resolution:                 open
Fixed in Version:           
====================================================================== 
Date Submitted:             2011-10-28 12:02 EDT
Last Modified:              2011-10-28 12:02 EDT
====================================================================== 
Summary:                    vtkImageImport has problems with PipelineMtime and
upstream changes.
Description: 
I have been using the ImageToVTKImageFilter, but have found a bug that the
downstream pipeline does not correctly detect changes upstream of the filter. 

In the sample below, an ITK image is constructed and filled with the value 127.
This value is correctly extracted as float using a vtkImageCast filter. However,
when I change the data buffer, filling it with zeros, the output initially
reports the image value as unchanged, even after Update() is called. It appears
to explicitly require the ITK converter to be updated, which should not be
necessary. 

I think the bug relates to vtkImageImport, which does not correctly report the
PipelineMtime, but I am not sure. 

I am using a git version of VTK, based on
dbb88cda6b6d703b237b431629562ff275aae000 from July this year. 

Code sample:

#include <itkImage.h>
#include <itkImageToVTKImageFilter.h>

#include <vtkImageCast.h>
#include <vtkImageData.h>
#include <vtkSmartPointer.h>

int main()
{
  const int dims[3] = { 64, 64, 64 }; // Image size in pixels
  
  typedef itk::Image<unsigned char, 3> ImageType;

  ImageType::RegionType region;
  for ( int i(0); i<3; ++i ) {
      region.SetSize(i, dims[i] );
      region.SetIndex(i,0);
  }

  ImageType::Pointer image = ImageType::New();
  image->SetLargestPossibleRegion(region);
  image->SetBufferedRegion(region);
  image->Allocate();
  image->FillBuffer( 127 );


  typedef itk::ImageToVTKImageFilter< ImageType > ConverterType;
  ConverterType::Pointer myConverter = ConverterType::New();
  myConverter->SetInput ( image );
  myConverter->UpdateOutputInformation();

  vtkSmartPointer<vtkImageCast> imCast = vtkSmartPointer<vtkImageCast>::New();
  imCast->SetOutputScalarTypeToFloat();
  imCast->SetInput(myConverter->GetOutput());

  vtkImageData * tstImg = imCast->GetOutput();
  tstImg->Update();
  float fval0 = ((const float*)tstImg->GetScalarPointer())[0];

  image->FillBuffer(0);
  image->Modified();
  image->GetPixelContainer()->Modified();

  tstImg->Update();
  float fval1 = ((const float*)tstImg->GetScalarPointer())[0];

  myConverter->GetOutput()->UpdateInformation();
  tstImg->Update();
  float fval2 = ((const float*)tstImg->GetScalarPointer())[0];

  if ( (fval0 == 127.)
      && (fval1 == 0.)
      && (fval2 == 0.) ) {
    return EXIT_SUCCESS;
  } else {
      return EXIT_FAILURE;
  }
}

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-10-28 12:02 John Stark     New Issue                                    
======================================================================




More information about the vtk-developers mailing list