MixtureModelPCAStrategy.cpp
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/MixtureModelPCAStrategy.cpp
22 
23  \brief PCA (Principal Component Analysis) strategy for mixture model.
24 */
25 
26 // TerraLib
27 #include "../common/MatrixUtils.h"
28 #include "../common/progress/TaskProgress.h"
29 #include "../raster/Grid.h"
30 #include "../raster/Utils.h"
31 #include "Functions.h"
32 #include "Macros.h"
34 #include "Functions.h"
35 
36 // Boost
37 #include <boost/numeric/ublas/io.hpp>
38 #include <boost/numeric/ublas/matrix.hpp>
39 
40 bool gaussElimination(boost::numeric::ublas::matrix<double>& Z, std::vector<int>& row, unsigned int nComponents);
41 bool fowardBackSubstitution(boost::numeric::ublas::matrix<double>& Z, std::vector<double>& y, unsigned int ys, std::vector<int>& row, unsigned int rows, std::vector<double>& x, unsigned int xs);
42 
43 namespace
44 {
45  static te::rp::MixtureModelPCAStrategyFactory mixtureModelPCAStrategyFactoryInstance;
46 }
47 
49 {
50  reset();
51 }
52 
54 {
55 }
56 
58 {
59  reset();
60 
61  return *this;
62 }
63 
65 {
66 }
67 
69 {
71 }
72 
74 {
75  m_isInitialized = false;
76 }
77 
79 {
80 }
81 
82 bool te::rp::MixtureModelPCAStrategy::initialize(te::rp::StrategyParameters const* const strategyParams) throw(te::rp::Exception)
83 {
84  m_isInitialized = false;
85 
86  te::rp::MixtureModelPCAStrategy::Parameters const* paramsPtr = dynamic_cast<te::rp::MixtureModelPCAStrategy::Parameters const*>(strategyParams);
87 
88  if(!paramsPtr)
89  return false;
90 
91  m_parameters = *(paramsPtr);
92 
93  // TERP_TRUE_OR_RETURN_FALSE(m_parameters.m_acceptanceThreshold > 0 && m_parameters.m_acceptanceThreshold <= 100, "Invalid acceptance threshold [0, 100].")
94 
95  m_isInitialized = true;
96 
97  return true;
98 }
99 
100 bool te::rp::MixtureModelPCAStrategy::execute(const te::rst::Raster& inputRaster, const std::vector<unsigned int>& inputRasterBands,
101  const std::vector<std::string>& inputSensorBands, const std::map<std::string, std::vector<double> >& components,
102  std::vector<te::rst::Raster*>& outputRaster, const bool normalize, const bool enableProgressInterface) throw(te::rp::Exception)
103 {
104 // this source code is based on TerraLib 4
105  TERP_TRUE_OR_RETURN_FALSE(m_isInitialized, "Instance not initialized")
106 
107  const unsigned int nComponents = (unsigned int)components.size();
108  const unsigned int nBands = (unsigned int)inputSensorBands.size();
109 
110  double dummy = outputRaster[0]->getBand(0)->getProperty()->m_noDataValue;
111 
112  bool computeErrorRasters = false;
113  if (nComponents < outputRaster[0]->getNumberOfBands())
114  computeErrorRasters = true;
115 
116 // indexes variables
117  unsigned int i, j, k, m;
118 
119  std::vector<double> Qmax;
120  std::vector<double> Qmin;
121  for (i = 0; i < inputSensorBands.size(); i++)
122  {
123  Qmax.push_back(GetDigitalNumberBandMax(inputSensorBands[i]));
124  Qmin.push_back(GetDigitalNumberBandMin(inputSensorBands[i]));
125  }
126 
127  te::rst::Grid* tmpgrid = new te::rst::Grid(*inputRaster.getGrid());
128 
129  std::vector<te::rst::BandProperty*> tmpbandsProperties;
130  for (unsigned i = 0; i < outputRaster[0]->getNumberOfBands(); i++)
131  {
132  te::rst::BandProperty* bprop = new te::rst::BandProperty(*(outputRaster[0]->getBand(i)->getProperty()));
134  bprop->m_type = te::dt::DOUBLE_TYPE;
135  tmpbandsProperties.push_back(bprop);
136  }
137  std::unique_ptr<te::rst::Raster> tmpRaster(te::rst::RasterFactory::make("MEM", tmpgrid, tmpbandsProperties, std::map<std::string, std::string>()));
138 
139  // used to calculate minimum e maximum values of outputraster
140  std::vector<double> tmp_min;
141  std::vector<double> tmp_max;
142  for (unsigned i = 0; i < outputRaster[0]->getNumberOfBands(); i++)
143  {
144  tmp_min.push_back(std::numeric_limits< double >::max());
145  tmp_max.push_back(-std::numeric_limits< double >::max());
146  if (normalize)
147  {
148  m_min.push_back(0);
149  m_max.push_back(255);
150  }
151  else
152  {
153  m_min.push_back(std::numeric_limits< double >::max());
154  m_max.push_back(-std::numeric_limits< double >::max());
155  }
156  m_minerror.push_back(std::numeric_limits< double >::max());
157  m_maxerror.push_back(-std::numeric_limits< double >::max());
158  }
159 
160  // buildind the SpectralBandsComponents Matrix
161  if (m_transfMatrix.size1() == 0)
162  generateTransformMatrix(inputRasterBands, inputSensorBands, components);
163 
164 // Part I : mathematical processing independend on image data
165 
166 // SpectralBandsComponentsTransposed stores SpectralBandsComponents and other things after
167  boost::numeric::ublas::matrix<double> SpectralBandsComponentsTransposed(nComponents, nBands);
168 
169 // Initializing SpectralBandsComponentsTransposed Matrix = Transpose of SpectralBandsComponents
170  SpectralBandsComponentsTransposed = boost::numeric::ublas::trans(m_transfMatrix);
171 
172 // compute componentsMean vector as the mean coefficient value per band and subtract the componentsMeanAfter from the coefficients matrix
173 // creating two double vectors to store de means of the spectralBands of each component
174  std::vector<double> componentsMean(nBands, 0.0);
175  std::vector<double> componentsMeanAfter(nBands, 0.0);
176 
177  for (j = 0; j < nBands; j++)
178  {
179 // compute original mean (componentsMean)
180  componentsMean[j] = 0;
181  for(i = 0; i < nComponents; i++)
182  componentsMean[j] = componentsMean[j] + SpectralBandsComponentsTransposed(i, j);
183  componentsMean[j] = componentsMean[j] / (double) nComponents;
184 
185 // subtract mean from SpectralBandsComponents and compute new matrix mean (componentsMeanAfter)
186  componentsMeanAfter[j] = 0;
187  for(i = 0; i < nComponents; i++)
188  {
189  SpectralBandsComponentsTransposed(i, j) = SpectralBandsComponentsTransposed(i, j) - componentsMean[j];
190  componentsMeanAfter[j] = componentsMeanAfter[j] + SpectralBandsComponentsTransposed(i, j);
191  }
192  componentsMeanAfter[j] = componentsMeanAfter[j] / (double) nComponents;
193  }
194 
195 // compute covarianceVector vector
196  std::vector<double> covarianceVector(nBands * nBands, 0.0);
197  for(k = 0; k < nBands * nBands; k++)
198  covarianceVector[k] = 0;
199 
200  k = 0 ;
201  for(j = 0; j < nBands; j++)
202  for(m = 0; m < j + 1; m++)
203  {
204  for(i = 0; i < nComponents; i++)
205  covarianceVector[k] = covarianceVector[k] + (SpectralBandsComponentsTransposed(i, j) - componentsMeanAfter[j]) *
206  (SpectralBandsComponentsTransposed(i, m) - componentsMeanAfter[m]);
207  covarianceVector[k] = covarianceVector[k] / (double) nComponents;
208 
209  k++;
210  }
211 
212  k = 0;
213  boost::numeric::ublas::matrix<double> covarianceMatrix(nBands, nBands);
214  for (i = 0; i < nBands; i++)
215  for (j = 0; j <= i; j++)
216  covarianceMatrix(i, j) = covarianceVector[k++];
217 
218 // compute eigenvectors -> auxMatrix and eigenvalues -> tmpMatrix
219  boost::numeric::ublas::matrix<double> auxMatrix(covarianceMatrix);
220  boost::numeric::ublas::matrix<double> tmpMatrix;
221 
222  if(!te::common::EigenVectors(covarianceMatrix, auxMatrix, tmpMatrix))
223  return false; // print error in eigenvectors
224 
225 // keep only significant eigenvectors (nComponents - 1): results eigenReduced
226  boost::numeric::ublas::matrix<double> eigenReduced(nBands, nComponents - 1);
227  for (j = 0; j < nBands; j++)
228  for (i = 0; i < nComponents - 1; i++)
229  eigenReduced(j, i) = auxMatrix(j, i);
230 
231 // rotate SpectralBandsComponentsTransposed to PCA space; result SpectralBandsComponentsPCA
232  boost::numeric::ublas::matrix<double> SpectralBandsComponentsPCA(SpectralBandsComponentsTransposed.size1(), eigenReduced.size2()); // (nrow x ncol)???
233  SpectralBandsComponentsPCA = boost::numeric::ublas::prod(SpectralBandsComponentsTransposed, eigenReduced);
234 
235 // Initialize one more column to SpectralBandsComponentsPCA to incorporate sum restriction to equations; results auxMatrix
236  auxMatrix.resize(SpectralBandsComponentsPCA.size1(), SpectralBandsComponentsPCA.size2() + 1); // nrow, ncol + 1 ???
237  auxMatrix.clear();
238 
239  for (j = 0; j < SpectralBandsComponentsPCA.size1(); j++) // nrow
240  {
241  for (i = 0; i < SpectralBandsComponentsPCA.size2(); i++) // ncol
242  auxMatrix(j, i) = SpectralBandsComponentsPCA(j, i);
243 
244  auxMatrix(j, SpectralBandsComponentsPCA.size2()) = 1.0;
245  }
246 
247 // Transpose auxMatrix; results SpectralBandsComponentsPCA
248  SpectralBandsComponentsPCA.clear();
249  SpectralBandsComponentsPCA = boost::numeric::ublas::trans(auxMatrix);
250 
251 // invert matrix SpectralBandsComponentsPCA; results SpectralBandsComponentsPCA
252  std::vector<int> rows(nComponents, 0);
253 
254  if (!gaussElimination(SpectralBandsComponentsPCA, rows, nComponents))
255  return false; // print "Error in gauss elimination");
256 
257 // Part II : mathematical processing dependend on image data
258 
259 // Initialize matrices that will help to prepare vector Y
260  auxMatrix.resize(1, nBands);
261  auxMatrix.clear();
262  boost::numeric::ublas::matrix<double> ymat(nComponents - 1, nComponents - 1);
263 
264 // initialize proportion vector X and image dependent values for the linear equations Y
265  std::vector<double> x(nComponents, 0.0);
266  std::vector<double> y(nComponents, 0.0);
267 
268  double prop;
269  std::vector<unsigned int> rowsIn(nBands, 0);
270  std::vector<unsigned int> columnIn(nBands, 0);
271  std::vector<unsigned int> columnsIn(nBands, 0);
272  std::vector<double> spectralBandsError(nBands, 0.0);
273 
274  boost::numeric::ublas::matrix<double> rasterRowsIn(nBands, inputRaster.getNumberOfColumns());
275  boost::numeric::ublas::matrix<double> rasterRowsOut(nComponents, inputRaster.getNumberOfColumns());
276 
277  te::common::TaskProgress task(TE_TR("PCA Mixture Model"), te::common::TaskProgress::UNDEFINED, inputRaster.getNumberOfRows());
278  double value;
279  for (unsigned int rowout = 0; rowout < inputRaster.getNumberOfRows(); rowout++)
280  {
281 // read input row for each band
282  for (i = 0; i < nBands; i++)
283  {
284  for (j = 0; j < inputRaster.getNumberOfColumns(); j++)
285  {
286  inputRaster.getValue(j, rowsIn[i], value, inputRasterBands[i]);
287  rasterRowsIn(i, j) = value;
288  }
289 
290 // update next row to be read for band i
291  rowsIn[i]++;
292 
293 // reinitialize first column for band i
294  columnIn[i] = columnsIn[i];
295  }
296 
297 // compute proportions for each column
298  for (unsigned int colout = 0; colout < inputRaster.getNumberOfColumns(); colout++)
299  {
300 // prepare y
301  for (i = 0; i < nBands; i++)
302  auxMatrix(0, i) = (double) (rasterRowsIn(i, columnIn[i])) / Qmax[i] - componentsMean[i];
303 
304  ymat = boost::numeric::ublas::prod(auxMatrix, eigenReduced);
305 
306  for (i = 0; i < nComponents - 1; i++)
307  y[i] = ymat(0, i);
308 
309 // compute proportions
310  if (!fowardBackSubstitution(SpectralBandsComponentsPCA, y, nComponents, rows, nComponents, x, nComponents))
311  return false; // print "error in function fowardBackSubstitution"
312 
313  bool hasdummy = false;
314  for (i = 0; i < nBands; i++) //Verifica se naquele ponto nas imagens existe algum valor dummy
315  {
316  if (((rasterRowsIn(i, colout) == dummy)))
317  hasdummy = true;
318  }
319 
320  if (hasdummy)
321  {
322  for (i = 0; i < nComponents; i++)
323  {
324  rasterRowsOut(i, colout) = dummy; //Ponto ja e dummy
325  columnIn[i]++;
326  }
327  hasdummy = false;
328  continue;
329  }
330 
331 // store proportion in buffers
332  for (i = 0; i < nComponents; i++)
333  {
334  prop = (x[i] * 100 + 100);
335  prop = prop >= Qmax[i] ? Qmax[i] - 1 : prop <= Qmin[i] ? Qmin[i] : prop;
336  rasterRowsOut(i, colout) = prop;
337  }
338 
339  double aux;
340  double error;
341 
342 // verify if it is necessary to compute the error
343  if (computeErrorRasters)
344  {
345  for (unsigned int ii = 0; ii < nBands; ii++)
346  {
347 // compute digital value from the proportions
348  aux = 0.0;
349  for (j = 0; j < nComponents; j++)
350  aux += x[j] * m_transfMatrix(ii, j);
351 
352 // compute error as module of the difference between the original value and aux
353  error = (long) (rasterRowsIn(ii, columnIn[ii])) / Qmax[ii] - aux;
354  if (error < 0)
355  error *= -1;
356 
357  if (computeErrorRasters)
358  rasterRowsIn(ii, colout) = error/* * Qmax[ii]*/; // Itīs using rasterRowsIn to store error
359  }
360  }
361 
362 // update current column number
363  for (i = 0; i < nBands; i++)
364  columnIn[i]++;
365  }
366 
367 // write processed row to disk
368  for (i = 0; i < nComponents; i++)
369  for (j = 0; j < inputRaster.getNumberOfColumns(); j++)
370  {
371  value = rasterRowsOut(i, j);
372  tmpRaster->setValue(j, rowout, value, i);
373  if (value != dummy) //not dummy
374  {
375  tmp_min[i] = value < tmp_min[i] ? value : tmp_min[i];
376  tmp_max[i] = value > tmp_max[i] ? value : tmp_max[i];
377  }
378  }
379 
380 // store output error rasters
381  if (outputRaster.size() > 1)
382  {
383  for (i = 0; i < nComponents; i++)
384  for (j = 0; j < inputRaster.getNumberOfColumns(); j++)
385  {
386  value = rasterRowsIn(i, j);
387  outputRaster[1]->setValue(j, rowout, value, i);
388  m_minerror[i] = value < m_minerror[i] ? value : m_minerror[i];
389  m_maxerror[i] = value > m_maxerror[i] ? value : m_maxerror[i];
390  }
391  }
392  task.pulse();
393  }
394 
395 
396  //Transform to output type
397  for (unsigned r = 0; r < tmpRaster->getNumberOfRows(); r++)
398  {
399  for (unsigned c = 0; c < tmpRaster->getNumberOfColumns(); c++)
400  {
401  for (unsigned b = 0; b < nComponents; b++)
402  {
403  tmpRaster->getValue(c, r, value, b);
404  if (value != dummy)
405  if (normalize) //to 8 bits
406  value = 255 * (value - tmp_min[b]) / (tmp_max[b] - tmp_min[b]);
407  else
408  value = (Qmax[b] - Qmin[b]) * (value - tmp_min[b]) / (tmp_max[b] - tmp_min[b]);
409 
410  outputRaster[0]->setValue(c, r, value, b);
411  m_min[b] = value < m_min[b] ? value : m_min[b];
412  m_max[b] = value > m_max[b] ? value : m_max[b];
413  }
414  }
415  }
416 
417  return true;
418 }
419 
421  boost::numeric::ublas::matrix<double>& matrix ) const
422 {
423  matrix = m_transfMatrix;
424  return true;
425 }
426 
427 bool te::rp::MixtureModelPCAStrategy::setTransformMatrix(boost::numeric::ublas::matrix<double>& matrix)
428 {
429  m_transfMatrix = matrix;
430  return true;
431 }
432 
433 bool te::rp::MixtureModelPCAStrategy::generateTransformMatrix(const std::vector<unsigned int>& inputRasterBands, const std::vector<std::string>& inputSensorBands,
434  const std::map<std::string, std::vector<double> >& components)
435 {
436  const unsigned int nComponents = (unsigned int)components.size();
437  const unsigned int nBands = (unsigned int)inputSensorBands.size();
438 
439  // indexes variables
440  unsigned int i, j;
441 
442  std::vector<double> Qmax;
443  for (i = 0; i < inputSensorBands.size(); i++)
444  Qmax.push_back(GetDigitalNumberBandMax(inputSensorBands[i]));
445 
446  // buildind the SpectralBandsComponents Matrix
447  boost::numeric::ublas::matrix<double> SpectralBandsComponents(nBands, nComponents);
448  std::map<std::string, std::vector<double> >::const_iterator it;
449  for (i = 0; i < nBands; i++)
450  for (j = 0, it = components.begin(); it != components.end(); j++, it++)
451  SpectralBandsComponents(i, j) = it->second[i] / Qmax[i];
452 
453  m_transfMatrix = SpectralBandsComponents;
454 
455  return true;
456 }
457 
458 bool te::rp::MixtureModelPCAStrategy::getMinMax(std::vector<double>& min, std::vector<double>& max) const
459 {
460  min = m_min;
461  max = m_max;
462  return true;
463 }
464 
465 bool te::rp::MixtureModelPCAStrategy::getMinMaxError(std::vector<double>& min, std::vector<double>& max) const
466 {
467  min = m_minerror;
468  max = m_maxerror;
469  return true;
470 }
471 
473  : te::rp::MixtureModelStrategyFactory("pca")
474 {
475 }
476 
478 {
479 }
480 
482 {
483  return new te::rp::MixtureModelPCAStrategy();
484 }
485 
486 bool gaussElimination(boost::numeric::ublas::matrix<double>& Z, std::vector<int>& row, unsigned int nComponents)
487 {
488 // verify matrix and vector sizes
489  assert(Z.size1() >= Z.size2());
490  unsigned int nrows = (unsigned int)Z.size1(); // rows = size2?
491  assert(nComponents >= nrows);
492 
493  unsigned int i;
494  unsigned int j;
495  unsigned int k;
496  unsigned int aux;
497  double auxd;
498  double m;
499 
500 // initialize changed rows indicator
501  for (i = 0; i < nrows; i++)
502  row[i] = i;
503 
504 // diagonalization
505  for (k = 0; k < nrows; k++)
506  {
507  i = k;
508  while (Z(i, k) == 0.0)
509  {
510  if (i == nrows - 1)
511  return false; // print "Singular matrix"
512 
513  i++;
514  }
515 
516  if (k != i)
517  {
518 // update changed rows indicator
519  aux = row[i];
520  row[i] = row[k];
521  row[k] = aux;
522 
523 // change rows
524  for (j=0; j < nrows; j ++)
525  {
526  auxd = Z(k, j);
527  Z(k, j) = Z (i, j);
528  Z (i, j) = auxd;
529  }
530  }
531 
532 // recompute rows i = k + 1,..., nComponents - 1
533  for (i = k + 1; i < nrows; i++)
534  {
535  m = Z(i, k)/Z(k, k);
536  Z(i, k) = m;
537  for (j = k + 1; j < nrows; j++)
538  Z (i, j) = Z (i, j) - m * Z(k, j);
539  }
540 
541  }
542 
543  if (Z(nrows - 1, nrows - 1) == 0.0)
544  return false; // print "Singular Matrix"
545 
546  return true;
547 }
548 
549 bool fowardBackSubstitution(boost::numeric::ublas::matrix<double>& Z, std::vector<double>& y, unsigned int ys, std::vector<int>& row, unsigned int rows, std::vector<double>& x, unsigned int xs)
550 {
551 // verify matrix size
552  assert(Z.size1() >= Z.size2());
553  unsigned int nrows = (unsigned int)Z.size1(); // rows = size2?
554 
555  if (((rows < nrows) || (ys < nrows) || (xs < nrows)))
556  return false; // print "Vector Size"
557 
558  int j, k;
559  double aux;
560  std::vector<double> F(nrows, 0.0);
561 
562 // foward substuitution
563  for (k = 0; k < (int) nrows; k++)
564  {
565  aux = 0.0;
566  for (j = 0; j <= k - 1; j++)
567  aux = aux + Z(k, j) * F[j];
568 
569  F[k] = y[row[k]] - aux;
570  }
571 
572 // backward substitution
573  for (k = ((int) nrows) - 1; k >= 0; k--)
574  {
575  aux = 0.0;
576  for (j = k + 1; j < (int) nrows; j++)
577  aux = aux + Z(k, j) * x[j];
578 
579  x[k] = (F[k] - aux) / Z(k, k);
580  }
581 
582  return true;
583 }
double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band.
Raster Mixture model strategy factory base class.
Index into a lookup table.
A raster band description.
Definition: BandProperty.h:61
Base exception class for plugin module.
bool fowardBackSubstitution(boost::numeric::ublas::matrix< double > &Z, std::vector< double > &y, unsigned int ys, std::vector< int > &row, unsigned int rows, std::vector< double > &x, unsigned int xs)
std::vector< double > m_maxerror
Maximum error value.
bool initialize(StrategyParameters const *const strategyParams)
Initialize the segmentation strategy.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
bool getTransformMatrix(boost::numeric::ublas::matrix< double > &matrix) const
Returns the used transformation matrix (when applicable).
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
std::vector< double > m_max
Maximum value.
int m_type
The data type of the elements in the band ( See te::dt namespace basic data types for reference )...
Definition: BandProperty.h:133
std::vector< double > m_minerror
Minimun error value.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
double GetDigitalNumberBandMin(std::string bandName)
Returns the minimum digital number of a given sensor/band.
MixtureModelPCAStrategy::Parameters m_parameters
Internal execution parameters.
#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...
Definition: Macros.h:185
bool setTransformMatrix(boost::numeric::ublas::matrix< double > &matrix)
Sets the used transformation matrix.
int b
Definition: TsRtree.cpp:32
Raster mixture model strategy base class.
An abstract class for raster data strucutures.
bool getMinMax(std::vector< double > &, std::vector< double > &) const
URI C++ Library.
Definition: Attributes.h:37
const Parameters & operator=(const Parameters &params)
Raster strategy parameters base class.
Raster PCA mixture model strategy factory.
std::vector< double > m_min
Transformation matrix;.
bool EigenVectors(const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &eigenVectorsMatrix, boost::numeric::ublas::matrix< T > &eigenValuesMatrix)
Computes the eigenvectors of a given matrix.
Definition: MatrixUtils.h:250
Abstract parameters base interface.
bool gaussElimination(boost::numeric::ublas::matrix< double > &Z, std::vector< int > &row, unsigned int nComponents)
AbstractParameters * clone() const
Create a clone copy of this instance.
bool generateTransformMatrix(const std::vector< unsigned int > &inputRasterBands, const std::vector< std::string > &inputSensorBands, const std::map< std::string, std::vector< double > > &components)
Generates the used transformation matrix (when applicable).
boost::numeric::ublas::matrix< double > m_transfMatrix
bool m_isInitialized
True if this instance is initialized.
bool getMinMaxError(std::vector< double > &, std::vector< double > &) const
bool execute(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< std::string > &inputSensorBands, const std::map< std::string, std::vector< double > > &components, std::vector< te::rst::Raster * > &outputRaster, const bool normalize, const bool enableProgressInterface)
Executes the segmentation strategy.
static Raster * make()
It creates and returns an empty raster with default raster driver.
Raster Processing functions.
PCA (Principal Component Analysis) strategy for mixture model.
te::rp::MixtureModelStrategy * build()
Concrete factories (derived from this one) must implement this method in order to create objects...
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
ColorInterp m_colorInterp
The color interpretation.
Definition: BandProperty.h:140