[vtkusers] Colour map complex scalars

John Platt jcplatt at dsl.pipex.com
Thu Apr 7 18:27:45 EDT 2011


Hi David,

Thank you very much for sharing your thoughts. As well as complex scalars, I 
also have complex vectors.

I was looking for a single place where complex scalars or complex vectors 
could be "converted" to real scalars or vectors prior to mapping through a 
normal LUT. Unfortunately, I was wrong footed by the painter.

Deriving new classes from vtkLookupTable isn't that easy because of the 
number of global functions. I didn't find away of using these so they have 
to copied into the .cpp file. At a casual glance it looks like the author of 
vtkLookupTableWithEnabling had the same problem. For this reason I hesitated 
about subclassing vtkScalarsToColorsPainter.

Many thanks for your suggestions.

John.

----- Original Message ----- 
From: "David Gobbi" <david.gobbi at gmail.com>
To: "John Platt" <jcplatt at dsl.pipex.com>
Cc: "vtkusers" <vtkusers at vtk.org>
Sent: Thursday, April 07, 2011 11:05 PM
Subject: Re: [vtkusers] Colour map complex scalars


Oops, I misread what you were attempting... you aren't mapping
real/imag independently, you're using them to compute a new scalar
value.  So you can ignore my previous response.

You could turn your real/imag scalar values into 2D texture
coordinates, and then use vtkTexture to make a 2D texture that will
map them to colors i.e. a 2D texture color table.  The texture would
have to be re-generated at each animation step... not a small task,
since it would be a 256x256 texture, but easily done at >60fps.  Any
other options that I can think of (apart from shader programs) would
require re-loading the mesh at each step.

 - David


On Thu, Apr 7, 2011 at 2:31 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi John,
>
> I've also been thinking about mapping complex scalars, because I know
> it is an issue that I will run into sooner rather than later. However
> it isn't just complex data that I'll have to worry about, but
> multi-channel data in general.
>
> My thought was to add multi-channel mapping directly to
> vtkScalarsToColors (the base class of vtkLookupTable), by making it
> possible to add "child" tables that will be used if the input has
> multiple components. In practice, it would look something like this:
>
> table->SetVectorModeToIndependent(); // map each component independently
> table->SetComponentTable(0, table_for_real);
> table->SetComponentTable(1, table_for_imag);
>
> Given a single-channel input, the base table would be used, but given
> a multi-channel input, the "child" tables would be used.
>
> Putting these features into the vtkScalarsToColors base class would
> also effectively force the mappers/painters to play along and provide
> similar multi-channel color mapping features. For example, scalars
> with N independent channels can be color-mapped by an NxM texture
> where M is greater than or equal to the number of colors per table.
>
> For images I've used an in-house class called vtkImageComposite for
> accomplish basically the same thing (it is image-specific) but, as you
> say, it would be nice to have multi-channel capability built directly
> into vtkLookupTable.
>
> - David
>
>
> On Thu, Apr 7, 2011 at 1:54 PM, John Platt <jcplatt at dsl.pipex.com> wrote:
>>
>> Hi,
>>
>> I would like to colour map complex scalars. This could be the magnitude 
>> or the real part after multiplying the scalars by exp(i theta) for a 
>> specified angle theta.
>>
>> I have written a class vtkLookupTableComplex derived from vtkLookupTable. 
>> MapScalarsThroughTable2() does the conversion of the real and imaginary 
>> components to a single value which is then mapped through the table.
>>
>> This appears to work except when InterpolateScalarsBeforeMapping is set 
>> on the mapper. In this case, the scalars are mapped by 
>> vtkScalarsToColorsPainter::MapScalarsToTexture().
>>
>> I am beginning to think a vtkDataSetAlgorithm based solution would be 
>> easier but I need the performance for animating the scalars by varying 
>> the angle theta from 0 - 360.
>>
>> Should I give up or is there another approach?
>>
>> Thanks for your time.
>>
>> John.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at 
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at: 
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK 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