<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000;">Hi Luis,<br><br><span id="result_box" class="long_text"><span title="saya berusaha untuk mensegmentasi file dicom lalu menyimpannya dalam format vtk.">I tried to segmented DICOM files and save them in vtk format.<br></span><span title="saya menggunakan contoh 1 2 dan 3 untuk membangun program saya.">I used DicomSeriesReadImageWrite2.cxx, DeformableModel1.cxx, DeformableModel2.cxx to build my program.<br></span><span title="masalahnya adalah hasilnya tidak sesuai dengan yang saya harapkan.">the problem is the result does not match what I expected.<br></span><span title="ketika saya membuka bone.vtk dengan fileeditor isinya hanya seperti ini:">when I opened bone.vtk (result file) with file editor the content just like this:</span></span> <div><br><font size="2"># vtk
DataFile Version 3.0<br>VTK File Generated by Insight Segmentation and Registration Toolkit (ITK)<br>ASCII<br>DATASET STRUCTURED_POINTS<br>DIMENSIONS 124 124 45<br>SPACING 1.0000000000000000e+00 1.0000000000000000e+00 1.0000000000000000e+00<br>ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00<br>POINT_DATA 691920<br>SCALARS scalars short 1<br>LOOKUP_TABLE default<br>0 0 0 0 0 0 <br>0 0 0 0 0 0 <br>0 0 0 0 0 0 <br>0 0 0 0 0 0 <br>0 0 0 0 0 0 <br>0 0 0 0 0 0 </font><br>....<br>and when I opened this file with vtk reader (<font size="2">PolyDataReader</font>) there was error :<br><br><font size="2">ERROR: In /build/buildd/vtk-5.0.3/IO/vtkPolyDataReader.cxx, line 142<br>vtkPolyDataReader (0x8765510): Cannot read dataset type: structured_points</font><br><br><br>This is my source code list :<br><font size="2">/*=========================================================================<br>Name : 3D Segmentation of Bone Structure on CT
Image<br>=========================================================================*/<br>// Include the required header <br><br>#include "itkOrientedImage.h"
<br>#include "itkGDCMImageIO.h"
<br>#include "itkGDCMSeriesFileNames.h"
<br>#include "itkImageSeriesReader.h"
<br>#include "itkImageFileWriter.h"<br><br>#include "itkMesh.h"
<br>#include "itkDeformableMesh3DFilter.h"
<br>#include "itkGradientRecursiveGaussianImageFilter.h"
<br>#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
<br>#include "itkImage.h"
<br>#include "itkCovariantVector.h"
<br>#include "itkSphereMeshSource.h"
<br>#include "itkImageFileReader.h" <br>#include "itkPointSetToImageFilter.h"<br>#include "itkVTKImageIO.h"
<br><br><br><br>int main(int argc, char* argv[] )<br>{<br> if( argc < 3 )
<br> {
<br> std::cerr << "Usage: " << std::endl;
<br> std::cerr << argv[0] << " DicomDirectory outputFileName [seriesName]"
<br> << std::endl;
<br> return EXIT_FAILURE;<br> }<br><br> typedef signed short PixelType;
<br> const unsigned int Dimension = 3;
<br> <br> typedef itk::OrientedImage< PixelType, Dimension > ImageType;
<br> <br> typedef itk::ImageSeriesReader< ImageType > ReaderType;
<br> ReaderType::Pointer reader = ReaderType::New();
<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> <br> nameGenerator->SetUseSeriesDetails( true );
<br> nameGenerator->AddSeriesRestriction("0008|0021" );
<br> nameGenerator->SetDirectory( argv[1] );
<br>
<br> try
<br> {
<br> std::cout << std::endl << "The directory: " << std::endl;
<br> std::cout << std::endl << argv[1] << std::endl << std::endl;
<br> std::cout << "Contains the following DICOM Series: ";
<br> std::cout << std::endl << std::endl;
<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> while( seriesItr != seriesEnd )
<br> {
<br> std::cout << seriesItr->c_str() << std::endl;
<br> seriesItr++;
<br> }
<br> <br> std::string seriesIdentifier;
<br> if( argc > 3 )
<br> {
<br> seriesIdentifier = argv[3];
<br> }
<br> else
<br> {
<br> seriesIdentifier = seriesUID.begin()->c_str();
<br> }
<br> <br> std::cout << std::endl << std::endl;
<br> std::cout << "Now reading series: " << std::endl << std::endl;
<br> std::cout << seriesIdentifier << std::endl;
<br> std::cout << std::endl << std::endl;
<br> <br> //read DICOM<br> typedef std::vector< std::string > FileNamesContainer;
<br> FileNamesContainer fileNames;
<br> <br> fileNames = nameGenerator->GetFileNames( seriesIdentifier );
<br> reader->SetFileNames( fileNames );
<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>//segmentation with DeformableModel<br> const float sigma = 1.0 ;
<br> const int numberOfIterations = 100 ;
<br> const float timeStep = 0.1 ;
<br> const float externalForceScale = 10 ;
<br> const float stiffness = 0.1 ;<br> <br> typedef double MeshPixelType; typedef itk::Mesh< MeshPixelType > MeshType;
<br> typedef itk::GradientRecursiveGaussianImageFilter<ImageType> GradientFilterType; typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<ImageType,ImageType> GradientMagnitudeFilterType;
<br> typedef itk::DeformableMesh3DFilter<MeshType,MeshType> DeformableFilterType; GradientMagnitudeFilterType::Pointer gradientMagnitudeFilter = GradientMagnitudeFilterType::New();
<br> ImageType::ConstPointer inputImage = reader->GetOutput(); gradientMagnitudeFilter->SetInput( inputImage ); gradientMagnitudeFilter->SetSigma( sigma ); GradientFilterType::Pointer gradientMapFilter = GradientFilterType::New(); <br> gradientMapFilter->SetInput( gradientMagnitudeFilter->GetOutput()); gradientMapFilter->SetSigma( sigma ); gradientMapFilter->Update(); <br> DeformableFilterType::Pointer deformableModelFilter = DeformableFilterType::New();
<br> typedef itk::SphereMeshSource< MeshType > MeshSourceType; MeshSourceType::Pointer meshSource = MeshSourceType::New();
<br>
<br> // Set the initial sphere in the center of the image
<br> const ImageType::SpacingType spacing = inputImage->GetSpacing();
<br> ImageType::PointType origin = inputImage->GetOrigin(); ImageType::SizeType size = inputImage->GetBufferedRegion().GetSize();
<br> <br> MeshType::PointType center;
<br> center[0] = origin[0] + spacing[0] * size[0] / 2.0; center[1] = origin[1] + spacing[1] * size[1] / 2.0; center[2] = origin[2] + spacing[2] * size[2] / 2.0;
<br> meshSource->SetCenter( center );
<br> MeshType::PointType radius; radius[0] = spacing[0] * size[0] / 4.0;
<br> radius[1] = spacing[1] * size[1] / 4.0; radius[2] = spacing[2] * size[2] / 4.0;
<br> meshSource->SetScale( radius );
<br> meshSource->SetResolutionX( 50 ); meshSource->SetResolutionY( 50 ); meshSource->Update();
<br> deformableModelFilter->SetInput( meshSource->GetOutput() ); deformableModelFilter->SetGradient( gradientMapFilter->GetOutput() );
<br> typedef itk::CovariantVector<double, 2> StiffnessType;
<br> StiffnessType stiffnessVector; stiffnessVector[0] = stiffness; stiffnessVector[1] = stiffness;
<br> <br> deformableModelFilter->SetTimeStep( timeStep ); deformableModelFilter->SetStiffness( stiffnessVector );
<br> deformableModelFilter->SetStepThreshold( numberOfIterations ); deformableModelFilter->SetGradientMagnitude( externalForceScale );<br> try {
<br> deformableModelFilter->Update();
<br> }
<br> catch( itk::ExceptionObject & excep ) { std::cerr << "Exception Caught !" << std::endl; std::cerr << excep << std::endl; }<br><br>//writer to *.vtk file<br> typedef itk::PointSetToImageFilter<MeshType,ImageType> MeshFilterType;
<br> MeshFilterType::Pointer meshFilter = MeshFilterType::New();
<br> meshFilter->SetInput(meshSource->GetOutput());
//</font><font size="2"> (<font size="4">I confused in there !!!!! or </font> )</font><br><font size="2"> try
<br> {
<br> meshFilter->Update();
<br> }
<br> catch( itk::ExceptionObject & excep )
<br> {
<br> std::cerr << "Exception Caught !" << std::endl;
<br> std::cerr << excep << std::endl;
<br> }<br><br> <br> typedef itk::ImageFileWriter< ImageType > WriterType;
<br> WriterType::Pointer writer = WriterType::New();
<br> writer->SetFileName( argv[2] );
<br> writer->SetInput( meshFilter->GetOutput() );
<br> <br> std::cout << "Writing the image as " << std::endl << std::endl;
<br> std::cout << argv[2] << std::endl << std::endl;
<br> typedef itk::VTKImageIO ImageIOType;<br> ImageIOType::Pointer vtkIO = ImageIOType::New();<br> vtkIO->SetFileTypeToASCII();<br> writer->SetImageIO( vtkIO );
<br> <br> try
<br> {
<br> writer->Update();
<br> }
<br> catch (itk::ExceptionObject &ex)
<br> {
<br> std::cout << ex << std::endl;
<br> return EXIT_FAILURE;
<br> }<br><br> <br> }
<br> catch (itk::ExceptionObject &ex)
<br> {
<br> std::cout << ex << std::endl;
<br> return EXIT_FAILURE;
<br> }
<br><br>}<br></font><font size="2">//end list=========================================================================</font><br><br><br>Regards,<br><br> Sutrisno<br></div>
</div><br>__________________________________________________<br>Apakah Anda Yahoo!?<br>Lelah menerima spam? Surat Yahoo! memiliki perlindungan terbaik terhadap spam <br>http://id.mail.yahoo.com </body></html>