27 #include "../geometry.h"
28 #include "../raster/Band.h"
29 #include "../raster/BandIterator.h"
30 #include "../raster/Grid.h"
31 #include "../raster/PositionIterator.h"
32 #include "../raster/Raster.h"
33 #include "../statistics.h"
65 std::vector<double> dvalues = getValuesFromBand(raster, band, polygon);
66 std::vector<std::complex<double> > values;
68 for (
unsigned int i = 0; i < dvalues.size(); i++)
69 values.push_back(dvalues[i]);
78 std::vector<double> values;
87 values.push_back((*it)[band]);
97 std::vector<std::vector<double> > dallvalues = getValuesFromRaster(raster, polygon, bands);
98 std::vector<std::complex<double> > values;
99 std::vector<std::vector<std::complex<double> > > allvalues;
101 for (
unsigned int i = 0; i < dallvalues.size(); i++)
104 for (
unsigned int j = 0; j < dallvalues[i].size(); j++)
105 values.push_back(dallvalues[i][j]);
106 allvalues.push_back(values);
114 assert(bands.size() > 0);
117 std::vector<std::vector<double> > allvalues;
124 for (
unsigned int i = 0; i < bands.size(); i++)
125 allvalues.push_back(std::vector<double> ());
128 for (
unsigned int i = 0; i < bands.size(); i++)
131 allvalues[i].push_back(value);
142 assert(pixels.size() > 0);
152 for (
unsigned int i = 0; i < vpixels.size(); i++)
153 assert(vpixels[i].size() > 0);
154 for (
unsigned int i = 1; i < vpixels.size(); i++)
155 assert(vpixels[0].size() == vpixels[i].size());
156 assert(vpixels.size() == vmeans.size());
161 unsigned int nbands = vpixels.size();
162 unsigned int nvalues = vpixels[0].size();
164 boost::numeric::ublas::matrix<double> covariance(nbands, nbands);
169 for (i = 0; i < nbands; i++)
171 for (j = 0; j < nbands; j++)
172 covariance(i, j) = 0.0;
173 covariance(i, i) = 1000.0;
180 std::complex<double> sum;
181 for (i = 0; i < nbands; i++)
182 for (j = 0; j < nbands; j++)
184 sum = std::complex<double> (0.0, 0.0);
186 for (k = 0; k < nvalues; k++)
187 sum += (vpixels[i][k] - vmeans[i]) * (vpixels[j][k] - vmeans[j]);
189 covariance(i, j) = sum.real() / (nvalues - 1);
TESTATEXPORT void GetNumericStatisticalSummary(std::vector< double > &values, te::stat::NumericStatisticalSummary &ss, double nullVal)
A structure to hold the set of statistics from a set of numerical values.
boost::numeric::ublas::matrix< double > getCovarianceMatrix(const std::vector< std::vector< double > > &vpixels, const std::vector< double > &vmeans)
Returns the covariance matrix between vectors of pixel values.
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
Extraction of attributes from Raster, Bands, and Polygons.
Raster Processing algorithm output parameters base interface.
unsigned int getRow() const
Returns the current row in iterator.
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
An abstract class for raster data strucutures.
std::vector< std::complex< double > > getComplexValuesFromBand(const te::rst::Raster &raster, unsigned int band, const te::gm::Polygon &polygon)
Returns the pixel values (real and imag) for the band, inside the polygon.
std::vector< std::vector< double > > getValuesFromRaster(const te::rst::Raster &raster, const te::gm::Polygon &polygon, std::vector< unsigned int > bands)
Returns the pixel values for all the bands in raster, inside the polygon.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
te::stat::NumericStatisticalSummary getStatistics(std::vector< double > &pixels)
Returns several statistics from a set of pixels.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
RasterAttributes()
Public constructor.
std::vector< double > getValuesFromBand(const te::rst::Raster &raster, unsigned int band, const te::gm::Polygon &polygon)
Returns the pixel values for the band, inside the polygon.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band.
std::vector< std::vector< std::complex< double > > > getComplexValuesFromRaster(const te::rst::Raster &raster, const te::gm::Polygon &polygon, std::vector< unsigned int > bands)
Returns the pixel values (real and imag) for all the bands in raster, inside the polygon.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
unsigned int getColumn() const
Returns the current column in iterator.