[Insight-users] (no subject)

Lydia Ng lng at insightful.com
Tue, 9 Mar 2004 12:56:44 -0800


The ComputeMoments() API was removed 7 months ago to make it consistent =
with
all the other Calculators. The following should work:

 calculator->SetImage( connectedThreshold->GetOutput() );
 calculator->Compute();

- Lydia

> -----Original Message-----
> From: yasser salman [mailto:yass71 at yahoo.com]
> Sent: Tuesday, March 09, 2004 12:37 PM
> To: insight-users at itk.org
> Cc: Luis Ibanez
> Subject: [Insight-users] (no subject)
>=20
> Hi All
> for this  code how can i get the voxel (or pixel)
> value in the specified location ,also when i'm using
> itk::ImageMomentsCalculator
> the following error occured ..,
> "error C2039: 'ComputeMoments' : is not a member of
> 'ImageMomentsCalculator<class itk::Image<unsigned
> short,3> >'"
>=20
> can any one help me in that..,
> yasser
>=20
>=20
>=20
>=20
>=20
> typedef unsigned short   InputPixelType;
>   typedef float        InternalPixelType;
>   typedef unsigned short   SegmentedPixelType;
>=20
>   typedef itk::Image< InputPixelType, 3 >
> InputImageType;
>   typedef itk::Image< InternalPixelType, 3>
> InternalImageType;
>   typedef itk::Image< SegmentedPixelType, 3 >
> SegmentedImageType;
>=20
> typedef
> itk::ImageMomentsCalculator<SegmentedImageType>
> 		ImageMomentsType;
>=20
>   typedef   itk::CastImageFilter<
>                  InputImageType,
>                  InternalImageType >
> CastImageFilterType;
>=20
>   typedef   itk::CurvatureFlowImageFilter<
>                  InternalImageType,
>                  InternalImageType >
> CurvatureFlowImageFilterType;
>=20
>=20
>   typedef itk::ConnectedThresholdImageFilter<
> 			InternalImageType, SegmentedImageType >
> ConnectedFilterType;
>=20
>   typedef itk::ImageToVTKImageFilter<
> SegmentedImageType >
> ITK2VTKConnectorFilterType;
>=20
>   typedef itk::VTKImageToImageFilter< InputImageType
>   >
> VTK2ITKConnectorFilterType;
>=20
> typedef itk::ImageSeriesReader< InputImageType >
> ReaderType;
>=20
>   itk::DICOMImageIO2::Pointer dicomIO =3D
> itk::DICOMImageIO2::New();
>=20
>   // Get the DICOM filenames from the directory
>   itk::DICOMSeriesFileNames::Pointer nameGenerator =3D
> itk::DICOMSeriesFileNames::New();
>=20
>   nameGenerator->SetDirectory( argv[1] );
>=20
>          std::cerr << "Usage: viewer1 imagefilename
> xseed yseed zseed neighborhoodsize" << std::endl;
>=20
>   typedef std::vector<std::string> seriesIdContainer;
>   const seriesIdContainer & seriesUID =3D
> nameGenerator->GetSeriesUIDs();
> seriesIdContainer::const_iterator seriesItr =3D
> seriesUID.begin();
>   seriesIdContainer::const_iterator seriesEnd =3D
> 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 !=3D seriesEnd )
>     {
>     std::cout << seriesItr->c_str() << std::endl;
>     seriesItr++;
>     }
>=20
>   std::cout << std::endl << std::endl;
>   std::cout << "Now reading series: " << std::endl <<
> std::endl;
>=20
>   typedef std::vector<std::string> fileNamesContainer;
>   fileNamesContainer fileNames;
>   argc=3D3;   ///Part One
>   if( argc < 4 ) // If no optional third argument
>     {
>     std::cout << seriesUID.begin()->c_str() <<
> std::endl;
>     fileNames =3D nameGenerator->GetFileNames();
>     }
>   else  //part Two..
>     {
>     std::cout << argv[3] << std::endl;
>     fileNames =3D nameGenerator->GetFileNames( argv[3]
> );
>     }
>   std::cout << std::endl << std::endl;
>=20
>   ReaderType::Pointer reader =3D ReaderType::New();
>   reader->SetFileNames( fileNames );
>   reader->SetImageIO( dicomIO );
>=20
>   try
>     {
>     reader->Update();
>     }
>   catch (itk::ExceptionObject &ex)
>     {
>     std::cout << ex << std::endl;
>     return EXIT_FAILURE;
>     }
>=20
>=20
>   CastImageFilterType::Pointer cast =3D
> CastImageFilterType::New();
>=20
>   CurvatureFlowImageFilterType::Pointer smoothing =3D
> CurvatureFlowImageFilterType::New();
>=20
>=20
>   ConnectedFilterType::Pointer connectedThreshold =3D
> 	  ConnectedFilterType::New();
>=20
>   VTK2ITKConnectorFilterType::Pointer VTK2ITKconnector
> =3D
> VTK2ITKConnectorFilterType::New();
>   ImageMomentsType::Pointer
> calculator=3DImageMomentsType::New();
>=20
>=20
>   cast->SetInput( reader->GetOutput() );
>=20
>   smoothing->SetInput(  cast->GetOutput() );
>   confidence->SetInput( smoothing->GetOutput() );
>=20
>   smoothing->SetTimeStep( 0.125 );
>   smoothing->SetNumberOfIterations( 2 );
>     connectedThreshold->SetInput(
> smoothing->GetOutput() );
>=20
> 	 const InternalPixelType lowerThreshold =3D 190;
>   const InternalPixelType upperThreshold =3D 205;
>   connectedThreshold->SetLower(  lowerThreshold  );
>   connectedThreshold->SetUpper(  upperThreshold  );
>   connectedThreshold->SetReplaceValue( 255 );
>=20
>=20
>   typedef ConnectedFilterType::IndexType IndexType;
>   IndexType seed;
>   seed[0] =3D 126;
>   seed[1] =3D 126;
>   seed[2] =3D 9;
>=20
>   std::cout << "Using seed =3D " << seed << std::endl;
>   connectedThreshold->SetSeed( seed );
>=20
>   //confidence->SetInitialNeighborhoodRadius( 2);
>=20
>   ITK2VTKConnectorFilterType::Pointer ITK2VTKconnector
> =3D
> ITK2VTKConnectorFilterType::New();
>=20
>   calculator->ComputeMoments(
> connectedThreshold->GetOutput() );
>=20
> double area =3D calculator->GetTotalMass();
>=20
>=20
> __________________________________
> Do you Yahoo!?
> Yahoo! Search - Find what you're looking for faster
> http://search.yahoo.com
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users