<div>Hi everyone;<br></div><div>I need to create a DICOM image from vtkRenderWindow contents and send it to a DICOM printer. <br>I used vtkWindowToImageFilter to get the screenshot of the render window, at first i casted it to monochrome image using vtkImageLuminance, and converted the scalar type to unsigned short using vtkImageCast. The reason of this conversions is; vtkWindowToImageFilter creates RGB images which uses char as scalar type and vtkGDCMImageWriter doesn't accept the unsigned char as an input. I gave the output of the last filter to vtkGDCMImageWriter but the result is a little bit paler than the original DICOM file(but if i change the window / level values it just looks like the original image). I think the reason of this "paleness" is the difference of the scalar ranges of original DICOM image(which is -1000 and +2000 after rescaling) and the exported RGB screenshot(0-255)...So i need to rescale the image and define suitable values for window / level. I tried to give the original image's values but no difference, i didn't set any values and let the vtkGDCMImageWriter to determine them, still no good results. What should be the shift and scale values for rescaling the output of the vtkWindowToImageFilter? Any help will be appreciated,thanks already....</div>
<div><br></div><div>this->Image->SetImageItem(tempitem);//set the current imagedata to the vtkImageSlice<br> this->Image->GetRenderWindow()->OffScreenRenderingOn();<br> this->Image->SetCameraPositions(activeFrame->GetActiveCamera());<br>
this->Image->RenderFrame();<br><br> vtkWindowToImageFilter *windowToImage = vtkWindowToImageFilter::New();<br> windowToImage->SetInput(this->Image->GetRenderWindow());<br><br> vtkImageLuminance *luminance = vtkImageLuminance::New();<br>
luminance->SetInputConnection(windowToImage->GetOutputPort());<br><br> vtkImageCast *cast = vtkImageCast::New();<br> cast->SetInputConnection(luminance->GetOutputPort());<br> cast->SetOutputScalarTypeToUnsignedShort();<br>
<br>vtkGDCMImageWriter *dicomExport = vtkGDCMImageWriter::New();<br>dicomExport->SetFileName(filename.toStdString().c_str());<br> dicomExport->SetInput(cast->GetOutput());<br> dicomExport->SetImageFormat(0);<br>
dicomExport->SetMedicalImageProperties(tempitem->GetImageProperties());</div><div>dicomExport->SetShift(tempitem->GetShift());<br> dicomExport->SetScale(tempitem->GetScale());<br> dicomExport->Write();<br>
<br> this->Image->GetRenderWindow()->OffScreenRenderingOff();<br> cast->Delete();<br> luminance->Delete();<br> windowToImage->Delete();</div>