[vtkusers] Displaying DICOM images in grayscale

David Gobbi david.gobbi at gmail.com
Fri Apr 6 11:18:31 EDT 2012


Hi Alexis,

Make a greyscale lookup table, i.e. one where R = G = B and A = 1.
Then use texture->SetLookupTable() to make the texture use this table,
instead of the colorful table that it uses by default.  Use
table->SetRange() to adjust the window and level.

 - David


On Fri, Apr 6, 2012 at 8:26 AM, Alexis Cheng <acheng_1221 at hotmail.com> wrote:
> Dear all,
>
> I'm having some trouble displaying DICOM images read in with
> vtkDICOMImageReader in grayscale. I was able to display it in grayscale
> using imageViewer2 as per the example, but not with this texture, mapper,
> actor, renderer setup. My pipeline looks like this:
>
> /////
>
> for (int i = 0; i < inputFileVector.size(); i++)
>     {
>         // Read all the DICOM files in the specified directory.
>         vtkSmartPointer<vtkDICOMImageReader> reader =
> vtkSmartPointer<vtkDICOMImageReader>::New();
>         reader->SetFileName(inputFileVector.at(i).c_str());
>         reader->Update();
>
>         vtkSmartPointer<vtkImageData> dicomImage =
> vtkSmartPointer<vtkImageData>::New();
>         dicomImage = reader->GetOutput();
>
>         imageSet.push_back(dicomImage);
>     }
>
> planeSource->SetCenter(center.x, center.y, 0.0);
>     planeSource->SetNormal(0.0, 0.0, 1.0);
>     planeSource->Update();
>
> vtkSmartPointer<vtkImageData> image = imageSet.at((int)getSliceNum());
>
>     texture->SetInput(image);
>     texturePlane->SetInputConnection(planeSource->GetOutputPort());
>     mapper->SetInputConnection(texturePlane->GetOutputPort());
>
>     imageActor->SetMapper(mapper);
>     imageActor->SetTexture(texture);
>
> renderer->AddActor(imageActor);
> renderWindow->Render();
>
> /////
>
> The result is that the DICOM image is being displayed in RGB colours. From
> my searches online, it sounds like I need to apply a lookup table that will
> convert RGB into luminance, but is that the only way? If imageviewer2 can
> display it in grayscale without a lookup table, then I would imagine this
> could do so as well. Thank you in advance for your attention.
>
> Regards,
> Alexis Cheng
> Computer Science
> Johns Hopkins University



More information about the vtkusers mailing list