<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi Luis\All<br><br>When I changed the last line of code to applyKmeansEstimator-&gt;SetInputImage(reader-&gt;GetOutput()); It worked. So guess that problem is solved.<br>However i see no function to view the output image after
classification.&nbsp; The older ImageKmeansImageFilter had a
kmeansFilter-&gt;GetOutput() function, but I see no analogous function
in the itkKmeansModelEstimator. How do I get the output? I want to
parse it into the writer object. I am using nifti images.<br><br>Please help<br><br>Sincerely<br>Tom<br><br><hr>From: tomnash1@hotmail.com<br>To: insight-users@itk.org<br>Subject: ImageKmeansModelEstimator parameters<br>Date: Mon, 13 Oct 2008 22:00:09 +0000<br><br>

<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass body.EC_hmmessage
{font-size:10pt;font-family:Tahoma;}
</style>


Hi All<br><br>I am using ImageKmeansModelEstimator and my input image is a Nifti image. Since it has been specified that ImageKmeansModelEstimator requires the input to be of vector type, I have used the following code to read the image:<br><br>typedef itk::Vector&lt; short, 3 &gt;&nbsp;&nbsp;&nbsp; VecImagePixelType;<br>typedef itk::Image&lt; VecImagePixelType, 3 &gt; VecImageType;<br><br>typedef itk::ImageFileReader&lt; VecImageType &gt; ReaderType;<br>ReaderType::Pointer reader = ReaderType::New();<br>reader-&gt;SetFileName( "Image.nii" );<br>try<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; reader-&gt;Update();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; catch( itk::ExceptionObject &amp; err ) <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; } <br><br>Now the image is obtained in the reader object. <br><br>Now I do the following:<br><br>//----------------------------------------------------------------------<br>&nbsp; //Set membership function (Using the statistics objects)<br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; namespace stat = itk::Statistics;<br><br>&nbsp; typedef stat::DistanceToCentroidMembershipFunction&lt; VecImagePixelType &gt; <br>&nbsp;&nbsp;&nbsp; MembershipFunctionType ;<br>&nbsp; typedef MembershipFunctionType::Pointer MembershipFunctionPointer ;<br><br>&nbsp; typedef std::vector&lt; MembershipFunctionPointer &gt; <br>&nbsp;&nbsp;&nbsp; MembershipFunctionPointerVector;<br><br><br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; //Set the image model estimator<br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; typedef itk::ImageKmeansModelEstimator&lt;ReaderType, MembershipFunctionType&gt; <br>&nbsp;&nbsp;&nbsp; ImageKmeansModelEstimatorType;<br><br>&nbsp; ImageKmeansModelEstimatorType::Pointer <br>&nbsp;&nbsp;&nbsp; applyKmeansEstimator = ImageKmeansModelEstimatorType::New();<br><br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; //Set the parameters of the clusterer<br>&nbsp; //----------------------------------------------------------------------<br>&nbsp; applyKmeansEstimator-&gt;SetInputImage(reader);<br><br>But this does not work because I think&nbsp; <a class="EC_el" href="http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageKmeansModelEstimator.html#aed8380a159b75d128cd7d4c38caac88" target="_blank">itk::ImageKmeansModelEstimator&lt; TInputImage, TMembershipFunction &gt;</a> needs TInputImage to be of type itk::Vector::Pointer and not itk::ImageFileReader::Pointer like how I have used. If I change the above to&nbsp;
<br>typedef itk::ImageKmeansModelEstimator&lt;VecImageType, MembershipFunctionType&gt;, the code will compile. But the input is lying in the reader object and is not passed through the model estimator. So How do I go about this? I did not find any SetFileName function in itk::Vector else I could do that. <br><br>Please help<br><br>Sincerely<br>Tom<br> <br><hr>MSN Technology brings you the latest on gadgets, gizmos and the new hits in the gaming market.  <a href="http://computing.in.msn.com/" target="_blank">Try it now!</a>
<br /><hr />MSN Technology brings you the latest on gadgets, gizmos and the new hits in the gaming market.  <a href='http://computing.in.msn.com/' target='_new'>Try it now!</a></body>
</html>