Loading...
Searching...
No Matches
ClassifierKMeansStrategy.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file terralib/rp/ClassifierKMeansStrategy.h
22
23 \brief KMeans strategy for image classification.
24*/
25
26#ifndef __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
27#define __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
28
29#include "ClassifierStrategy.h"
31#include "Config.h"
32
33namespace te
34{
35 namespace rp
36 {
37 class AlgorithmParametersSerializer;
38
39 /*!
40 \class ClassifierKMeansStrategy
41
42 \brief KMeans strategy for image classification.
43 Step-by-step:
44 1. Define a random solution, creating K values of mean.
45 2. Classify each pixel according to the closest mean.
46 3. Calculate new means using the classified pixels.
47 4. Go back to step 2, or stop depending on the following checks:
48 5. Check if the new means are different from the previous iteration,
49 using the convergence threshold.
50 6. Check if maximum number of iterations has achieved.
51
52 \ingroup rp_class
53 */
55 {
56 public:
57
58 /*!
59 \class Parameters
60
61 \brief Classifier Parameters
62 */
64 {
65 public:
66
67 unsigned int m_K; //!< The number of clusters (means) to detect in image.
68 unsigned int m_maxIterations; //!< The maximum of iterations to perform if convergence is not achieved.
69 unsigned int m_maxInputPoints; //!< The maximum number of points used to estimate the clusters (default = 1000).
70 double m_epsilon; //!< The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achieved.
71
73
75
76 //overload
77 const Parameters& operator=(const Parameters& params);
78
79 //overload
80 void reset() ;
81
82 //overload
83 AbstractParameters* clone() const;
84
85 //overload
86 bool serialize ( AlgorithmParametersSerializer& serializer ) const;
87 };
88
89 public:
90
92
94
95 //overload
96 bool initialize(ClassifierStrategyParameters const* const strategyParams) ;
97
98 //overload
99 bool execute() ;
100
101 protected:
102
103 bool m_isInitialized; //!< True if this instance is initialized.
104 ClassifierKMeansStrategy::Parameters m_parameters; //!< Internal execution parameters.
105
106 };
107
108 /*!
109 \class ClassifierKMeansStrategyFactory
110
111 \brief Raster KMeans Classifier strategy factory.
112
113 \note Factory key: RegionGrowing
114 */
116 {
117 public:
118
120
122
123 //overload
125 };
126
127 } // end namespace rp
128} // end namespace te
129
130#endif // __TERRALIB_RP_INTERNAL_CLASSIFIERKMEANSSTRATEGY_H
131
Raster classifier strategy factory base class.
Raster classifier strategy base class.
A class to standardize algorithm parameters serialization.
Raster KMeans Classifier strategy factory.
te::rp::ClassifierStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
const Parameters & operator=(const Parameters &params)
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...
unsigned int m_maxIterations
The maximum of iterations to perform if convergence is not achieved.
bool serialize(AlgorithmParametersSerializer &serializer) const
Returns a parameter serialization object.
unsigned int m_K
The number of clusters (means) to detect in image.
AbstractParameters * clone() const
Create a clone copy of this instance.
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000).
KMeans strategy for image classification. Step-by-step:
bool m_isInitialized
True if this instance is initialized.
bool execute()
Executes the classification strategy.
bool initialize(ClassifierStrategyParameters const *const strategyParams)
Initialize the classification strategy.
ClassifierKMeansStrategy::Parameters m_parameters
Internal execution parameters.
Raster classifier strategy factory base class.
Raster classifier strategy base class.
TerraLib.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
Proxy configuration file for TerraView (see terraview_config.h).