vtkImageCast sets output scalar type VERY late
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The scalar type of the actual vtkImageCast output is only updated after an explicit Update() (an UpdateInformation is NOT enough). This wreaks havoc when connecting with ITK filters, as they expect for e.g. a float and then get a double (although the cast has been set to double).
I've made a Python example that reproduces the bug. The example is available here: http://visualisation.tudelft.nl/~cpbotha/files/kitware/WhatIsWrongWithImageCast.py and generates the following output:
===== OUTPUT BEGINS ===== We've just called imageCast.SetOutputScalarTypeToFloat(), so let's check imageCast.GetOutputScalarType() 10 It's 10, which is VTK_FLOAT, and exactly what we expect.
Now let's check the scalar type of the imageCast output double Yikes! It's a double, not a float!
Let's try UpdateInformation first... ERROR: In /home/cpbotha/DoNotBackup/build/VTK/IO/vtkPNGReader.cxx, line 36 vtkPNGReader (0x826ed10): Unable to open file ../../../../VTKData/Data/fullhead15.png
Yikes! Still double!
Looks like we have to do a full Update() ERROR: In /home/cpbotha/DoNotBackup/build/VTK/IO/vtkPNGReader.cxx, line 36 vtkPNGReader (0x826ed10): Unable to open file ../../../../VTKData/Data/fullhead15.png
float The type should be float now.
This doesn't seem like such a biggie, but when VTK filters are used with for instance ITK filters, this causes trouble as a float ITK filter does NOT like getting double when someone first updates the very end of the mixed pipeline.
===== OUTPUT ENDS =====