[Insight-users] ImageKmeansModelEstimator parameters
Tom Nash
tomnash1 at hotmail.com
Tue Oct 14 22:56:26 EDT 2008
Hi Luis\All
When I changed the last line of code to applyKmeansEstimator->SetInputImage(reader->GetOutput()); It worked. So guess that problem is solved.
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.
Please help
Sincerely
Tom
From: tomnash1 at hotmail.com
To: insight-users at itk.org
Subject: ImageKmeansModelEstimator parameters
Date: Mon, 13 Oct 2008 22:00:09 +0000
Hi All
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:
typedef itk::Vector< short, 3 > VecImagePixelType;
typedef itk::Image< VecImagePixelType, 3 > VecImageType;
typedef itk::ImageFileReader< VecImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "Image.nii" );
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
Now the image is obtained in the reader object.
Now I do the following:
//----------------------------------------------------------------------
//Set membership function (Using the statistics objects)
//----------------------------------------------------------------------
namespace stat = itk::Statistics;
typedef stat::DistanceToCentroidMembershipFunction< VecImagePixelType >
MembershipFunctionType ;
typedef MembershipFunctionType::Pointer MembershipFunctionPointer ;
typedef std::vector< MembershipFunctionPointer >
MembershipFunctionPointerVector;
//----------------------------------------------------------------------
//Set the image model estimator
//----------------------------------------------------------------------
typedef itk::ImageKmeansModelEstimator<ReaderType, MembershipFunctionType>
ImageKmeansModelEstimatorType;
ImageKmeansModelEstimatorType::Pointer
applyKmeansEstimator = ImageKmeansModelEstimatorType::New();
//----------------------------------------------------------------------
//Set the parameters of the clusterer
//----------------------------------------------------------------------
applyKmeansEstimator->SetInputImage(reader);
But this does not work because I think itk::ImageKmeansModelEstimator< TInputImage, TMembershipFunction > 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
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.
Please help
Sincerely
Tom
MSN Technology brings you the latest on gadgets, gizmos and the new hits in the gaming market. Try it now!
_________________________________________________________________
Search for videos of Bollywood, Hollywood, Mollywood and every other wood, only on Live.com
http://www.live.com/?scope=video&form=MICOAL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081015/88457bfc/attachment.htm>
More information about the Insight-users
mailing list