dgobbi / vtk-dicom

A set of classes for using DICOM in VTK.
BSD 3-Clause "New" or "Revised" License
259 stars 94 forks source link

Supplemental Palette Color not applied correctly? #237

Closed RobertHabrich closed 3 weeks ago

RobertHabrich commented 3 weeks ago

This sample file has PixelPresentation of "COLOR" and contains palette color lookup tables. vtkDICOMApplyPalette also seems to recognize everything. However, when rendering, I would expect something in this direction:

image

What I actually get using the following code is a black window. Am I missing something here?


#include <vtkDICOMApplyPalette.h>
#include <vtkDICOMReader.h>
#include <vtkImageViewer2.h>
#include <vtkInteractorStyleImage.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>

int main()
{
    auto reader = vtkSmartPointer<vtkDICOMReader>::New();
    reader->SetFileName(R"(PATH_TO_FILE)");
    reader->Update();

    auto palette = vtkSmartPointer<vtkDICOMApplyPalette>::New();
    palette->SetInputConnection(reader->GetOutputPort());
    palette->Update();

    auto iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    auto style = vtkSmartPointer<vtkInteractorStyleImage>::New();
    iren->SetInteractorStyle(style);

    auto viewer = vtkSmartPointer<vtkImageViewer2>::New();
    viewer->SetInputConnection(palette->GetOutputPort());
    viewer->SetupInteractor(iren);
    viewer->Render();
    viewer->GetRenderWindow()->SetSize(800, 800);
    viewer->GetRenderer()->Render();
    iren->Start();
    return 0;
}
dgobbi commented 3 weeks ago

Use reader->AutoRescaleOff() when applying a palette to the image.

Explanation: for CT and PET, the vtkDICOMReader outputs modality values by default, and AutoRescaleOff() tells it to output the stored values instead. Palettes always expect stored values as input.

See Examples/TestDICOMDisplay.cxx.

RobertHabrich commented 3 weeks ago

Oof... I've actually been in that example and have seen that before but totally forgot about it.

Thank you!