[vtkusers] Displaying a 16 bit image
David Gobbi
david.gobbi at gmail.com
Tue Sep 25 16:13:01 EDT 2012
Hi Serena,
In VTK 5.8 and earlier, you have to add a vtkImageMapToColors filter
before the ImageActor. This filter will convert the 16-bit image to
an 8-bit color image.
If you are using VTK 5.10, they you can call GetProperty() on the
ImageActor, and then adjust the Window and Level through the image
property. In VTK 5.10, you can also use the newer image display
classes described on this wiki page:
http://www.vtk.org/Wiki/VTK/Image_Rendering_Classes
- David
On Tue, Sep 25, 2012 at 12:44 PM, Serena Wong <shwong at gmail.com> wrote:
> Hi,
>
> I can't seem to display a 16 bit image.
>
> I'm creating a vtkImage as follows and then am using QVTKWidget to display
> it. Do I need to set the scale factor or something somewhere? Everything
> keeps displayinga s an 8 bit image! Thanks in advance for your help. (code
> segment below)
>
> Serena
>
> imageData = vtkSmartPointer<vtkImageData>::New();
> imageData->SetDimensions(xsize,ysize,1);
> imageData->SetScalarTypeToUnsignedShort();
> imageData->SetNumberOfScalarComponents(1);
>
> //populate the data here
> int* dims = imageData->GetDimensions();
> // int dims[3]; // can't do this
>
> for (int y = 0; y < dims[1]; y++)
> {
> for (int x = 0; x < dims[0]; x++)
> {
>
> /// some sort of population with values between 0 and 2^16
> }
> }
>
> imageActor = vtkSmartPointer<vtkImageActor>::New();
> imageActor->SetInput(imageData); //this adds the vtk image actor
> renderer = vtkSmartPointer<vtkRenderer>::New();
> renderer->InteractiveOff(); //turn the interaction off for now
> renderer->AddActor(imageActor);
>
> this->ui->waterfallVTKObject->GetRenderWindow()->AddRenderer(renderer);
> this->ui->waterfallVTKObject->GetRenderWindow()->Render();
More information about the vtkusers
mailing list