[vtkusers] Another question on vtkLookupTable..!

David Gobbi david.gobbi at gmail.com
Tue Feb 22 08:42:18 EST 2011


Hi Rakesh,

You might want to look at vtkColorTransferFunction.

 - David


On Tue, Feb 22, 2011 at 2:38 AM, rakesh patil <prakeshofficial at gmail.com> wrote:
> Hi David,
>
> It can be done by repeating colors as you say. But how do I identify the
> number of table values? Because the values
> 10
> 20
> 30
> 40
> 50
> 60
> 80
> 100
> 200
>
> is entered by user. and user may enter any value like,
>
> 10
> 20
> 30
> 35
> 40
> 45
> 70
> 90
> 100
> 200
>
> In this case, number of table values will be more (i.e. @ interval of 5).
> Well, I'll just give a try. Number of colors should remain same in either
> case right? only number of table values will vary. Am I correct..??
>
> Thanks
>
> Regards
> Rakesh Patil
>
> On Tue, Feb 22, 2011 at 2:41 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi Rakesh,
>>
>> You can't change the fact that the binsize is uniform.  But I don't
>> understand why you don't just repeat the colors:
>>
>> 10     ==== (1.0, 0.0, 0.0)
>> 20     ==== (1.0, 0.5, 0.0)
>> 30     ==== (1.0, 1.0, 0.0)
>> 40     ==== (0.5, 1.0, 0.0)
>> 50     ==== (0.0, 1.0, 0.0)
>> 60     ==== (0.0, 1.0, 0.5)
>> 70     ==== (0.0, 1.0, 0.5)
>> 80     ==== (0.0, 1.0, 1.0)
>> 90     ==== (0.0, 1.0, 1.0)
>> 100   ==== (0.0, 0.5, 1.0)
>> 110   ==== (0.0, 0.0, 1.0)
>> ... ditto for 120 to 190 ...
>> 200   ==== (0.0, 0.0, 1.0)
>>
>>  - David
>>
>> On Tue, Feb 22, 2011 at 12:58 AM, rakesh patil
>> <prakeshofficial at gmail.com> wrote:
>> > Hey David,
>> >
>> > Thanks for that explanation. Now it's bit clear about how lookup table
>> > works. But in my case, I guess, binsize is not uniform. Let me put it in
>> > this form
>> >
>> > 10     ==== (1.0, 0.0, 0.0)
>> > 20     ==== (1.0, 0.5, 0.0)
>> > 30     ==== (1.0, 1.0, 0.0)
>> > 40     ==== (0.5, 1.0, 0.0)
>> > 50     ==== (0.0, 1.0, 0.0)
>> > 60     ==== (0.0, 1.0, 0.5)
>> > 80     ==== (0.0, 1.0, 1.0)
>> > 100   ==== (0.0, 0.5, 1.0)
>> > 200   ==== (0.0, 0.0, 1.0)
>> >
>> > in this case, bin size is not equal to (max-min)/n. I mean, lookup table
>> > might calculate it like that. But If dont want in that way, then what
>> > changes I have to do to implement? May be I am wrong in understanding
>> > the
>> > meaning of binsize. Please correct me if I'm wrong.
>> >
>> > Thanks
>> >
>> > Regards
>> > Rakesh Patil
>> >
>> > On Tue, Feb 22, 2011 at 11:58 AM, David Gobbi <david.gobbi at gmail.com>
>> > wrote:
>> >>
>> >> Hi Rakesh,
>> >>
>> >> The way that the lookup table maps values to colors is as follows:
>> >> If the Range of the table is set to [min,max] and the number of colors
>> >> in the table is n, then the equation that maps a value "v" to an
>> >> index "i" is:
>> >>
>> >>  i = floor((v - min)*n/(max - min))
>> >>
>> >> The bin size is uniform and equal to (max - min)/n.  Values in the
>> >> range [min, min + binsize] go into the first bin (and values less than
>> >> min also go into the first bin).
>> >>
>> >> Since the bins are uniform in size, you will need a table with 20
>> >> values
>> >> and a binsize of 10, and some of the colors will have to be repeated.
>> >> Use lut->SetTableRange(0.5, 200.5), where the ".5" is for rounding.
>> >>
>> >>  - David
>> >>
>> >>
>> >> On Mon, Feb 21, 2011 at 10:35 PM, rakesh patil
>> >> <prakeshofficial at gmail.com> wrote:
>> >> > Hello,
>> >> >
>> >> > I have to display contours, for a given range, by mapping values to
>> >> > colours.
>> >> > i.e. Consider I need to display contours between 1 and 200.
>> >> >
>> >> > I use the lookuptable as follows
>> >> >
>> >> > vtkSmartPointer<vtkLookupTable> lut =
>> >> > vtkSmartPointer<vtkLookupTable>::New();
>> >> > lut->SetNumberOfTableValues(9);
>> >> > lut->SetTableValue(0, 1.00, 0.00, 0.00);
>> >> > lut->SetTableValue(1, 1.00, 0.50, 0.00);
>> >> > lut->SetTableValue(2, 1.00, 1.00, 0.00);
>> >> > lut->SetTableValue(3, 0.50, 1.00, 0.00);
>> >> > lut->SetTableValue(4, 0.00, 1.00, 0.00);
>> >> > lut->SetTableValue(5, 0.00, 1.00, 0.50);
>> >> > lut->SetTableValue(6, 0.00, 1.00, 1.00);
>> >> > lut->SetTableValue(7, 0.00, 0.50, 1.00);
>> >> > lut->SetTableValue(8, 0.00, 0.00, 1.00);
>> >> > lut->Build();
>> >> > Now suppose I want the output like show below
>> >> >
>> >> > 01 - 10     ==== (1.0, 0.0, 0.0)
>> >> > 11 - 20     ==== (1.0, 0.5, 0.0)
>> >> > 21 - 30     ==== (1.0, 1.0, 0.0)
>> >> > 31 - 40     ==== (0.5, 1.0, 0.0)
>> >> > 41 - 50     ==== (0.0, 1.0, 0.0)
>> >> > 51 - 60     ==== (0.0, 1.0, 0.5)
>> >> > 61 - 80     ==== (0.0, 1.0, 1.0)
>> >> > 81 - 100    ==== (0.0, 0.5, 1.0)
>> >> > 101 - 200  ==== (0.0, 0.0, 1.0)
>> >> >
>> >> > How can this be done.?? So that the values supplied should be mapped
>> >> > to
>> >> > the
>> >> > corresponding colour and should be displayed.
>> >> >
>> >> > Thanks
>> >> >
>> >> > Regards
>> >> > Rakesh Patil
>> >
>> >
>
>



More information about the vtkusers mailing list