[vtk-developers] vtkImageActor doesn't allow you to increase image components from 1 to 3

David Doria daviddoria at gmail.com
Tue Nov 23 12:41:41 EST 2010


I setup a demo and tried a few cases. (1) - (3) work properly, and (4)
is the issue.

1) If I create an image with image->SetNumberOfScalarComponents(1), then call:

vtkImageActor* actor = vtkImageActor::New()
actor->SetInput(image);

it works as expected, a grayscale image is displayed.

2) If I create an image with image->SetNumberOfScalarComponents(3), then call:

vtkImageActor* actor = vtkImageActor::New()
actor->SetInput(image);

it works as expected, a color image is displayed.

3) If I create an image with image->SetNumberOfScalarComponents(3), then call:

vtkImageActor* actor = vtkImageActor::New()
actor->SetInput(image);

then change the image:
image->SetNumberOfScalarComponents(1)
... update image ...

it works as expected, a grayscale image is displayed.

4) HOWEVER, if I create an image with
image->SetNumberOfScalarComponents(1), then call:

vtkImageActor* actor = vtkImageActor::New()
actor->SetInput(image);

then change the image:
image->SetNumberOfScalarComponents(3)
... update image ...

A GRAYSCALE image is still displayed. I have attached a demonstration
of the problem (comment or uncomment #define DemonstrateBug to see the
correct vs the incorrect behavior).

If someone can confirm this is a bug I will add it to the bug tracker.

Thanks,

David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageActor.cxx
Type: text/x-c++src
Size: 4083 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20101123/0d3d0e5e/attachment-0001.cxx>


More information about the vtk-developers mailing list