[Insight-users] How can i use itkImageMomentsCalculator

Lydia Ng lng at insightful . com
Fri, 19 Sep 2003 08:40:14 -0700


Hi Marcelo,

Which version of ITK are you using?
The class was overhauled about 5 weeks ago so that is API is more
consistent with the rest of ITK.

So if you are using a current or ITK 1.4 then you do something like this
(snippet from Testing/Code/Algorithms/itkImageMomentsTest.cxx)

    /* Compute the moments */
    CalculatorType::Pointer moments =3D CalculatorType::New();
    moments->SetImage( image );
    moments->Compute();

    /* Printout info */
    moments->Print( std::cout );

    double ctm =3D moments->GetTotalMass();
    VectorType ccg =3D moments->GetCenterOfGravity();
    VectorType cpm =3D moments->GetPrincipalMoments();
    MatrixType cpa =3D moments->GetPrincipalAxes();

- Lydia


> -----Original Message-----
> From: Marcelo [mailto:marcelo at cci . fmrp . usp . br]
> Sent: Friday, September 19, 2003 8:30 AM
> To: insight-users at itk . org
> Subject: [Insight-users] How can i use itkImageMomentsCalculator
>=20
> Hi user's
>=20
>=20
> How can i use itkImageMomentsCalculator
> I'm try:
>=20
> typedef itk::Image<  float, 2 > InternalImageType;
>=20
> typedef itk :: ImageMomentsCalculator< InternalImageType  >
> MomentsCalculator;
>=20
>=20
> MomentsCalculator :: Pointer  PcalculaArea =3D MomentsCalculator ::
New();
>=20
> PalculaArea->ComputeMoments( isolatedConnected->GetOutput() );
>=20
> double area =3D PcalculaArea->GetTotalMass();
>=20
>=20
>=20
>=20
> /home/marcelo/programas/Segmentacao/Cone3.cxx:230: `Pointer' is not a
> member
> of type `itk::ImageMomentsCalculator<itk::Image<float,2> >'
> /home/marcelo/programas/Segmentacao/Cone3.cxx:230: parse error before
`=3D'
>=20
>=20
> Sorry my question, but i'm starting with ITK.
>=20
> Tanks a lot for your help me
> ________________________________________________
> Message sent using UebiMiau
> 2.7.2
>=20
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users