1
votes

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?

enter image description here

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();
1
Have you try to see if an alpha channel on color is not lost during process??Destrif
Two common reasons for too dark images are: 1) (lack of) gamma correction, and 2) alpha blending. Looking at the images on the right I would bet on alpha blending: your alpha is set to the intensity, and to zero for the light blue background. Try disabling alpha blending, if you canDestrif
For vtkImageData I set: AllocateScalars(VTK_DOUBLE, 1). Image data is composed from one component double values per pixel so there is no alpha channel. Same data displays properly in vtkImageViewer2.Springfield762
have you tried using vtkImagePlanWidget and play around with the SetWindowLevel method?MrPedru22
vtkImagePlaneWidget also do not proper display images with window center/width transformation.Springfield762

1 Answers

1
votes

I solved that issue. For proper display of images with wl/ww transformation comment out or remove line 327 in void vtkResliceImageViewer::InstallPipeline() function.

Line 327: this->WindowLevel->SetLookupTable(this->GetLookupTable());