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

Thomas Lambertz thomas at hexerei-software.de
Fri Feb 16 06:52:04 EST 2007


Hello Jesús,

Jesús Spí­nola wrote:
> 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 ).
Why do you want to blow up your input from 12bit (typical medical) to 
16bit ?

>
> 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!

vtkImageMapToColors has a 8bit output ("The result is an image of type 
VTK_UNSIGNED_CHAR"). So you have to manage how your intensities should 
be "pressed" from 12bit into these 8bit. One common way is the 
level/window-concept as most dicom-viewers do.
I have realized this in my work by using 
itkIntensityWindowingImageFilter and itkCastImageFilter. But there is 
also a vtk-viewer-class that supports the concept of level/window 
directly (dont know its exact name - havent used it in my projects).

Hth,
Tom





More information about the vtkusers mailing list