[Insight-users] ImageKmeansModelEstimator parameters

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 16 08:47:45 EDT 2008



Hi Tom,

The Estimator is not a filter. The output of the KMeans estimation is
an array of parameters representing the coordinates of the means.

Please look at the examples in


            Insight/Examples/Statistics

in particular to:

           ScalarImageKmeansModelEstimator.cxx


You should now take the output of the Estimator and use it
in the classifier.

Look in particular to the example:

          ScalarImageKmeansClassifier.cxx


Note that in the new refactoring of the Statistics Framework,
these classes have been converted to Filters.

http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007
http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_New_Statistics_Framework


This probably will be integrated with ITK 4.0.


     Regards,


        Luis


-----------------
Tom Nash wrote:
> 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 > 
> <http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageKmeansModelEstimator.html#aed8380a159b75d128cd7d4c38caac88> 
> 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! <http://computing.in.msn.com/>
> ------------------------------------------------------------------------
> MSN Technology brings you the latest on gadgets, gizmos and the new hits 
> in the gaming market. Try it now! <http://computing.in.msn.com/>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list