[vtk-developers] reproducible bug with vtkExtractVOI and vtkImageShiftScale

Charl P. Botha c.p.botha at its.tudelft.nl
Fri Nov 9 20:17:11 EST 2001


Dear VTK-developers,

If one uses a vtkExtractVOI followed by a vtkImageShiftScale on e.g.
unsigned char data, the data _seems_ to change type to float
(imagedata->GetScalarType(), although
imagedata->GetPointData()->GetActiveScalars()->GetDataType() seems to remain
correct).  In addition, setting vtkImageShiftScale's output scalar type to
the same type as the input data results in an immediate segfault in the two
examples that I've attached.

I am using this filter combination in a raycasting pipeline... obviously the
raycaster refuses to render float data.  In my own application, changing the
output type of vtkImageShiftScale does not result in a segfault, but the
actual scalar data seems to get "lost", as nothing is rendered.  I have
confirmed that all other components in my pipeline are working.

Please apply the attached two patches to the pertinent examples
(graphics/examplesCxx/volProt.cxx and graphics/examplesPython/volSimple.py)
in current VTK cvs.  Each demonstrates this problem *independently*.  To see
the segfault, UNcomment the line that calls
SetOutputScalarTypeToUnsignedShort().  If this line is commented, one can
watch the raycaster complaining about incorrect scalar type.  It is also
interesting to note that if either of the vtkImageShiftScale OR the
vtkExtractVOI is short-circuited, all is well.

If anyone can shed some more light on this, I'd be MOST grateful.  I suppose
it has something to do with the changes in VTK's data-model abstraction, but
I haven't been able to find anything obviously wrong.  The perl scripts in
the 3.2 -> 4.0 upgrade package also seem to think all is fine with the
involved filters.

Thanks in advance for any information,
Charl

-- 
charl p. botha      | computer graphics and cad/cam 
http://cpbotha.net/ | http://www.cg.its.tudelft.nl/
-------------- next part --------------
--- volSimple-orig.py	Wed Apr 18 19:40:59 2001
+++ volSimple.py	Sat Nov 10 01:50:55 2001
@@ -40,8 +40,18 @@
 
 compositeFunction = vtkVolumeRayCastCompositeFunction()
 
+extractVOI = vtkExtractVOI()
+extractVOI.SetInput(reader.GetOutput())
+extractVOI.SetVOI(0,65,0,65,0,65)
+
+shiftscale = vtkImageShiftScale()
+shiftscale.SetInput(extractVOI.GetOutput())
+shiftscale.SetShift(0)
+shiftscale.SetScale(1)
+#shiftscale.SetOutputScalarTypeToUnsignedShort()
+
 volumeMapper = vtkVolumeRayCastMapper()
-volumeMapper.SetInput(reader.GetOutput())
+volumeMapper.SetInput(shiftscale.GetOutput())
 volumeMapper.SetVolumeRayCastFunction(compositeFunction)
 
 volume = vtkVolume()
-------------- next part --------------
--- volProt-orig.cxx	Sat Nov 10 01:56:03 2001
+++ volProt.cxx	Sat Nov 10 02:02:57 2001
@@ -7,6 +7,8 @@
 #include "vtkVolumeRayCastCompositeFunction.h"
 #include "vtkVolumeRayCastMapper.h"
 #include "vtkVolume.h"
+#include "vtkExtractVOI.h"
+#include "vtkImageShiftScale.h"
 
 #include "SaveImage.h"
 
@@ -23,6 +25,17 @@
   vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
     reader->SetFileName("../../../vtkdata/ironProt.vtk");
     reader->Update();
+    
+    vtkExtractVOI* extractVOI = vtkExtractVOI::New();
+    extractVOI->SetInput(reader->GetOutput());
+    extractVOI->SetVOI(reader->GetOutput()->GetExtent());
+    
+    vtkImageShiftScale* shiftscale = vtkImageShiftScale::New();
+    //shiftscale->SetOutputScalarTypeToUnsignedShort();    
+    shiftscale->SetInput(extractVOI->GetOutput());
+    shiftscale->SetShift(0);
+    shiftscale->SetScale(1);
+
 
   // Create a transfer function mapping scalar value to opacity
   vtkPiecewiseFunction *oTFun = vtkPiecewiseFunction::New();
@@ -46,7 +59,7 @@
 
   // Create the volume mapper and set the ray function and scalar input
   vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
-    volumeMapper->SetInput(reader->GetOutput());
+    volumeMapper->SetInput(shiftscale->GetOutput());
     volumeMapper->SetVolumeRayCastFunction(compositeFunction);
 
   // Create the volume and set the mapper and property


More information about the vtk-developers mailing list