<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Hi Andreas:</DIV>
<DIV> </DIV>
<DIV>Thanks so much.</DIV>
<DIV> </DIV>
<DIV>I understand why my program is wrong, but don not know the solution.</DIV>
<DIV> </DIV>
<DIV>Thanks again.</DIV>
<DIV> </DIV>
<DIV>baoyun<BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Andreas Schuh <andreas.schuh.84@googlemail.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Baoyun Li <baoyun_li123@yahoo.com><BR><B><SPAN style="FONT-WEIGHT: bold">Cc:</SPAN></B> "insight-users@itk.org" <insight-users@itk.org><BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Wednesday, March 18, 2009 4:33:29 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: how to template the image dimension or vector dimesion in template function<BR></FONT><BR>Hi Baoyun,<BR><BR>use the static constant itk::Vector::Dimension instead.<BR><BR>typedef typename itk::Vector< double, VectorPixelType::Dimension > MeasurementVectorType;<BR><BR>itk::Vector::GetVectorDimension() is a static method that has to be evaluated at runtime to get the number of components. For template arguments you need constant values that can be derived at compile time. itk::Vector::Dimension,
therefore, is a public static const class member, instead.<BR><BR>--<BR>regards<BR>Andreas<BR><BR>Baoyun Li schrieb:<BR>> Dear Andreas and all:<BR>> Can you please teach me how to template the image dimension or vector dimesion in template function.<BR>> In the following template function, if I give the vector dimension as<BR>> typedef typename itk::Vector< double,NumberOfComponents> MeasurementVectorType;<BR>> where Numberof compoents is obtained as trait<BR>> const unsigned int NumberOfComponents=VectorPixelType::GetVectorDimension();<BR>> The program cannot be build.<BR>> Why and how to solve the problem?<BR>> Thanks<BR>> Baoyun<BR>> template <unsigned int Dim,unsigned int NumberOfComponents1,class TInputFilter, class TOutputFilter><BR>> void EMClustering( typename TInputFilter::Pointer& inputfilter, typename TOutputFilter::Pointer&
outputfilter)<BR>> {<BR>> typedef typename TInputFilter::PixelType VectorPixelType;<BR>> typedef typename TInputFilter::PixelType::SizeType Num;<BR>> const unsigned int NumberOfComponents=VectorPixelType::GetVectorDimension();<BR>> const unsigned int Dim1=TInputFilter::GetImageDimension();<BR>> typedef typename itk::Vector< double,NumberOfComponents> MeasurementVectorType;<BR>> typedef typename itk::Statistics::ListSample< MeasurementVectorType > SampleType;<BR>> // SampleType::Pointer sample = SampleType::New();<BR>> // sample->SetMeasurementVectorSize(NumberOfComponents );<BR>> // MeasurementVectorType mv;<BR>> };<BR>>> ml><BR>> <BR><BR></DIV></DIV></div><br>
</body></html>