[vtkusers] vtkImageActor coloring bug? (+ fix)

Mark Wyszomierski markww at gmail.com
Tue May 10 16:44:07 EDT 2005


Hi all,

In vtkImageActor, I specify a vtkImageData object as its input which
has 3 scalar components, in RGB format. This allows me to display the
image with true color, without having to use a lookup table. I get
wrong coloring however which I was able to exactly reproduce in a
straight opengl implementation of this texture mapping technique.

Here is what a subsample of my image should look like:
www.mark-w.com/real.gif

Here is how vtkImageActor displays it (and also my own opengl implementation):
www.mark-w.com/textured.gif

I traced the problem down to this single function in my implementation:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, cxImg, cyImg, 0, GL_RGB,
GL_UNSIGNED_BYTE, pImgData);

I was passing GL_RGB for parameter 3 which is supposed to be the
internal format identifier of the texture. This results in those crazy
colors. When I switched it to GL_RGBA, the colors are displayed
correctly.

It's certainly possible that I am using vtkImageActor incorrectly, and
this is just a usage problem on my part. But otherwise this may be the
problem and it would be a great fix to have for displaying true color
images. I don't know where to go to check what vtkImageActor actually
calls at the lowest level to see if this is what it actually is doing.

Please do let me know if you're experiencing the same problem, I'm on winXP.

Thanks!
Mark



More information about the vtkusers mailing list