[Insight-users] ImageKmeansModelEstimator parameters

Tom Nash tomnash1 at hotmail.com
Mon Oct 13 18:00:09 EDT 2008


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
 
_________________________________________________________________
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/20081013/57422e8c/attachment.htm>


More information about the Insight-users mailing list