[vtkusers] Looking for the perfect scalarRange...

Geoframer geoframer at gmail.com
Fri Sep 7 06:48:40 EDT 2007


Hi Rafael,

The fact that you only get one color in this case blue probably means that
the range of your scalars (the ones you use for color are all in the high
range of your lookuptable or higher then 1. The lookuptable starts at 0
(red) and up to the 1 (blue) and is in your case setup into 9344 intervals.
I don't know exactly how the make up of your scalars is but an easy test
would be to set a few to 0 and see if you then get red and blue colors. If
yes then the pipeline works correctly but the scalarvalues are to close to
another (and probaby to high) and you need some kind of multiplier/divider
to pull them apart.

In general a trick i used when i was first trying to grasp how lookuptables
work is to add a colorbar based on the lookup table. This colorbar will show
you the colors as they are mapped through your lookuptable. Just adding this
would quicky show if your lookuptable contains only one color and hence is
faulty or in fact multiple colors which would imply that your scalars need
some work.

#create a colorbar
colorbar = vtk.vtkScalarBarActor()
colorbar.SetLookupTable(lookupTable)
colorbar.SetWidth(0.05)
colorbar.SetPosition(0.95, 0.1)
colorbar.SetLabelFormat("%.3g")
colorbar.PickableOff()
colorbar.VisibilityOn()

ren.AddActor(colorbar)

Regards and hope this helps some - Geoframer

On 9/6/07, rafael possani <gentefinabr at hotmail.com> wrote:
>
>
> Hi Geoframer, first of all ,  thanks a lot for the reply, and well I have
> tested a lookuptable too, but without luck, I think that I mistaken some
> method, then I eraser my lookuptable and I writed another one like yours.
> And I still cant see the colors, only one cor, generally blue. Then I will
> post my program better to see if you may help me, one more time :)
>
> I have 9344 points(values) into a vtkdoublearray, each one with a value in
> scientific notation(like around 20 kinds of combinations), for example,
> 3.5E-5, 1.0E-5, 1.0E-5 and 7.7E-6, my bigger number is 7.7E-6, and my
> lesser is 0.0, then I tried it in my lookuptable:
>
>         lookupTable = vtk.vtkLookupTable()
>         lookupTable .SetNumberOfColors(9344);
>         lookupTable .SetTableRange(0,7.7E-6);
>         lookupTable .ForceBuild();
>
> After that I add into my mapper like y said:
>
>      conjunto.SetLookupTable(lookupTable );
>     And in my vtkImageMapToColors:
>
>     oIMTC1 = vtk.vtkImageMapToColors();
>     oIMTC1.SetLookupTable(lookupTable );
>
>     But, as my mapper as my vtkImageViewer still be with just one color.
> Do you suggest some change?
>     Thanks, again.
>     Rafael.
>
>
>
> ------------------------------
> Date: Thu, 6 Sep 2007 13:10:59 +0200
> From: geoframer at gmail.com
> To: gentefinabr at hotmail.com
> Subject: Re: [vtkusers] Looking for the perfect scalarRange...
> CC: vtkusers at vtk.org
>
> Hi Rafael,
>
> I think you're missing a lookup table. Your mapper needs a lookuptable to
> see what scalar is translated into which color.
>
> I suggest creating a lookuptable and adding the lookuptable to the mapper.
>
>
> lookupTable = vtk.vtkLookupTable()
> lookupTable.SetNumberOfColors(numberofscalars)
> lookupTable.SetTableRange(0,1)
> lookupTable.ForceBuild()
>
> conjuto..SetLookupTable(lookupTable)
>
> You'll probably need to take a closer look at lookup tables as i use a
> discrete number of colors (hence the SetNumberOfColors), no idea what kind
> of table you need.
>
> Regards - Geoframer
>
>
>
> On 9/6/07, *rafael possani* <gentefinabr at hotmail.com> wrote:
>
>
>    Hi vtk-users, I am with a problem. I am reading xy point into a
> vtkStructuredPoints and I would like to save like a image, but I cant... my
> vtkRenderWindow shows ok, but my image dont have colors and I know why, I
> need to set the scalars range into the vtkStructuredPoints but I dont know
> what method to use, that a part of my code:
>
> vtkStructuredPoints points = new vtkStructuredPoints();
>     points.SetDimensions( 128, 73, 1);
>     points.SetOrigin( 0.0, 0.0, 0.0 );
>     points.SetSpacing( 1.0, 1.0, 1.0 );
>     points.SetScalarTypeToUnsignedChar ();
>     points.SetNumberOfScalarComponents(id);
>     points.GetPointData().SetScalars( scalars );  // <--- Doesn´t work :/
> with that my image only be red
>
> the scalars vector are double in Scientific notation I dont know if its
> bad.
>
> I have been trying all possible methods but I hadn´t success.
>
> my mapper renders ok:
>
> vtkDataSetMapper conjunto = new vtkDataSetMapper();
>     conjunto.SetInput(points);
>     conjunto.SetScalarRange (points.GetScalarRange());  <---- But it works
> here
>
> I´m thinking that a need a method like SetScalarRange from my mapper to
> use before in my vtkStructuredPoints.
>
> besides, I am using vtkImageMapToColors to convert my structured points
> into a image. I also can post my entire code, but I made the same like this
> link, without the beginning because I generated my points :)  http://public.kitware.com/pipermail/vtkusers/2005-December/083147.html
>
>
>
> Well, someone suggest me a method for my vtkStructuredPoints? thanks in
> advanced.
>
>
>
> ------------------------------
> Receba GRÁTIS as mensagens do Messenger no seu celular quando você estiver
> offline. Conheça o MSN Mobile! Cadastre-se já!<http://mobile.live.com/signup/signup2.aspx?lc=pt-br>
>
> _______________________________________________
> 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
>
>
>
> ------------------------------
> Receba GRÁTIS as últimas novidades do esporte direto no seu Messenger! Assine
> já!<http://signup.alerts.live.com/alerts/login.do?PINID=37485679&returnURL=http://www.nivea.com.br>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070907/80ac78e8/attachment.htm>


More information about the vtkusers mailing list