27 #include "../Config.h" 32 #define BOOST_TEST_NO_MAIN 33 #include <boost/test/unit_test.hpp> 34 #include <boost/shared_ptr.hpp> 42 std::map<std::string, std::string> rinfo;
43 rinfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/cbers2b_rgb342_crop.tif";
47 double maxPixel, minPixel;
49 if ((maxPixel - minPixel) > 255) {
57 boost::numeric::ublas::matrix<double> glcm = rattributes.
getGLCM(*rin, 1, 1, -1, minPixel, maxPixel);
62 double myEpsilon = 1e-4;
63 BOOST_CHECK(std::abs(metrics.
m_contrast - 72.554) < myEpsilon);
65 BOOST_CHECK(std::abs(metrics.
m_energy - 0.0806309) < myEpsilon);
66 BOOST_CHECK(std::abs(metrics.
m_entropy - 6.00814) < myEpsilon);
67 BOOST_CHECK(std::abs(metrics.
m_homogeneity - 0.286813) < myEpsilon);
73 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(texture_tests) BOOST_AUTO_TEST_CASE(GLCM_test)
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
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}$.
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.
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$.
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.
BOOST_AUTO_TEST_CASE(encoding_test_utf8_latin1)
A structure to hold the set of GLCM metrics.
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.