[vtkusers] Displaying a 16 bit image

Serena Wong shwong at gmail.com
Tue Sep 25 14:44:18 EDT 2012


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();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120925/36609aa8/attachment.htm>


More information about the vtkusers mailing list