[vtkusers] vtkColorTransferFunction limit

Alex Malyushytskyy alexmalvtk at gmail.com
Wed Aug 17 21:05:35 EDT 2011


>From the algorithm limitation point of view - as far as I understand
there is no limitiation.
(it is limited by int. Check the limits.h, but I believe it is
2147483647 (Microsoft Windows) )

>From the code you are using point of view it is not that simple.

Even though vtk provides real value  RGB definition,
to understand your problem it is easier to think about rgb in other form, where
RGB is a value defined by 3 integer values - each in a range from  [0, 255]
( for example check  http://www.w3.org/TR/SVG/types.html#ColorKeywords )


So variation  by parameters separately ( red, green or blue )  in your function
with increase number of colors .
Something like this:.

int numCols = 256;
vtkColorTransferFunction ct = new vtkColorTransferFunction::New();
vtkPiecewiseFunction pf = new vtkPiecewiseFunction::New();

int i =0;
for (int r=0; r<numCols; r++)
{
  for (int g=0; g<numCols; r++)
  {
    int b=r;
    {
      ct.AddRGBPoint(i, double(r)/(numCols -1), double(g)/(numCols
-1), double(b)/(numCols -1));
      i++;
    }
  }
}

unsinged int totalValues = i;

i =0;
for (int r=0; r<numCols; r++)
{
  for (int g=0; g<numCols; r++)
  {
    int b=r;
    {
      pf.AddPoint(i, i /double(totalValues -1) );
      i++;
    }
  }
}

But I would expect that your don't need increase the number of colors.
Have you noted "double(r)", etc  in my code

I afraid that your code does not take into account  that deviding
integer 5 / 255  = 0

So the following
>  ct.AddRGBPoint(i, i/(numCols -1), i/(numCols -1), i/(numCols -1));
>  pf.AddPoint(i, i/(numCols -1));
is equivalent
>  ct.AddRGBPoint(i, 0, 0, 0 );
>  pf.AddPoint(i, 0));

for any i except 255,
which means you really added only 2  colors.

Try  to replace it with

ct.AddRGBPoint(i, double(i)/(numCols -1), double(i)/(numCols -1),
double(i)/(numCols -1));
pf.AddPoint(i, double(i)/(numCols -1));

regards,
 Alex



On Wed, Aug 10, 2011 at 11:03 AM,  <Clement.Chu at csiro.au> wrote:
> Hi,
>
>   Anyone know how many colours I can add into vtkColorTransferFunction class by calling AddRGBPoint method.  I used the code below to generate the colour map:
>
> int numCols = 256;
> vtkColorTransferFunction ct = new vtkColorTransferFunction::New();
> vtkPiecewiseFunction pf = new vtkPiecewiseFunction::New();
> for (int i=0; i<numCols; i++) {
>  ct.AddRGBPoint(i, i/(numCols -1), i/(numCols -1), i/(numCols -1));
>  pf.AddPoint(i, i/(numCols -1));
> }
>
> I would like to know whether it is possible to change the variable numCols to high number such 4096 or 65536.  Thanks.
>
>
> Regards,
> Clement
> _______________________________________________
> 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