8 #include <boost/numeric/ublas/matrix.hpp> 14 std::cout <<
"Texture example using cooccurrence matrix." << std::endl << std::endl;
17 std::map<std::string, std::string> rinfo;
18 rinfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers2b_rgb342_crop.tif";
23 double maxPixel, minPixel;
25 if ((maxPixel - minPixel) > 255) {
32 boost::numeric::ublas::matrix<double> glcm_b1 = rattributes.
getGLCM(*rin, 1, 1, -1, minPixel, maxPixel);
36 std::cout <<
"GLCM metrics of full image, band 1" << std::endl;
37 std::cout <<
" contrast: " << metrics.
m_contrast << std::endl;
38 std::cout <<
" dissimilarity: " << metrics.
m_dissimilarity << std::endl;
39 std::cout <<
" energy: " << metrics.
m_energy << std::endl;
40 std::cout <<
" entropy: " << metrics.
m_entropy << std::endl;
41 std::cout <<
" homogeneity: " << metrics.
m_homogeneity << std::endl;
60 double maxPixel, minPixel;
62 if ((maxPixel - minPixel) > 255) {
69 boost::numeric::ublas::matrix<double> glcm_b2 = rattributes.
getGLCM(*rin, 2, 1, 1, *polygon, minPixel, maxPixel);
73 std::cout <<
"GLCM metrics of image crop image, band 2" << std::endl;
74 std::cout <<
" contrast: " << metrics.
m_contrast << std::endl;
75 std::cout <<
" dissimilarity: " << metrics.
m_dissimilarity << std::endl;
76 std::cout <<
" energy: " << metrics.
m_energy << std::endl;
77 std::cout <<
" entropy: " << metrics.
m_entropy << std::endl;
78 std::cout <<
" homogeneity: " << metrics.
m_homogeneity << std::endl;
83 std::cout <<
"Done!" << std::endl << std::endl;
85 catch(
const std::exception& e)
87 std::cout << std::endl <<
"An exception has occurred in Texture(): " << e.what() << std::endl;
91 std::cout << std::endl <<
"An unexpected exception has occurred in Texture()!" << std::endl;
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
void push_back(Curve *ring)
It adds the curve to the curve polygon.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
These routines show how to use the RP (raster processing) module.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
double m_energy
GLCM metric Energy (the square root of Angular Second Moment) ${{i,j=0}^{N-1}P_{i,j}^2}$.
Extraction of attributes from Raster, Bands, and Polygons.
double m_homogeneity
GLCM metric Homogeneity (also called Inverse Difference Moment) ${i,j=0}^{N-1}{P_{i,j}}{1+(i-j)^2}$.
A LinearRing is a LineString that is both closed and simple.
virtual std::complex< double > getMaxValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the maximum occurring value in a window of the band.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
boost::numeric::ublas::matrix< double > getGLCM(const te::rst::Raster &rin, unsigned int band, int dx, int dy, double minPixel, double maxPixel, double gLevels=256)
Computes the Gray-Level Co-occurrence Matrix (GLCM) from a raster band.
An abstract class for raster data strucutures.
double m_dissimilarity
GLCM metric Dissimilarity ${i,j=0}^{N-1}P_{i,j}|i-j|$.
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
This file contains include headers for the TerraLib Raster Processing module.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
te::rp::Texture getGLCMMetrics(boost::numeric::ublas::matrix< double > glcm, double noDataValue=0.0)
Compute texture metrics from GLCM matrix.
double m_entropy
GLCM metric Entropy ${i,j=0}^{N-1}P_{i,j}(-{P_{i,j}})$.
double m_contrast
GLCM metric Contrast (also called Sum of Squares Variance) ${i,j=0}^{N-1}P_{i,j}(i-j)^2$.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
virtual std::complex< double > getMinValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the minimum occurring value in a window of the band.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A structure to hold the set of GLCM metrics.
This file contains include headers for the Vector Geometry model of TerraLib.
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.