[vtkusers] vtkLookupTable and vtkImageMapToColors question

David Gobbi dgobbi at atamai.com
Mon Aug 21 09:48:58 EDT 2006


Hi Anja,

You should try using GetScalarRange() instead
of GetScalarTypeMin() and GetScalarTypeMax().

The following code will calculate the actual data
range, rather than the maximum range allowed by
the data type:

double range[2];
slicer->GetOutput()->UpdateInformation();
slicer->GetOutput()->GetScalarRange(range);

vtkLookupTable *bwLut = vtkLookupTable::New();
bwLut->SetTableRange (range);
...

The SetValueRange(0, 1) just means that you want
the the table to go from the darkest value (black) to
the brightest value (in this case, white).  If you want
to understand more, google for "HSV".

There are very few filters in VTK that cast the data,
so it is surprising if your input is "short" and your
output is "double".  You will have to check your
pipeline to see where the cast occurs.

Cheers,

- David




Anja Ende wrote:
> Hi everyone,
>
> I am trying to window the pixel intensities in my image using 
> vtkLookupTable and vtkImageMapToColors objects.
>
> Basically what I am trying to do is set the maximum and minimum values 
> for the pixels. So, any value less than the minimum value should be 
> replaced by the minimum value set and any pixel value more than the 
> maximum value should be set by the maximum value.
>
> I thought I could do that with the combination of vtkLookupTable and 
> the vtkImageMapToColors object.
>
> So, here is what I try to do. I have a reslicer and I pipe the output 
> of the reslicer to the input of the vtkImageMapToColors.
>
> For test purposes, I try to set the min and max value to the possible 
> min and max value. However, all I get is a blank screen :(
>
> Here is the code:
>
> vtkLookupTable *bwLut = vtkLookupTable::New();
> bwLut->SetTableRange (slicer->GetOutput()->GetScalarTypeMin(), 
> slicer->GetOutput()->GetScalarTypeMax());
> bwLut->SetSaturationRange (0, 0);
> bwLut->SetHueRange (0, 0);
> bwLut->SetValueRange (0, 1);
> bwLut->Build(); //effective built
>    
> vtkImageMapToColors *mapColors = vtkImageMapToColors::New();
>     mapColors->SetInputConnection(slicer->GetOutputPort());
> mapColors->SetOutputFormatToRGB();
> mapColors->SetLookupTable(bwLut);
>  
> viewer1->SetInput(mapColors->GetOutput());
>
> // blah blah....    viewer1->SetupInteractor( 
> widget.GetRenderWindow()->GetInteractor());
> widget.SetRenderWindow(viewer1->GetRenderWindow());
>
> Also, I noticed that there is a lot of casting going on... My input 
> images are of type short but all the filters return the output as 
> double....Is that normal?
>
> Also, what does vtkLookUpTable::SetValueRange actually do...
>
> In my example, I expected to see the whole image as the min and max 
> values (in the SetTableTange) function should be within the possible 
> min and max values... but I see a black screen. Obviously, I have 
> misunderstood what these classes actually do, so if anyone can help me 
> understand it... I would be really grateful.
>
> Thanks :)
>
> Anja
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   




More information about the vtkusers mailing list