[vtkusers] Color texture mapping

Will Schroeder will.schroeder at kitware.com
Mon Jul 30 11:39:17 EDT 2001


Hi Tim-

At 04:20 PM 7/30/2001 +0100, Tim Hutton wrote:
>Hello!
>
>I would like to map an RGB image onto a VTK object, is this possible?
>
>I have created a vtkScalars object:
>
>vtkScalars *scalars = vtkScalars::New();
>scalars->SetNumberOfComponents(3);
>scalars->SetNumberOfScalars(X*Y);
>
>and filled it with the RGB values for my image, I would now like to use this as input to a vtkTexture
>for mapping onto an object. When I try this I get only the first channel (red) being used, through a
>rainbow lookup table.
>
>Any pointers are much appreciated!

Try:

vtkScalars *scalars = vtkScalars::New();
scalars->SetScalarTypeToUnsignedChar();
scalars->SetNumberOfComponents(3);
scalars->SetNumberOfScalars(X*Y);

If the scalars are unsigned char, they are (by default) treated as colors, and are not mapped through the lookup table.

Will


William J. Schroeder, Ph.D.
Kitware, Inc.
469 Clifton Corporate Parkway
Clifton Park, NY 12065
will.schroeder at kitware.com
1-518-371-3971 x102 (phone)
1-518-371-3971 (fax)





More information about the vtkusers mailing list