<div dir="ltr">Thanks Luis for your help, I used the following example showed in this file "DicomSeriesReadImageWrite2.cxx" and I<br><br> got the slice em order.<br>Best regards.<br><div class="gmail_quote">2008/9/29 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">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;">Hi Jihan,<br>
<br>
Try the following:<br>
<br>
after the code:<div class="Ih2E3d"><br>
<br>
try{<br>
> reader2->Update();<br>
> }<br>
> catch (itk::ExceptionObject & e)<br>
> {<br>
> std::cerr << "Failed to read " << fname << "\n" <<<br>
> e.GetDescription() << std::endl;<br>
> return NULL;<br>
> }<br>
<br></div>
add a writer:<br>
<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
<br>
WriterType::Pointer writer2 = WriterType::New();<br>
<br>
writer2->SetInput( reader2->GetOutput() );<br>
writer2->SetFileName( "FROMDICOM.mhd");<br>
writer2->Updates();<br>
<br>
Then look at the output image by using the ImageViewer,<br>
or ParaView, or Slicer, or VV, or SNAP,... or any other<br>
application based on ITK readers.<br>
<br>
Please let us know if that image still appears to have<br>
the slices out of order.<br>
<br>
<br>
Thanks<br>
<br>
<br>
<br>
Luis<br>
<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 class="Wj3C7c">
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>
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);<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>
SetInputConnection(image->GetOutputPort());<br>
axialColors->SetInput(dicom_info);<br>
axialColors->SetLookupTable(hueLut);<br>
axial = vtkImageActor::New();<br>
axial->SetInput(axialColors->GetOutput());<br>
axial->SetDisplayExtent(0,extent[1], 0,extent[3], slice_number,slice_number);<br>
axial->SetPosition(0,0,0);<br>
<br>
renderer->AddActor(axial);<br>
renderer->ResetCameraClippingRange();<br>
renArea->queue_draw();<br>
}<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<<br>
ImageType> ImageToVTKImageFilterType;<br>
typedef itk::ImageFileReader< ImageType > ReaderType;<br>
typedef itk::ImageSeriesReader< ImageType > ReaderType2;<br>
typename ReaderType::Pointer reader = ReaderType::New();<br>
typename ReaderType2::Pointer reader2 = ReaderType2::New();<br>
typename ImageToVTKImageFilterType::Pointer exporter=ImageToVTKImageFilterType::New();<br>
if (choice==0){<br>
reader->SetFileName(fname);<br>
try{ reader->Update(); } catch (itk::ExceptionObject & e) { std::cerr << "Failed to read " << fname << "\n" << e.GetDescription() << std::endl; return NULL; }<br>
exporter->SetInput(reader->GetOutput());<br>
}<br>
if (choice==1){<br>
itk::DICOMImageIO2::Pointer dicomIO = itk::DICOMImageIO2::New();<br>
// Get the DICOM filenames from the directory<br>
itk::DICOMSeriesFileNames::Pointer nameGenerator = itk::DICOMSeriesFileNames::New();<br>
nameGenerator->SetDirectory(fname);<br>
try<br>
{<br>
typedef std::vector<std::string> seriesIdContainer;<br>
const seriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br>
seriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>
seriesIdContainer::const_iterator seriesEnd = seriesUID.end();<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>
while( seriesItr != seriesEnd )<br>
{<br>
std::cout << seriesItr->c_str() << std::endl;<br>
seriesItr++;<br>
}<br>
std::cout << std::endl << std::endl;<br>
std::cout << "Now reading series: " << std::endl << std::endl;<br>
typedef std::vector<std::string> fileNamesContainer;<br>
fileNamesContainer fileNames;<br>
std::cout << seriesUID.begin()->c_str() << std::endl;<br>
fileNames = nameGenerator->GetFileNames();<br>
std::cout << std::endl << std::endl;<br>
reader2->SetFileNames( fileNames );<br>
reader2->SetImageIO( dicomIO );<br>
try{ reader2->Update(); } catch (itk::ExceptionObject & e) { std::cerr << "Failed to read " << fname << "\n" << e.GetDescription() << std::endl; return NULL; }<br>
exporter->SetInput(reader2->GetOutput());<br>
}<br>
catch (itk::ExceptionObject &ex)<br>
{<br>
std::cout << ex;<br>
return NULL;<br>
}<br>
}<br>
exporter->Update();<br>
vtkImageData* output=vtkImageData::New();<br>
output->DeepCopy(exporter->GetOutput());<br>
return output;<br>
} <br>
P.S: This renderer is a Rendering Area of vtkmm.<br>
<br>
Best Regards..<br></div></div>
2008/9/27 Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a> <mailto:<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>>><div class="Ih2E3d">
<br>
<br>
<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>
<br>
<br>
Hi all,<br>
I have a set of Analyze Image. I used ITK to read the .hdr file<br>
and it got all right. I export this image to vtk, I'm facing a<br>
great problem to display a 2D Slice. I already checked the<br>
header data like: Spacing, Extent, Origin ..and everything is<br>
ok! I 'm using unsigned short as a pixel type. I used the<br>
vtkExtractVOI to extract a 2D slice, but when I try to<br>
visualize it, i got a total different image. Could anybody help me?<br>
<br>
Regards<br>
-- Jihan Zoghbi<br>
<br>
-- Jihan Zoghbi<br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
<br>
_______________________________________________<br>
Insight-users mailing list<br></div>
<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a> <mailto:<a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a>><div class="Ih2E3d"><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
<br>
<br>
<br>
-- <br>
Jihan Zoghbi<br>
</div></blockquote>
</blockquote></div><br><br clear="all"><br>-- <br>Jihan Zoghbi<br>
</div>