[vtk-developers] vtkLookupTable + vtkStructuredPointsWriter = bug

Mathieu Malaterre Mathieu.Malaterre at creatis.insa-lyon.fr
Fri Nov 7 07:40:16 EST 2003


Hi,

	I guess my mail was a bit too long. Could at least someone reports that 
he/she could reproduce the bug ? This mail was supposed to be the first 
one, before my question of design:

	In VTK, a polydata with an associated lookuptable can be displayed 
automatically with the good LUT. Because vtkMapper has a
'vtkScalarsToColors'. However for vtkImageData, there is no such things
-well at least I couldn't find one-. An ImageData with an associated
LookupTable is not displayed correctly until you actually use a
vtkImageMapToColors. So my question is simply: why ?

	Thanks a lot for your comments.

mathieu
Ps: I also try to track down why a vtkDataSetMapper doesn't apply the 
lookup table, I end up in
	vtkScalarsToColors::MapScalars which starts: 	
		ConvertUnsignedCharToRGBA
which doesn't take into account the LUT...

Mathieu Malaterre wrote:
> Hi all,
> 
>     In case someone already knows the answer I am posting this. Anyway 
> here is a python script(*) that reproduce the bug. The faulty line is:
> 
>     writer.SetFileTypeToBinary()
> 
> if a vtkImageData is saved with a vtkLookupTable in binary mode 
> everything is ok, but when saved as ASCII then the LUT can't be reread 
> properly. I'll try to find a patch ASAP.
> 
>     BTW, does anyone knows why I should explicitely set the TableRange ?
> 
>     lut.SetTableRange( 0, 255)
> 
> Thanks,
> mathieu
> 
> ##################################################
> (*)
> import vtk
> from vtk.util.misc import vtkGetDataRoot
> VTK_DATA_ROOT = vtkGetDataRoot()
> 
> reader = vtk.vtkBMPReader()
> reader.SetFileName( VTK_DATA_ROOT + '/Data/masonry.bmp' )
> reader.Allow8BitBMPOn ()
> reader.Update()
> 
> #construct an image data with a lookup table
> image = reader.GetOutput()
> image.GetPointData().GetScalars().SetLookupTable( reader.GetLookupTable() )
> 
> writer = vtk.vtkStructuredPointsWriter()
> writer.SetInput( image )
> writer.SetFileName( 'demolut.vtk' )
> #writer.SetFileTypeToBinary()     #culprit !!!
> writer.Write()
> 
> reader2 = vtk.vtkStructuredPointsReader()
> reader2.SetFileName( 'demolut.vtk' )
> reader2.UpdateWholeExtent()
> 
> lut = reader2.GetOutput().GetPointData().GetScalars().GetLookupTable()
> lut.SetTableRange( 0, 255) #trick ??
> 
> map2 = vtk.vtkImageMapToColors ()
> map2.SetInput (reader2.GetOutput())
> map2.SetLookupTable ( lut )
> map2.SetOutputFormatToRGB()
> 
> iren = vtk.vtkRenderWindowInteractor();
> 
> viewer = vtk.vtkImageViewer2()
> viewer.SetInput (map2.GetOutput())
> viewer.SetupInteractor (iren)
> 
> #make interface
> iren.Initialize()
> iren.Start()
> ##################################################




More information about the vtk-developers mailing list