27 #include "../classification/KMeans.h" 
   28 #include "../common/progress/TaskProgress.h" 
   29 #include "../geometry/Envelope.h" 
   30 #include "../raster/Grid.h" 
   31 #include "../raster/PositionIterator.h" 
   32 #include "../raster/RasterIterator.h" 
  113                                               const std::vector<te::gm::Polygon*>& inputPolygons, 
te::rst::Raster& outputRaster,
 
  114                                               const unsigned int outputRasterBand, 
const bool enableProgressInterface) 
throw(te::rp::Exception)
 
  123   std::vector<unsigned int> classification;
 
  137   if(!classifier.
initialize(classifierParameters))
 
  139   if(!classifier.
train(pit, pitend, inputRasterBands, std::vector<unsigned int>(), 
true))
 
  141   if(!classifier.
classify(rit, ritend, inputRasterBands, classification, 
true))
 
  146   task.
setTotalSteps(inputRaster.getNumberOfColumns() * inputRaster.getNumberOfRows());
 
  150   while (rit != ritend)
 
  152     outputRaster.setValue(rit.
getColumn(), rit.
getRow(), classification[i], outputRasterBand);
 
unsigned int m_maxInputPoints
The maximum number of points used to estimate the clusters (default = 1000). 
double m_epsilon
The stop criteria. When the clusters change in a value smaller then epsilon, the convergence is achie...
Raster KMeans Classifier strategy factory. 
const Parameters & operator=(const Parameters ¶ms)
Raster strategy parameters base class. 
static PointSetIterator begin(const te::rst::Raster *r, const std::vector< te::gm::Point * > p)
Returns an iterator referring to the first value of the band. 
std::vector< te::gm::Point * > GetRandomPointsInRaster(const te::rst::Raster &inputRaster, unsigned int numberOfPoints)
Creates a vector of random positions (points) inside the raster. 
Raster Processing functions. 
void setTotalSteps(int value)
Set the task total stepes. 
KMeans strategy for classification. Step-by-step: 
ClassifierKMeansStrategyFactory()
bool train(TTRAIN &itBegin, TTRAIN &itEnd, const std::vector< unsigned int > &attributesIndices, const std::vector< unsigned int > &labels, const bool enableProgressInterface)
This class implements and iterator to "navigate" over a raster, with a predefined number of bands...
#define TR_RP(message)
It marks a string in order to get translated. This is a special mark used in the Raster Processing mo...
bool initialize(const Parameters ¶ms)
void setCurrentStep(int value)
Set the task current step. 
unsigned int getRow() const 
Returns the current row in iterator. 
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
KMeans strategy for image classification. 
Abstract parameters base interface. 
KMeans strategy for image classification. Step-by-step: 
te::rp::ClassifierStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects...
unsigned int m_maxIterations
The maximum of iterations to perform if convergence is not achieved. 
bool execute(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< te::gm::Polygon * > &inputPolygons, te::rst::Raster &outputRaster, const unsigned int outputRasterBand, const bool enableProgressInterface)
Executes the classification strategy. 
unsigned int m_K
The number of clusters (means) to detect in image. 
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1. 
Raster classifier strategy factory base class. 
~ClassifierKMeansStrategy()
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
bool initialize(StrategyParameters const *const strategyParams)
Initialize the classification strategy. 
static RasterIterator end(Raster *r, const std::vector< unsigned int > &bands)
Returns an iterator referring to after the end of the iterator. 
static PointSetIterator end(const te::rst::Raster *r, const std::vector< te::gm::Point * > p)
Returns an iterator referring to after the end of the iterator. 
ClassifierKMeansStrategy()
~ClassifierKMeansStrategyFactory()
void setMessage(const std::string &message)
Set the task message. 
An abstract class for raster data strucutures. 
This class can be used to inform the progress of a task. 
unsigned int getColumn() const 
Returns the current column in iterator. 
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
ClassifierKMeansStrategy::Parameters m_parameters
Internal execution parameters. 
Raster classifier strategy base class. 
bool classify(TCLASSIFY &itBegin, TCLASSIFY &itEnd, const std::vector< unsigned int > &attributesIndices, std::vector< unsigned int > &classification, const bool enableProgressInterface)
static RasterIterator begin(Raster *r, const std::vector< unsigned int > &bands)
Returns an iterator referring to the first value. 
bool m_isInitialized
True if this instance is initialized. 
AbstractParameters * clone() const 
Create a clone copy of this instance.