<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->SetInputImage(reader->GetOutput()); It worked. So guess that problem is solved.<br>However i see no function to view the output image after
classification. The older ImageKmeansImageFilter had a
kmeansFilter->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< short, 3 > VecImagePixelType;<br>typedef itk::Image< VecImagePixelType, 3 > VecImageType;<br><br>typedef itk::ImageFileReader< VecImageType > ReaderType;<br>ReaderType::Pointer reader = ReaderType::New();<br>reader->SetFileName( "Image.nii" );<br>try<br> {<br> reader->Update();<br> }<br> catch( itk::ExceptionObject & err ) <br> { <br> std::cerr << "ExceptionObject caught !" << std::endl; <br> std::cerr << err << std::endl; <br> return EXIT_FAILURE;<br> } <br><br>Now the image is obtained in the reader object. <br><br>Now I do the following:<br><br>//----------------------------------------------------------------------<br> //Set membership function (Using the statistics objects)<br> //----------------------------------------------------------------------<br> namespace stat = itk::Statistics;<br><br> typedef stat::DistanceToCentroidMembershipFunction< VecImagePixelType > <br> MembershipFunctionType ;<br> typedef MembershipFunctionType::Pointer MembershipFunctionPointer ;<br><br> typedef std::vector< MembershipFunctionPointer > <br> MembershipFunctionPointerVector;<br><br><br> //----------------------------------------------------------------------<br> //Set the image model estimator<br> //----------------------------------------------------------------------<br> typedef itk::ImageKmeansModelEstimator<ReaderType, MembershipFunctionType> <br> ImageKmeansModelEstimatorType;<br><br> ImageKmeansModelEstimatorType::Pointer <br> applyKmeansEstimator = ImageKmeansModelEstimatorType::New();<br><br> //----------------------------------------------------------------------<br> //Set the parameters of the clusterer<br> //----------------------------------------------------------------------<br> applyKmeansEstimator->SetInputImage(reader);<br><br>But this does not work because I think <a class="EC_el" href="http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageKmeansModelEstimator.html#aed8380a159b75d128cd7d4c38caac88" target="_blank">itk::ImageKmeansModelEstimator< TInputImage, TMembershipFunction ></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
<br>typedef itk::ImageKmeansModelEstimator<VecImageType, MembershipFunctionType>, 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>