[vtkusers] How to build grayscale lookup tables the right way ( vtk 5.0.2 )

Jesús Spí­nola jspinola at gmail.com
Fri Feb 16 06:28:10 EST 2007


Hello,

I'm having some trouble building a pipeline with several grayscale lookup
tables by hand. Let's see if someone can help me.
I think may be I'm not understanding well what does exactly every method
from the lookup table classes.

The images I want to view are medical images and I'm using vtkImageViewer2.
I'll show an example case to illustrate better the problems I have.

For example, I have an image whit a pixel range of -2047..+2048. Then I want
to apply to that image a Lookup table. This lookup table has 4096 entries,
and its values goes from 0 to 65535 with a +16 step between each entry ( 0,
16, 32, 48, ...,65519, 65535 ).

This is the code to build the grayscale lut

int numberOfEntries = 4096;
vtkLookupTable *vtkLut = vtkLookupTable::New();
vtkLut->SetNumberOfTableValues( numberOfEntries );
for( int i =0; i < numberOfEntries; i++ )
{
   double value = (double)lutValues[i]/65535.0; // lutValues is the array
with the values of the lut ( 0,16,...,65535)
   vtkLut->SetTableValue( i , value , value , value , 1.0 );
}
vtkLut->SetTableRange( -2047 , 2048 );

My first question about this lut is if is the correct way to build it, or if
I'm missing something.
Another thing I want to know is what exactly does the method SetTableRange.
It refers to the range of the input values or the range for the output? I
mean, the range refers to the vtkImageData object I want to apply the lut or
to the range of the vtkImageData produced once I applied the lut to the
original data?
If i put table range to 0,65535, (that is the supposed range of the output
data?), I get a dark image.

This is the code to build the pipeline

vtkImageViewer2 *viewer = vtkImageViewer2::New()
viewer->SetInput( imageData ); // image data is a vtkImageData object
obtained reading a file

vtkImageMapToColors *mapColors = vtkImageMapToColors::New();
mapColors->SetInput( imageData );
mapColors->SetLookupTable( vtkLut ); // the lut we've build before

// I do this because I don't want to use the internal window level mapper
that vtkImageViewer2 has
viewer->GetImageActor()->SetInput( mapColors->GetOutput() );

After this first lut transform, I would like to apply a window level
transform, either with another lut o the common window/level values, and
after the window levelling another lut.
I don't know which are the appropiate classes to expand this pipeline and
how to do it well.

Does someone know which is the right way to do this?

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070216/cc4638f5/attachment.htm>


More information about the vtkusers mailing list