[vtkusers] fill vtkImageData with RGB data?

Mark Wyszomierski markww at gmail.com
Mon Apr 11 12:48:05 EDT 2005


Hi,

I have an RGB image, I would like to load it into an instance of
vtkImageData. I use the following:

image_data->SetDimensions(cx, cy, 1);
image_data->SetScalarType(VTK_UNSIGNED_CHAR);
image_data->SetNumberOfScalarComponents(3);
image_data->AllocateScalars();
unsigned char *p = (unsigned char*)image_data->GetScalarPointer();

// Now here I will fill image_data with my RGB components in
RGB..RGB..RGB order.

When I go to display my image using vtkImageViewer2, they always come
out grey. Is there a way to make it recognize there are really 3 color
channels to create the actual colors?

Thanks.



More information about the vtkusers mailing list