[vtkusers] Question on vtkLookupTable

David Doria daviddoria+vtk at gmail.com
Mon Sep 13 07:55:09 EDT 2010


On Mon, Sep 13, 2010 at 2:31 AM, Lodron, Gerald
<Gerald.Lodron at joanneum.at> wrote:
>
> Hi,
>
> I am trying to make a vtk lookuptable and have problems understanding the
> class.
>
> Can anyone explain me the difference between TableRange, ValueRange and
> Number of colors?
>
> I interpret it as follows:
>
> -Number of Table values are the number of entries in the lookup table but
> why or what is a Table Range? Shouldn't it be the same as number of colors?
> -Value range is the range of the gray values in the image (e.g. 0-255)
>
> Can anyone explain it to me, would be great.
>
> I am trying to make a Lookuptable which mapps 0 to black and 1 to an
> arbitrary color which is transparent. I think i could make it like this but
> it doesn't work:
>
>
> vtkLookupTable* poVtkLut = oMitkLut->GetVtkLookupTable();
>
> poVtkLut->SetTableRange(0, 1);
>
> poVtkLut->SetAlphaRange(1.0, 0.0);
>
> poVtkLut->SetValueRange(0, 1);
>
> poVtkLut->SetNumberOfTableValues(2);
>
> poVtkLut->SetNumberOfColors(2);
>
> poVtkLut->Build();
>
>
>
> Any suggestions?

Gerald,

The TableRange is the input range. No matter how many values are in
the table, you can map them to any input range.

The documentation for SetNumberOfColors says "Use
SetNumberOfTableValues instead", so you should just do that :)

The ValueRange I guess what you'd want to use for greyscale colors,
but generally it is the V in the HSV color scheme.

Now your main question "Can anyone explain me the difference between
TableRange, ValueRange and Number of colors?". Say you have this:

TableRange = [9, 10]
ValueRange = [125, 255]
NumberOfColors = 2

This would take the input value 9.0 and map it to the color with index
0 in the table, which is (125, something, something) . It will take
the number 10.0 and map it to the color with index 1 in the table,
which is (255, something, something) (the somethings depend on your
choice of SetHueRange and SetSaturationRange.

Another alternative is to specify the colors directly:

On Mon, Sep 13, 2010 at 2:31 AM, Lodron, Gerald
<Gerald.Lodron at joanneum.at> wrote:
>
> Hi,
>
> I am trying to make a vtk lookuptable and have problems understanding the
> class.
>
> Can anyone explain me the difference between TableRange, ValueRange and
> Number of colors?
>
> I interpret it as follows:
>
> -Number of Table values are the number of entries in the lookup table but
> why or what is a Table Range? Shouldn't it be the same as number of colors?
> -Value range is the range of the gray values in the image (e.g. 0-255)
>
> Can anyone explain it to me, would be great.
>
> I am trying to make a Lookuptable which mapps 0 to black and 1 to an
> arbitrary color which is transparent. I think i could make it like this but
> it doesn't work:
>
>
> vtkLookupTable* poVtkLut = oMitkLut->GetVtkLookupTable();
>
> poVtkLut->SetTableRange(0, 1);
>
> poVtkLut->SetAlphaRange(1.0, 0.0);
>
> poVtkLut->SetValueRange(0, 1);
>
> poVtkLut->SetNumberOfTableValues(2);
>
> poVtkLut->SetNumberOfColors(2);
>
> poVtkLut->Build();
>
>
>
> Any suggestions?

Gerald,

The TableRange is the input range. No matter how many values are in
the table, you can map them to any input range.

The documentation for SetNumberOfColors says "Use
SetNumberOfTableValues instead", so you should just do that :)

The ValueRange I guess what you'd want to use for greyscale colors,
but generally it is the V in the HSV color scheme.

Now your main question "Can anyone explain me the difference between
TableRange, ValueRange and Number of colors?". Say you have this:

TableRange = [9, 10]
NumberOfColors = 2
lut->SetTableValue(0     , 0     , 0     , 0, 1);
lut->SetTableValue(1, 1, 1, 1);

This will map 9.0 to black and 10.0 to white.

Of course in both examples above 9.5 will be mapped to the color that
lies exactly between the color at index 0 and the color at index 1 (as
long as you aren't UsingLogScale).

I hope that explains it... let us know if you need any more clarification.

David



More information about the vtkusers mailing list