[Insight-users] Run time Error in itk::ImageMomentsCalculator().

yasser salman yass71 at yahoo.com
Sat, 13 Mar 2004 12:28:22 -0800 (PST)


hi Lydia.,
when i'm using 
calculator->
     SetImage( connectedThreshold->GetOutput() );
 calculator->Compute();
the run time error Msg occured when i remove 
calculator->Compute(); there is no problem .., can i
find out where is the error.., 


..,



typedef unsigned short   InputPixelType;
>   typedef float        InternalPixelType;
>   typedef unsigned short   SegmentedPixelType;
> 
>   typedef itk::Image< InputPixelType, 3 >
> InputImageType;
>   typedef itk::Image< InternalPixelType, 3>
> InternalImageType;
>   typedef itk::Image< SegmentedPixelType, 3 >
> SegmentedImageType;
> 
> typedef
> itk::ImageMomentsCalculator<SegmentedImageType>
> 		ImageMomentsType;
> 
>   typedef   itk::CastImageFilter<
>                  InputImageType,
>                  InternalImageType >
> CastImageFilterType;
> 
>   typedef   itk::CurvatureFlowImageFilter<
>                  InternalImageType,
>                  InternalImageType >
> CurvatureFlowImageFilterType;
> 
> 
>   typedef itk::ConnectedThresholdImageFilter<
> 			InternalImageType, SegmentedImageType >
> ConnectedFilterType;
> 
>   typedef itk::ImageToVTKImageFilter<
> SegmentedImageType >
> ITK2VTKConnectorFilterType;
> 
>   typedef itk::VTKImageToImageFilter< InputImageType
>   >
> VTK2ITKConnectorFilterType;
> 
> typedef itk::ImageSeriesReader< InputImageType >
> ReaderType;
> 
>   itk::DICOMImageIO2::Pointer dicomIO =
> itk::DICOMImageIO2::New();
> 
>   // Get the DICOM filenames from the directory
>   itk::DICOMSeriesFileNames::Pointer nameGenerator =
> itk::DICOMSeriesFileNames::New();
> 
>   nameGenerator->SetDirectory( argv[1] );
> 
>          std::cerr << "Usage: viewer1 imagefilename
> xseed yseed zseed neighborhoodsize" << std::endl;
> 
>   typedef std::vector<std::string>
seriesIdContainer;
>   const seriesIdContainer & seriesUID =
> nameGenerator->GetSeriesUIDs();
> seriesIdContainer::const_iterator seriesItr =
> seriesUID.begin();
>   seriesIdContainer::const_iterator seriesEnd =
> seriesUID.end();
>   std::cout << std::endl << "The directory: " <<
> std::endl;
>   //std::cout << std::endl << argv[1] << std::endl
<<
> std::endl;
>   std::cout << "Contains the following DICOM Series:
> ";
>   std::cout << std::endl << std::endl;
>   while( seriesItr != seriesEnd )
>     {
>     std::cout << seriesItr->c_str() << std::endl;
>     seriesItr++;
>     }
> 
>   std::cout << std::endl << std::endl;
>   std::cout << "Now reading series: " << std::endl
<<
> std::endl;
> 
>   typedef std::vector<std::string>
fileNamesContainer;
>   fileNamesContainer fileNames;
>   argc=3;   ///Part One
>   if( argc < 4 ) // If no optional third argument
>     {
>     std::cout << seriesUID.begin()->c_str() <<
> std::endl;
>     fileNames = nameGenerator->GetFileNames();
>     }
>   else  //part Two..
>     {
>     std::cout << argv[3] << std::endl;
>     fileNames = nameGenerator->GetFileNames( argv[3]
> );
>     }
>   std::cout << std::endl << std::endl;
> 
>   ReaderType::Pointer reader = ReaderType::New();
>   reader->SetFileNames( fileNames );
>   reader->SetImageIO( dicomIO );
> 
>   try
>     {
>     reader->Update();
>     }
>   catch (itk::ExceptionObject &ex)
>     {
>     std::cout << ex << std::endl;
>     return EXIT_FAILURE;
>     }
> 
> 
>   CastImageFilterType::Pointer cast =
> CastImageFilterType::New();
> 
>   CurvatureFlowImageFilterType::Pointer smoothing =
> CurvatureFlowImageFilterType::New();
> 
> 
>   ConnectedFilterType::Pointer connectedThreshold =
> 	  ConnectedFilterType::New();
> 
>   VTK2ITKConnectorFilterType::Pointer
VTK2ITKconnector
> =
> VTK2ITKConnectorFilterType::New();
>   ImageMomentsType::Pointer
> calculator=ImageMomentsType::New();
> 
> 
>   cast->SetInput( reader->GetOutput() );
> 
>   smoothing->SetInput(  cast->GetOutput() );
>   confidence->SetInput( smoothing->GetOutput() );
> 
>   smoothing->SetTimeStep( 0.125 );
>   smoothing->SetNumberOfIterations( 2 );
>     connectedThreshold->SetInput(
> smoothing->GetOutput() );
> 
> 	 const InternalPixelType lowerThreshold = 190;
>   const InternalPixelType upperThreshold = 205;
>   connectedThreshold->SetLower(  lowerThreshold  );
>   connectedThreshold->SetUpper(  upperThreshold  );
>   connectedThreshold->SetReplaceValue( 255 );
> 
> 
>   typedef ConnectedFilterType::IndexType IndexType;
>   IndexType seed;
>   seed[0] = 126;
>   seed[1] = 126;
>   seed[2] = 9;
> 
>   std::cout << "Using seed = " << seed << std::endl;
>   connectedThreshold->SetSeed( seed );
> 
>   //confidence->SetInitialNeighborhoodRadius( 2);
> 
>   ITK2VTKConnectorFilterType::Pointer
ITK2VTKconnector
> =
> ITK2VTKConnectorFilterType::New();
> 
>     SetImage( connectedThreshold->GetOutput() );
 calculator->Compute();

> 
>// double area = calculator->GetTotalMass();
...,,,

vtk_visualization...,,,,,etc..,
...,

__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com