I am using vtkResliceImageViewer vtk library class to display DICOM files
. Images are too dark. I don't know if I use it wrong way or it's a bug (there was similar unresolved problem posted before: Correct display of DICOM images ITK-VTK (images too dark)).
I am using custom DICOM
data reader and I'm sure data is ok. vtkImageViewer2
class displays it correctly. I'am sure that this is not issue connected to Modality LUT
, Rescale Slope/Intercept
, VOI LUT
and window center/width
(values are fine).
I attach basic code example producing two images. Window center = 40
and width = 400
are hardcoded and are 100% proper for tested image. Render window with red background displays image using vtkImageViewer2
class and it's perfectly fine. Render window with green background display image using vtkResliceImageViewer
and it's too dark. When I set WindowLevel to -40
instead of 40 it's look close to the proper displayed image.
Both clases use vtkImageMapToWindowLevelColors
to apply window transformation. I've tried using SetOutputFormatToLuminance()
and PassAlphaToOutputOff()
methods of that class but this didn't help.
Does somebody have same problem and resolved it some way?
SeriesDataReader dataReader;
vtkSmartPointer<vtkImageData> data = dataReader.ReadSeriesData();
vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(900, 900);
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(0, 1, 0);
renderer->ResetCamera();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindow> renderWindow2 = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow2->SetSize(900, 900);
vtkSmartPointer<vtkRenderer> renderer2 = vtkSmartPointer<vtkRenderer>::New();
renderer2->SetBackground(1, 0, 0);
renderer2->ResetCamera();
renderWindow2->AddRenderer(renderer2);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor2 = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor2->SetRenderWindow(renderWindow2);
vtkSmartPointer<vtkImageViewer2> imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInputData(data);
imageViewer->SetColorLevel(40.0);
imageViewer->SetColorWindow(400.0);
imageViewer->SetupInteractor(renderWindowInteractor2);
imageViewer->SetRenderWindow(renderWindow2);
imageViewer->SetRenderer(renderer2);
imageViewer->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->Render();
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkResliceImageViewer> resliceImageViewer = vtkSmartPointer<vtkResliceImageViewer>::New();
resliceImageViewer->SetupInteractor(renderWindowInteractor);
resliceImageViewer->SetRenderWindow(renderWindow);
resliceImageViewer->SetSliceOrientationToXY();
resliceImageViewer->SetRenderer(renderer);
resliceImageViewer->SetInputData(data);
resliceImageViewer->SetSliceOrientation(2);
resliceImageViewer->SetResliceModeToAxisAligned();
resliceImageViewer->SetColorLevel(40.0);
resliceImageViewer->SetColorWindow(400.0);
resliceImageViewer->SetResliceMode(0);
resliceImageViewer->GetRenderer()->ResetCamera();
resliceImageViewer->Render();
imageViewer->GetRenderWindow()->Render();
renderWindowInteractor2->Initialize();
imageViewer->GetRenderWindow()->Render();
renderWindowInteractor2->Start();
resliceImageViewer->GetRenderWindow()->Render();
renderWindowInteractor->Initialize();
resliceImageViewer->GetRenderWindow()->Render();
renderWindowInteractor->Start();
vtkImagePlanWidget
and play around with theSetWindowLevel
method? – MrPedru22vtkImagePlaneWidget
also do not proper display images with window center/width transformation. – Springfield762