[Insight-developers] Re: [Insight-users] a cast problem ?
Lagaffe
lagaffe74130 at yahoo.fr
Sat Oct 1 09:38:02 EDT 2005
Well, this is how to use the
itkMahalanobisDistanceMembershipFunction with the head
version fo CVS with the code I put below:
MahalanobisDistance->SetMean(*(meanAlgorithm->GetOutput()));
instead of:
MahalanobisDistance->SetMean(meanAlgorithm->GetOutput());
So,now it works, but I am not sure it is the best
solution to invoke the filter ... (this is why a put a
copy of this mail to the ITK developpers)
Hope it will help you,
Arnaud
--- Lagaffe <lagaffe74130 at yahoo.fr> a écrit :
> Hello Karthik,
>
> I did a checkout this morning, for your last update
> concerning the SetMean function of the
> itkMahalanobisDistanceMembershipFunction filter ...
> But there is still a problem ...
> error: invalid conversion from 'itk::Array<double>*'
> to 'unsigned int'
>
> So, I did a simple program below, that evaluate the
> mahalanobis distance so you can easily check if the
> filter work with the new convention (itkArray)
> Hope it will help you and I to debug the filter ;-)
> thanks
> arnaud
>
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
> #include "itkVector.h"
> #include "itkListSample.h"
> #include "itkMeanCalculator.h"
> #include "itkCovarianceCalculator.h"
> #include
> "itkMahalanobisDistanceMembershipFunction.h"
> int main()
> {
>
> const unsigned int MeasurementVectorLength = 3;
> typedef itk::Vector< float, MeasurementVectorLength
> >
> MeasurementVectorType;
> typedef itk::Statistics::ListSample<
> MeasurementVectorType > SampleType;
> SampleType::Pointer sample = SampleType::New();
> sample->SetMeasurementVectorSize(
> MeasurementVectorLength );
> MeasurementVectorType mv;
> mv[0] = 1.0;
> mv[1] = 2.0;
> mv[2] = 4.0;
>
> sample->PushBack( mv );
>
> mv[0] = 2.0;
> mv[1] = 4.0;
> mv[2] = 5.0;
> sample->PushBack( mv );
>
> mv[0] = 3.0;
> mv[1] = 8.0;
> mv[2] = 6.0;
> sample->PushBack( mv );
>
> mv[0] = 2.0;
> mv[1] = 7.0;
> mv[2] = 4.0;
> sample->PushBack( mv );
>
> mv[0] = 3.0;
> mv[1] = 2.0;
> mv[2] = 7.0;
> sample->PushBack( mv );
> typedef itk::Statistics::MeanCalculator< SampleType
> >
> MeanAlgorithmType;
>
> MeanAlgorithmType::Pointer meanAlgorithm =
> MeanAlgorithmType::New();
>
> meanAlgorithm->SetInputSample( sample );
> meanAlgorithm->Update();
>
> std::cout << "Sample mean = " <<
> *(meanAlgorithm->GetOutput()) << std::endl;
>
> typedef itk::Statistics::CovarianceCalculator<
> SampleType >
> CovarianceAlgorithmType;
> CovarianceAlgorithmType::Pointer
> covarianceAlgorithm
> =
> CovarianceAlgorithmType::New();
>
> covarianceAlgorithm->SetInputSample( sample );
> covarianceAlgorithm->SetMean(
> meanAlgorithm->GetOutput() );
> covarianceAlgorithm->Update();
>
> std::cout << "Sample covariance = " << std::endl ;
> std::cout << *(covarianceAlgorithm->GetOutput()) <<
> std::endl;
>
> typedef
>
itk::Statistics::MahalanobisDistanceMembershipFunction<
> MeasurementVectorType >
> MahalanobisDistanceMembershipFunctionType;
> MahalanobisDistanceMembershipFunctionType::Pointer
> MahalanobisDistance =
> MahalanobisDistanceMembershipFunctionType::New();
>
>
MahalanobisDistance->SetMean(meanAlgorithm->GetOutput());
>
>
MahalanobisDistance->SetCovariance(covarianceAlgorithm->GetOutput()->GetVnlMatrix());
> std::cout << "Mahalanobis distance=" <<
> MahalanobisDistance->Evaluate(mv) << std::endl;
>
> return 0;
> }
>
>
>
>
>
>
>
>
___________________________________________________________________________
>
> Appel audio GRATUIT partout dans le monde avec le
> nouveau Yahoo! Messenger
> Téléchargez cette version sur
> http://fr.messenger.yahoo.com
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
More information about the Insight-developers
mailing list