[vtkusers] How to display 24-bit RGB images as a volume

Chamanthi Karunasekara chamrk at gmail.com
Mon Jun 22 06:56:08 EDT 2009


Hi,

I'm new to VTK. I have a set of 24-bit RGB images (without a header) and I
want to display them in a volume. What is the suitable approach? I tried in
several ways but none of them seem to be right.

Initially I read R, G, B components seperately into three vtkImageReader
objects, append them together using vtkImageAppendComponents object and used
a vtkImageActor. When I used GetWholeZMin() and GetWholeZMax methods of
vtkImageActor, it shows that all images have been entered into
vtkImageActor. But only the 1st image is displayed. Then I found that
vtkImageActor seems to be able to show only one slice.

Then I tried to display using vtkVolumeRayCastMapper and vtkVolume. It
generates a set of parrelel planes, but it is in grey scale and only part of
the image is shown. I want to display in original colouring.

In the 1st method, if I use a vtkActor insead of vtkImageActor, I think
I would need a mapper object. Is there a suitable mapper object?

I also found that vtkVolumeReader can be used to read images and if more
than one image is read results in a 3D volume. I tried that also, but when I
compile it, it gives an error like this. I'm using VTK5.2.1. Why does this
happen?

 error C2440: 'initializing' : cannot convert from 'class vtkAlgorithm *' to
'class vtkVolumeReader *'
        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast

#include "vtkVolumeReader.h"

int main(int argc, char **argv)
{
 int numCol=2048;
 int numRow=1216;
 int startSlice=0;
 int endslice=10;

 vtkVolumeReader *reader=vtkVolumeReader::New();
 reader->SetFilePrefix(argv[1]);
 reader->SetImageRange(startSlice,endslice);
 reader->SetFilePattern("%s%d.raw");
 reader->SetDataSpacing(0.33, 0.33, 1);//voxel size
 reader->UpdateWholeExtent();

 return 0;
}

 Thanks a lot.
Chamanthi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090622/883f9397/attachment.htm>


More information about the vtkusers mailing list