When I used VTKDICOMReader directly on a axial slice data I get the right answer in radiological convention. But using the same data in ITK gives me an orientation mismatch error . But anyway you can just use vtkImageFlip or just multiple the necessary rotation matrix to the direction cosines. <br>
<br>Regards<br>Darshan<br><br><div class="gmail_quote">On Sun, Feb 27, 2011 at 12:59 PM, Alexander Taghva <span dir="ltr"><<a href="mailto:alextaghva@gmail.com">alextaghva@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>I am relatively new to ITK and VTK. I am trying to read a
DICOM series into ITK and display it with a simple viewer using VTK and
KWWidgets. When I load the series in ITK, the axial images are
upside-down and the sagittal images are flipped left-right. If I try
doing it all in VTK (vtkDicomImageReader), the sagittal and coronal
images are upside-down. I have seen this issue touched on before, but I
couldn't find a good solution. Key parts of my code are below. I am using ITK 3.20 and VTK 5.6.1 on Ubuntu Linux
10.10. <br>
<br>******************************<div>**********************************************************************************************************************<br><br> // initialize ITK DICOM reader<br> typedef unsigned short PixelType;<br>
const unsigned int Dimension = 3;<br><br> typedef itk::Image<PixelType, Dimension> ImageType;<br> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br> ReaderType::Pointer reader = ReaderType::New();<br>
<br> <br><br> typedef itk::GDCMImageIO ImageIOType;<br> ImageIOType::Pointer dicomIO = ImageIOType::New();<br> reader->SetImageIO( dicomIO );<br><br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br> nameGenerator->SetUseSeriesDetails( true );<br> nameGenerator->SetInputDirectory( "DICOM" );<br> const ReaderType::FileNamesContainer & filenames = nameGenerator->GetInputFileNames();<br>
<br> reader->SetFileNames( filenames );<br><br> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject &ex)<br> {<br> std::cout << ex << std::endl;<br> return EXIT_FAILURE;<br>
}<br><br> // now connect to VTK<br> typedef itk::ImageToVTKImageFilter< ImageType> ConnectorType;<br>
ConnectorType::Pointer connector = ConnectorType::New();<br> connector->SetInput( reader->GetOutput() );<br><br> vtkImageViewer2 *viewer = vtkImageViewer2::New();<br><br>
//Create a VTK image viewer, set it up so that it uses our render
widget, set its input to the output of the reader, reset the camera to
center the whole slice<br>
viewer->SetRenderWindow(rw->GetRenderWindow()); <br> viewer->SetRenderer(rw->GetRenderer());<br> viewer->SetInput(connector->GetOutput());<br> viewer->SetupInteractor(rw->GetRenderWindow()->GetInteractor());<br>
rw->ResetCamera(); <br><br> //Retrieve the corner
annotation object from the render widget, point it to the viewer actor
and window/level filter, and let it display both slice and window/level
in different corners using tags<br>
vtkCornerAnnotation *ca = rw->GetCornerAnnotation();<br> ca->SetImageActor(viewer->GetImageActor());<br> ca->SetWindowLevel(viewer->GetWindowLevel());<br> ca->SetText(2,"<slice>");<br>
ca->SetText(3,"<window>\n<level>");<br> <br>
//Create a scale object in our window, set its range to match the
number of slices, set its callback to use its value to set the slice in
the viewer, pack the scale in our window below the render widget<br>
vtkKWScale *slice_scale = vtkKWScale::New();<br> slice_scale->SetParent(win->GetViewFrame());<br> slice_scale->Create();<br> slice_scale->SetRange(viewer->GetSliceMin(),viewer->GetSliceMax());<br>
slice_scale->SetCommand(viewer, "SetSlice");<br> app->Script("pack %s -side top -expand n -fill x", slice_scale->GetWidgetName());<br> <br><br>******************************************************************************************************************************************************<br>
<br>Alex<br>
</div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>