[Insight-users] Re: Insight-users Digest, Vol 18, Issue 1

Xuelin Cui xuelin at hawaii.edu
Sun Oct 2 05:02:52 EDT 2005


good question

Department of Mechanical Engineering
University of Hawaii at Manoa
2540 Dole St
Honolulu HI 96822
United States

----- Original Message -----
From: insight-users-request at itk.org
Date: Saturday, October 1, 2005 6:00 am
Subject: Insight-users Digest, Vol 18, Issue 1

> Send Insight-users mailing list submissions to
> 	insight-users at itk.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.itk.org/mailman/listinfo/insight-users
> or, via email, send a message with subject or body 'help' to
> 	insight-users-request at itk.org
> 
> You can reach the person managing the list at
> 	insight-users-owner at itk.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Insight-users digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: a cast problem ? (Lagaffe)
>   2. Re: a cast problem ? (Lagaffe)
>   3. Re: Problem with ImageDimension and typedef (Bryn)
> 
> 
> -------------------------------------------------------------------
> ---
> 
> Message: 1
> Date: Sat, 1 Oct 2005 14:38:49 +0200 (CEST)
> From: Lagaffe <lagaffe74130 at yahoo.fr>
> Subject: Re: [Insight-users] a cast problem ?
> To: ITK mailing <insight-users at itk.org>
> Message-ID: <20051001123850.98318.qmail at web25807.mail.ukl.yahoo.com>
> Content-Type: text/plain; charset=iso-8859-1
> 
> 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
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Sat, 1 Oct 2005 15:38:02 +0200 (CEST)
> From: Lagaffe <lagaffe74130 at yahoo.fr>
> Subject: Re: [Insight-users] a cast problem ?
> To: Lagaffe <lagaffe74130 at yahoo.fr>,	ITK mailing
> 	<insight-users at itk.org>
> Cc: insight-developers at public.kitware.com
> Message-ID: <20051001133802.9311.qmail at web25807.mail.ukl.yahoo.com>
> Content-Type: text/plain; charset=iso-8859-1
> 
> 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
> 
> 
> ------------------------------
> 
> Message: 3
> Date: 1 Oct 2005 10:58:23 +0200
> From: "Bryn" <blloyd at bwh.harvard.edu>
> Subject: Re: [Insight-users] Problem with ImageDimension and typedef
> To: "Karthik Krishnan" <Karthik.Krishnan at kitware.com>
> Cc: insight-users at itk.org
> Message-ID: <433E4FAF.2070804 at bwh.harvard.edu>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> 
> > I cannot reproduce your problem without seeing a minimal example 
> of  
> > your code...
> >
> I am posting a some code as attachment, to show the problem...
> 
> > The pixeltype for the VectorImage, if you write code, should be 
> > obtained from the Image class.. This is the reason for generic 
> > programming. But if you find it convenient, I can easily add 
> > overloaded  = operators in itk::VariableLengthVector and 
> itk::Array, 
> > which is probably a good thing anyway, since they should be 
> assignable 
> > from each other...
> >
> That would be nice.
> 
> > I still do not understand what compiles in gcc34 and not in 
> gcc33. If 
> > any, I've seen things go the other way......
> >
> It seems that, if I define a templated class which holds a 
> specific type 
> of Image or VectorImage, say VectorImage<int,3>.
> I then typedef  the PixelType from the VectorImage, and finally 
> add a 
> function with this PixelType as argument type, gcc-3.3 compiles ok.
> 
> so say I have something like this (inside the class):
> 
> typedef VectorImage<int,3>    VectorImageType;
> typedef VectorImageType::PixelType PType;
> 
> PType method( PType );
> 
> gcc-3.3 compiles ok.
> 
> 
> But if I change this VectorImage typedef to:
> 
> typedef VectorImage<int,ImageDimension>    VectorImageType;
> 
>        where the ImageDimension is defined by:
> 
>        itkStaticConstMacro(ImageDimension, unsigned int,
>                              TInputImage::ImageDimension);
> 
> 
> 
> gcc-3.3 complains. gcc-3.4 compiles both versions just fine.
> 
> 
> 
> Maybe something I am doing is wrong. It seems it has to do with 
> the way 
> I get the ImageDimension.
> 
> It would be nice to know why the second version doesn't compile 
> with gcc-3.3
> 
> 
> 
> Thanks
> 
> Bryn
> 
> 
> 
> > -karthik
> >
> >>
> >>
> >> Thanks
> >> Bryn
> >>
> >>
> >> _______________________________________________
> >> Insight-users mailing list
> >> Insight-users at itk.org
> >> http://www.itk.org/mailman/listinfo/insight-users
> >>
> 
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: itkVectorImageAndTypedefTest.h
> Type: text/x-chdr
> Size: 1819 bytes
> Desc: not available
> Url : http://public.kitware.com/pipermail/insight-
> users/attachments/20051001/46b840e6/itkVectorImageAndTypedefTest-
0001.h
> -------------- next part --------------
> 
> ///author: Bryn Lloyd
> 
> #ifndef _itkVectorImageAndTypedefTest_txx
> #define _itkVectorImageAndTypedefTest_txx
> 
> 
> 
> 
> 
> namespace itk
> {
> 
> 
> /**
> *    Constructor
> */
> template <class TInputImage,class TOutputImage>
> VectorImageAndTypedefTest<TInputImage,TOutputImage>
> ::VectorImageAndTypedefTest()
> {
> 
> }
> 
> 
> 
> /**
> * Sort an int Array
> */
> template <class TInputImage,class TOutputImage>
> typename 
> 
VectorImageAndTypedefTest<TInputImage,TOutputImage>::TestPixelTypeVecto
rImageAndTypedefTest<TInputImage,TOutputImage>
> ::DoSomething(const TestPixelType& indices)
> {
>  TestPixelType test(3);
>  return test;
> }
> 
> 
> /**
> * Sort an int Array
> */
> template <class TInputImage,class TOutputImage>
> void
> VectorImageAndTypedefTest<TInputImage,TOutputImage>
> ::GenerateData()
> {
> }
> 
> 
> 
> 
> 
> /**
> *  Print Self
> */
> template <class TInputImage,class TOutputImage>
> void 
> VectorImageAndTypedefTest<TInputImage,TOutputImage>
> ::PrintSelf(std::ostream& os, Indent indent) const
> {
>  Superclass::PrintSelf(os,indent);
> }
> 
> 
> 
> } // end namespace itk
> 
> #endif
> 
> ------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> End of Insight-users Digest, Vol 18, Issue 1
> ********************************************
> 



More information about the Insight-users mailing list