[Insight-users] Problem with ImageMomentsCalculator
Luis Ibanez
luis.ibanez at kitware.com
Tue, 09 Mar 2004 16:07:54 -0500
Hi Yasser,
Doxygen will be glad to help you with that
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageMomentsCalculator.html
There is no "ComputeMoments()" method in this class.
The method is:
void Compute (void)
You should bookmark the Doxygen web page in
order to check rapidly the API of any ITK class:
http://www.itk.org/Insight/Doxygen/html/index.html
The alphabetical list of classes is at
http://www.itk.org/Insight/Doxygen/html/classes.html
and the list of *all* methods is at
http://www.itk.org/Insight/Doxygen/html/functions.html
You should use the calculator it as:
calculator->SetImage( otherfilter->GetOutput() );
calculator->Compute();
const CalculatorType::ScalarType mass =
calculator->GetTotalMass();
Regards,
Luis
----------------------
yasser salman wrote:
> 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> >'"
>
> can any one help me in that..,
> yasser
>
>
>
>
>
> 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();
>
> calculator->ComputeMoments(
> connectedThreshold->GetOutput() );
>
> double area = calculator->GetTotalMass();
>
>
> __________________________________
> 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
>