[vtkusers] A bug in vtkImageMapToColors? (bright voxels mapped to black)

Kalle Pahajoki kalpaha at st.jyu.fi
Mon Sep 12 14:32:17 EDT 2005


Hi

I've recently noticed a strange behaviour in my software that I've got 
the behaviour repeated with the attached piece of code. In short, the 
output from vtkImageMapToColors is very odd. Sometimes some scalars 
(could be around range 200-255 or so) are mapped to black. Other times 
they are colored in weird colors that do not come from the ctf.

Here's the code. It writes out two PNGs of the data, before and after 
mapping through the ctf. The before picture looks just as it should, but 
in the second picture there are black areas where there were bright 
intensity pixels in the first image.

The PNGs are available at
http://people.cc.jyu.fi/~kalpaha/before.png
http://people.cc.jyu.fi/~kalpaha/after.png

I'm aware that VTK is tested very thorougly so this is very surprising.
Can anyone confirm that there's a bug in VTK or give any pointers into 
what could be causing such (sudden) change in the behaviour?

In case it's relevant, I have a self compiled VTK from CVS (updated a 
few days ago), compiled with gcc version 3.4.2 (mingw)

Here's the code (all it does is map the data through the ctf and write 
out the images)
--------------------------------------------
import vtk
reader=vtk.vtkXMLImageDataReader()
reader.SetFileName("J:\\Data\\Sample2_1tp_0.vti")
reader.Update()
data=reader.GetOutput()
writer=vtk.vtkPNGWriter()

voi=vtk.vtkExtractVOI()
voi.SetInput(data)
voi.SetVOI(0,511,0,511,12,12)
voi.Update()
writer.SetInput(voi.GetOutput())
writer.SetFileDimensionality(2)
writer.SetFileName("before.png")
writer.Write()

#mapToColors.RemoveAllInputs()
mapToColors=vtk.vtkImageMapToColors()
mapToColors.SetInput(data)

#updateColor()
ctf=vtk.vtkColorTransferFunction()
ctf.AddRGBPoint(0,0,0,0)
ctf.AddRGBPoint(255.0,0.0,1.0,0)
mapToColors.SetLookupTable(ctf)
mapToColors.SetOutputFormatToRGB()

data=mapToColors.GetOutput()

voi=vtk.vtkExtractVOI()
voi.SetInput(data)
voi.SetVOI(0,511,0,511,12,12)
voi.Update()
writer.SetInput(voi.GetOutput())
writer.SetFileDimensionality(2)
writer.SetFileName("after.png")
writer.Write()



-- 
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition not smart enough to debug it.        -- Brian W. Kerninghan




More information about the vtkusers mailing list