[vtkusers] vtkColorTransferFunction - ColorSpace + Range problems

Julien Finet julien.finet at kitware.com
Thu Aug 15 15:58:48 EDT 2013


Hi Alexis,

1-
vtkColorTransferFunction::AddRGBPoint() takes RGB components from 0. to 1.
(double), not 0 to 255 (unsigned char).

Julien.


On Thu, Aug 15, 2013 at 3:37 PM, Girault, Alexis <girault at email.unc.edu>wrote:

>  Hi,
>
> I try to display colors to describe the scalars value of points in
> surfaces. When doing this, I'd like to choose between different color
> spaces to interpolate points color to create the colormap.
>
> I am using the vtkColorTransferFunction::SetColorSpaceTo...() to choose
> between Divergingm Lab, RGB and HSV.
>
> *1- Problem : Diverging and Lab do their job, RGB and HSV don't : *
>
>    - Diverging : http://hpics.li/ba7907f
>    - Lab : http://hpics.li/a36da83
>    - RGB & HSV : http://hpics.li/53b5d5d
>
>
> *My code :*
> ****************************************************************************************************************************
>
>         //Range
>         double *rangeLUT =
> mapper->GetInput()->GetPointData()->GetScalars()->GetRange();
>         double range = fabs(rangeLUT[1] - rangeLUT[0]);
>
>         //LookUpTable
>         vtkSmartPointer<vtkColorTransferFunction> DistanceMapTFunc =
> vtkSmartPointer<vtkColorTransferFunction>::New();
>         DistanceMapTFunc->AddRGBPoint(rangeLUT[0], 0, 255,
> 0);                           // Min value to green
>         DistanceMapTFunc->AddRGBPoint(rangeLUT[0] + range/2.0, 255, 255,
> 0);  // Middle of the range to yellow
>         DistanceMapTFunc->AddRGBPoint(rangeLUT[1], 255, 0, 0);
>                // Max value to red
>
>         //Color Space
>         if(cspace == "Diverging")
> DistanceMapTFunc->SetColorSpaceToDiverging();
>         else if(cspace == "Lab")
> DistanceMapTFunc->SetColorSpaceToLab();
>         else if(cspace == "RGB")
> DistanceMapTFunc->SetColorSpaceToRGB();
>         else if(cspace == "HSV")
> DistanceMapTFunc->SetColorSpaceToHSV();
>
>         //Mapper Update
>         mapper->SetLookupTable( DistanceMapTFunc );
>         mapper->ScalarVisibilityOn();
>         mapper->Update();
> ****************************************************************************************************************************
>
>
>
> *2- Black value at minimum Range :
>
> *Even if I add a Green point at rangeLUT[0], my min value is black, as
> you can see both on the surface and the scalarbar :
> http://hpics.li/2ce35fb
>
> I tought it might be because something was rounding when displaying
> colors, so I evaluated the error as the the range divided by the number of
> colors, which gives us range/256. Then I add it to the max and remove it to
> the min.
> By doing this I actually "erased" the black values from the surface, but
> not the scalarbar : I only have a lower min and still black :
> http://hpics.li/9315fec
> *
>
> **3- Are those functions useful? Nothing seems to change in my code
> (already implemented):*
>         mapper->SetScalarRange(rangeLUT[0],rangeLUT[1]);
>         mapper->SetScalarModeToUsePointData();
>         mapper->SetColorModeToMapScalars();
>
>
> If you have the answer to any of those questions, please let me know!
> Thanks all.
>
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130815/caafb51b/attachment.htm>


More information about the vtkusers mailing list