#include <itkImageKmeansModelEstimator.h>
Inheritance diagram for itk::ImageKmeansModelEstimator< TInputImage, TMembershipFunction >:


itkImageKmeansModelEstimator generated the kmeans model (cluster centers). This object performs clustering of data sets into different clusters either using user provided seed points as initial guess or generating the clusters using a recursive approach when the user provides the number of desired clusters. Each cluster is represented by its cluster center. The two algorithms used are the generalized Lloyd algorithm (GLA) and the Linde-Buzo-Gray algorithms. The cluster centers are also referred to as codewords and a table of cluster centers is is referred as a codebook.
As required by the GLA algorithm, the initial seed cluster should contain approximate centers of clusters. The GLA algorithm genrates an updated cluster centers that result in a lower distortion than the input seed cluster when the input vectors are mapped/classified/labelled using the given codebooks.
If no codebook is provided, the Linde-Buzo-Gray algorithm is used. This algorithm uses the GLA algorithm at its core to generate the centroids of the input vectors (data). However, since there is no initial codebook, LBG first creates a one word codebook (or centroid of one cluster comprising of all the input training vectors). The LBG uses codeword/or centroid splitting to create increasing number of clusters. Each new set of clusters are optimized using the GLA algorithm. The number of clusters increases as $2^{n}$ n= 0, 1, ... The codebook is expected to be in the form of a vnl matrix, where there are N rows. each row representing the cluster mean of a given cluster. The number of columns in a the codebook should be equal to the input image vector dimension.
The threshold parameter controls the ``optimality'' of the returned codebook where optimality is related to the least possible mean-squared error distortion that can be found by the algorithm. For larger thresholds, the result will be less optimal. For smaller thresholds, the result will be more optimal. If a more optimal result is desired, then the algorithm will take longer to complete. A reasonable threshold value is 0.01.
If, during the operation of the algorithm, there are any unused clusters or cells, the m_OffsetAdd and m_OffsetMultiply parameters is used to split the cells with the highest distortion. This functions will attempt to fill empty cells up to 10 times (unless the overall distortion is zero). Using 0.01 is a reasonable default values for the m_OffsetAdd and m_OffsetMultiply parameters.
If the GLA is unable to resolve the data into the desired number of clusters or cells, only the codewords which were used will be returned.
In terms of clustering, codewords are cluster centers, and a codebook is a table containing all cluster centers. The GLA produces results that are equivalent to the K-means clustering algorithm.
For more information about the algorithms, see A. Gersho and R. M. Gray, {Vector Quantization and Signal Compression}, Kluwer Academic Publishers, Boston, MA, 1992.
This object supports data handling of multiband images. The object accepts the input image in vector format only, where each pixel is a vector and each element of the vector corresponds to an entry from 1 particular band of a multiband dataset. A single band image is treated as a vector image with a single element for every vector.
This function is templated over the type of input image. In addition, a second parameter for the MembershipFunction needs to be specified. In this case a Membership function that store cluster centroids models needs to be specified.
The Update() function enables the calculation of the various models, creates the membership function objects and populates them.
Note: There is a second implementation of k-means algorithm in ITK under the itk::statistics namespace. While this algorithm (GLA/LBG based algorithm) is memory efficient, the other algorithm is time efficient.
Definition at line 127 of file itkImageKmeansModelEstimator.h.
Public Types | |
| typedef vnl_matrix< double > | CodebookMatrixOfDoubleType |
| typedef vnl_matrix< int > | CodebookMatrixOfIntegerType |
| typedef SmartPointer< const Self > | ConstPointer |
| typedef ImageRegionConstIterator< TInputImage > | InputImageConstIterator |
| typedef TInputImage::ConstPointer | InputImageConstPointer |
| typedef ImageRegionIterator< TInputImage > | InputImageIterator |
| typedef TInputImage::PixelType | InputImagePixelType |
| typedef TInputImage::Pointer | InputImagePointer |
| typedef TInputImage | InputImageType |
| typedef TInputImage::PixelType::VectorType | InputImageVectorType |
| typedef TMembershipFunction::Pointer | MembershipFunctionPointer |
| typedef std::vector< MembershipFunctionPointer > | MembershipFunctionPointerVector |
| typedef SmartPointer< Self > | Pointer |
| typedef ImageKmeansModelEstimator | Self |
| typedef ImageModelEstimatorBase< TInputImage, TMembershipFunction > | Superclass |
Public Member Functions | |
| virtual void | AbortGenerateDataOff () |
| virtual void | AbortGenerateDataOn () |
| unsigned int | AddMembershipFunction (MembershipFunctionPointer function) |
| Get the execution progress of a process object The progress is *a floating number | between (0, 1) |
| Set the execution progress of a process object The progress is *a floating number | between (0, 1) |
| virtual LightObject::Pointer | CreateAnother () const |
| virtual void | DebugOff () const |
| virtual void | DebugOn () const |
| virtual void | Delete () |
| void | DeleteAllMembershipFunctions () |
| virtual const bool & | GetAbortGenerateData () |
| virtual CodebookMatrixOfDoubleType | GetCodebook () |
| Command * | GetCommand (unsigned long tag) |
| bool | GetDebug () const |
| virtual InputImageType * | GetInputImage () |
| CodebookMatrixOfDoubleType | GetKmeansResults (void) |
| virtual int | GetMaxSplitAttempts () |
| const MembershipFunctionPointerVector | GetMembershipFunctions () const |
| const MetaDataDictionary & | GetMetaDataDictionary (void) const |
| MetaDataDictionary & | GetMetaDataDictionary (void) |
| virtual unsigned long | GetMTime () const |
| virtual const char * | GetNameOfClass () const |
| unsigned int | GetNumberOfMembershipFunctions () |
| virtual const unsigned int & | GetNumberOfModels () |
| virtual double | GetOffsetAdd () |
| virtual double | GetOffsetMultiply () |
| CodebookMatrixOfDoubleType | GetOutCodebook () |
| meaning *the filter has completed execution *virtual const float & | GetProgress () |
| virtual int | GetReferenceCount () const |
| virtual double | GetThreshold () |
| bool | HasObserver (const EventObject &event) const |
| void | InvokeEvent (const EventObject &) const |
| void | InvokeEvent (const EventObject &) |
| virtual void | Modified () const |
| void | Print (std::ostream &os, Indent indent=0) const |
| virtual void | Register () const |
| void | RemoveAllObservers () |
| void | RemoveObserver (unsigned long tag) |
| virtual void | SetAbortGenerateData (bool _arg) |
| void | SetCodebook (CodebookMatrixOfDoubleType InCodebook) |
| void | SetDebug (bool debugFlag) const |
| virtual void | SetInputImage (InputImageType *_arg) |
| virtual void | SetMaxSplitAttempts (int _arg) |
| void | SetMembershipFunctions (MembershipFunctionPointerVector membershipFunctions) |
| void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
| virtual void | SetNumberOfModels (unsigned int _arg) |
| virtual void | SetOffsetAdd (double _arg) |
| virtual void | SetOffsetMultiply (double _arg) |
| meaning *the filter has completed execution *virtual void | SetProgress (float _arg) |
| virtual void | SetReferenceCount (int) |
| virtual void | SetThreshold (double _arg) |
| virtual void | UnRegister () const |
| void | Update () |
| virtual void | UpdateOutputData () |
| void | UpdateProgress (float amount) |
Static Public Member Functions | |
| static void | BreakOnError () |
| static bool | GetGlobalWarningDisplay () |
| static void | GlobalWarningDisplayOff () |
| static void | GlobalWarningDisplayOn () |
| static Pointer | New () |
| This is a global flag that controls whether any warning *or error messages are displayed *static void | SetGlobalWarningDisplay (bool flag) |
Public Attributes | |
| Allow people to add remove invoke observers(callbacks) to any ITK *object.This is an implementation of the subject/observer design *pattern.An observer is added by specifying an event to respond to *and an itk unsigned lon | AddObserver )(const EventObject &event, Command *) const |
| This is a global flag that controls whether any | debug |
| Get the execution progress of a process object The progress is *a floating number meaning no | progress |
| Set the execution progress of a process object The progress is *a floating number meaning no | progress |
Protected Member Functions | |
| void | Allocate () |
| void | GenerateData () |
| ImageKmeansModelEstimator () | |
| Print out the results on the screen for visual feedback *void | PrintKmeansAlgorithmResults () |
| bool | PrintObservers (std::ostream &os, Indent indent) const |
| virtual void | PrintSelf (std::ostream &os, Indent indent) const |
| virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
| ~ImageKmeansModelEstimator () | |
Protected Attributes | |
| int | m_ReferenceCount |
| SimpleFastMutexLock | m_ReferenceCountLock |
| Methods invoked by virtual Print() to print information about the object *including superclasses.Typically not called by the user(use Print()*instead) but used in the hierarchical print process to combine the *output of several classes.*/virtual void PrintSelf(std voi | PrintHeader )(std::ostream &os, Indent indent) const |
|
|||||
|
Type definition for a double matrix. Definition at line 168 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Type definition for an integer vector. Definition at line 171 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 136 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Definition at line 162 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Definition at line 147 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Type definition for the input image iterator type. Definition at line 159 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Type definition for the input image pixel type. Definition at line 155 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 146 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Type definition for the input image. Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 142 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Type definition for the vector associated with input image pixel type. Definition at line 152 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Type definitions for the membership function . Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 165 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Definition at line 87 of file itkImageModelEstimatorBase.h. |
|
|||||
|
Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 135 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Standard class typedefs. Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 132 of file itkImageKmeansModelEstimator.h. |
|
|||||
|
Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. Definition at line 133 of file itkImageKmeansModelEstimator.h. |
|
|||||||||
|
|
|
|||||||||
|
|
|
|
|
|
|
Turn on and off the AbortGenerateData flag. |
|
||||||||||
|
Stores a MembershipCalculator of a class in its internal vector |
|
|||||||||
|
Allocate memory for the output model. |
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
This method is called when itkExceptionMacro executes. It allows the debugger to break on error. |
|
|
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class. Reimplemented from itk::LightObject. |
|
|
Turn debugging output off. |
|
|
Turn debugging output on. |
|
|
Delete an itk object. This method should always be used to delete an object when the new operator was used to create it. Using the C delete method will not work with reference counting. |
|
|||||||||
|
Method to reset the membership fucntion mean Definition at line 122 of file itkImageModelEstimatorBase.h. |
|
|||||||||
|
Starts the image modelling process Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. |
|
|
Get the AbortGenerateData flag for the process object. Process objects may handle premature termination of execution in different ways. |
|
|||||||||
|
Get the cluster centers. |
|
|
Get the command associated with the given tag. NOTE: This returns a pointer to a Command, but it is safe to asign this to a Command::Pointer. Since Command inherits from LightObject, at this point in the code, only a pointer or a reference to the Command can be used. |
|
|
Get the value of the debug flag. |
|
|
|
|
|||||||||
|
Get the input image. |
|
||||||||||
|
Return the codebook/cluster centers. Definition at line 208 of file itkImageKmeansModelEstimator.h. |
|
|||||||||
|
Get the manimum number of attempts to split a codeword. |
|
|||||||||
|
Method to get mean Definition at line 110 of file itkImageModelEstimatorBase.h. |
|
|
|
|
|
|
|
|
|||||||||
|
Run-time type information (and related methods). Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. |
|
|||||||||
|
Method to number of membership functions Definition at line 116 of file itkImageModelEstimatorBase.h. |
|
|||||||||
|
Get the number of classes. |
|
|||||||||
|
Get the offset add parameter. |
|
|||||||||
|
Get the offset multiplication parameter. |
|
|||||||||
|
Get the optimized codebook or the centroids of the clusters. Definition at line 180 of file itkImageKmeansModelEstimator.h. |
|
|
|
|
|
Gets the reference count on this object. Definition at line 98 of file itkLightObject.h. |
|
|||||||||
|
Get the threshold parameter. |
|
|
Definition at line 100 of file itkObject.h. References itk::Object::SetGlobalWarningDisplay(). |
|
|
Definition at line 98 of file itkObject.h. References itk::Object::SetGlobalWarningDisplay(). |
|
|
Return true if an observer is registered for this event. |
|
|
Call Execute on all the Commands observing this event id. The actions triggered by this call doesn't modify this object. |
|
|
Call Execute on all the Commands observing this event id. |
|
|
|||||||||
|
Method for creation through the object factory. Reimplemented from itk::LightProcessObject. |
|
||||||||||||
|
Cause the object to print itself out. |
|
|||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||||||
|
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes. Reimplemented from itk::ImageModelEstimatorBase< TInputImage, TMembershipFunction >. |
|
||||||||||||
|
|
|
|
Increase the reference count (mark as used by another object). Reimplemented from itk::LightObject. |
|
|
Remove all observers . |
|
|
Remove the observer with this tag value. |
|
|
Set the AbortGenerateData flag for the process object. Process objects may handle premature termination of execution in different ways. |
|
||||||||||
|
Set the cluster centers. |
|
|
Set the value of the debug flag. A non-zero value turns debugging on. |
|
|
Referenced by itk::Object::GlobalWarningDisplayOff(), and itk::Object::GlobalWarningDisplayOn(). |
|
||||||||||
|
Set the input image. |
|
||||||||||
|
Set the maximum number of attempts to split a codeword. |
|
||||||||||
|
Set the classified image. Definition at line 103 of file itkImageModelEstimatorBase.h. |
|
|
|
|
||||||||||
|
Set the number of classes. |
|
||||||||||
|
Set the offset add parameter. |
|
||||||||||
|
Set the offset multiplication parameter. |
|
|
|
|
|
Sets the reference count (use with care) Reimplemented from itk::LightObject. |
|
||||||||||
|
Set the threshold parameter. |
|
|
Decrease the reference count (release by another object). Reimplemented from itk::LightObject. |
|
|||||||||
|
Define a virtual function to perform model generation from the input data |
|
|
Actually generate new output. |
|
|
Update the progress of the process object. If a ProgressMethod exists, executes it. Then set the Progress ivar to amount. The parameter amount should range between (0,1). |
|
|
|
|
|
Definition at line 94 of file itkObject.h. |
|
|
Number of uses of this object by other objects. Definition at line 119 of file itkLightObject.h. |
|
|
Mutex lock to protect modification to the reference count Definition at line 122 of file itkLightObject.h. |
|
|
|
|
|
Definition at line 104 of file itkLightProcessObject.h. |
|
|
Definition at line 98 of file itkLightProcessObject.h. |
1.4.2 written by Dimitri van Heesch,
© 1997-2000