<div dir="ltr">Dear Luis,<br><br> Thanks for your help, I have already succeed to read and visualize Analyze Image. I'm facing a new problem now, when I'm trying to read and visualize Dicom Image , I got a problem to view the slides in the correct order. I used the following code:<br>
/*******************************************/<br><br><span dir="ltr" id=":xl">char dir_name[]="/home/talita/Desktop/COMUNIX/Neck 1HEAD_NECK_PETCT/CT HEAD-NK 5.0 B30s";<br>dicom_info = vtkImageData::New();<br>dicom_info = vtkITKMyUtilityLoadImage<unsigned short,1>(dir_name);</span><br>
/*****************************************************/<br>void window1::addAxialSlice(int slice_number)<br>{<br> int *extent;<br> extent = dicom_info->GetWholeExtent();<br> renderer->RemoveActor(axial);<br>
axialColors = vtkImageMapToColors::New();<br><br><div dir="ltr">SetInputConnection(image->GetOutputPort());<br> axialColors->SetInput(dicom_info);<br> axialColors->SetLookupTable(hueLut);<br> <br>
axial = vtkImageActor::New();<br> axial->SetInput(axialColors->GetOutput());<br> axial->SetDisplayExtent(0,extent[1], 0,extent[3], slice_number,slice_number);<br> <br> axial->SetPosition(0,0,0);<br>
<br> renderer->AddActor(axial);<br> renderer->ResetCameraClippingRange();<br> renArea->queue_draw();<br clear="all"></div><span dir="ltr" id=":xl"></span>}<br>/******************************************************/<br>
<br>template <class IT,int choice><br>vtkImageData* vtkITKMyUtilityLoadImage(char* fname)<br>{<br> typedef itk::Image< IT, 3 > ImageType;<br> typedef itk::ImageToVTKImageFilter<<div dir="ltr">ImageType> ImageToVTKImageFilterType;<br>
typedef itk::ImageFileReader< ImageType > ReaderType;<br> typedef itk::ImageSeriesReader< ImageType > ReaderType2;<br> <br> typename ReaderType::Pointer reader = ReaderType::New();<br> typename ReaderType2::Pointer reader2 = ReaderType2::New();<br>
<br> typename ImageToVTKImageFilterType::Pointer exporter=ImageToVTKImageFilterType::New();<br> <br> if (choice==0){<br> reader->SetFileName(fname);<br> <br> try{ <br> reader->Update(); <br>
} <br> catch (itk::ExceptionObject & e) <br> { <br>
std::cerr << "Failed to read " << fname <<
"\n" << e.GetDescription() << std::endl; <br>
return NULL; <br> }<br> exporter->SetInput(reader->GetOutput());<br> }<br> <br> if (choice==1){<br> <br> <br> itk::DICOMImageIO2::Pointer dicomIO = itk::DICOMImageIO2::New();<br>
<br> // Get the DICOM filenames from the directory<br> itk::DICOMSeriesFileNames::Pointer nameGenerator = itk::DICOMSeriesFileNames::New();<br> nameGenerator->SetDirectory(fname);<br> <br>
<br> try<br> {<br> typedef std::vector<std::string> seriesIdContainer;<br> const seriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br> <br> seriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>
seriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br> <br> std::cout << std::endl << "The directory: " << std::endl;<br> std::cout << std::endl << fname << std::endl << std::endl;<br>
std::cout << "Contains the following DICOM Series: ";<br> std::cout << std::endl << std::endl;<br> <br> while( seriesItr != seriesEnd )<br> {<br> std::cout << seriesItr->c_str() << std::endl;<br>
seriesItr++;<br> }<br> <br> std::cout << std::endl << std::endl;<br> std::cout << "Now reading series: " << std::endl << std::endl;<br> <br>
typedef std::vector<std::string> fileNamesContainer;<br> fileNamesContainer fileNames;<br> <br> std::cout << seriesUID.begin()->c_str() << std::endl;<br> fileNames = nameGenerator->GetFileNames();<br>
std::cout << std::endl << std::endl;<br> <br> reader2->SetFileNames( fileNames );<br> reader2->SetImageIO( dicomIO );<br> <br> <br> try{ <br> reader2->Update(); <br>
} <br> catch (itk::ExceptionObject & e) <br> { <br>
std::cerr << "Failed to read " << fname <<
"\n" << e.GetDescription() << std::endl; <br>
return NULL; <br> }<br> exporter->SetInput(reader2->GetOutput());<br> }<br> catch (itk::ExceptionObject &ex)<br> {<br> std::cout << ex;<br> return NULL;<br>
}<br> <br> }<br> <br> exporter->Update();<br> <br> vtkImageData* output=vtkImageData::New();<br> output->DeepCopy(exporter->GetOutput());<br> <br> return output;<br>} </div><br>P.S: This renderer is a Rendering Area of vtkmm.<br>
<br>Best Regards..<br><div class="gmail_quote">2008/9/27 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi Jihan,<br>
<br>
Please describe what is "different" about the image when you display it.<br>
<br>
Also, what are you using for displaying the image ?<br>
<br>
Have you used the ImageViewer to visualize the image ?<br>
You will find it in the InsightApplications module.<br>
<br>
<br>
Regards,<br>
<br>
<br>
Luis<br>
<br>
<br>
--------------------<br>
Jihan Zoghbi wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>
<br>
Hi all,<br>
I have a set of Analyze Image. I used ITK to read the .hdr file and it got all right. I export this image to vtk, I'm facing a great problem to display a 2D Slice. I already checked the header data like: Spacing, Extent, Origin ..and everything is ok! I 'm using unsigned short as a pixel type. I used the vtkExtractVOI to extract a 2D slice, but when I try to visualize it, i got a total different image. Could anybody help me?<br>
<br>
Regards<br>
-- <br>
Jihan Zoghbi<br>
<br>
-- <br>
Jihan Zoghbi<br>
<br>
<br></div></div>
------------------------------------------------------------------------<div><br>
<br>
_______________________________________________<br>
Insight-users mailing list<br>
<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></blockquote>
</blockquote></div><br><br clear="all"><br>-- <br>Jihan Zoghbi<br>
</div>