diff --git a/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h b/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h index 53b58cda3f7315e2705ca0aa8ed9263d9dad3010..075e5a6a007908aa5f5543ac1d668d4ed8e58d1d 100644 --- a/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h +++ b/Code/FeatureExtraction/otbClusterShadeTextureFunctor.h @@ -29,7 +29,7 @@ namespace Functor * * Computes cluster shade using joint histogram (neighborhood and offset neighborhood). * The formula is: - * \f[ \sum_{i}\sum_{j}((i-\mu)+(j-\mu))^3p(i,j) \f] + * \f[ \sum_{i}\sum_{j}((i-\mu_{x})+(j-\mu_{y}))^3p(i,j) \f] Where \f$ \mu \f$ is the mean texture value. * TIterInput is an iterator, TOutput is a PixelType. * @@ -60,11 +60,24 @@ public: virtual double ComputeOverSingleChannel(const NeighborhoodType& neigh, const NeighborhoodType& neighOff) { this->ComputeJointHistogram(neigh, neighOff); - double mean = Superclass::ComputeOverSingleChannel(neigh, neighOff); + + //compute meanPOff and meanPNeigh double area = static_cast<double>(neigh.GetSize()[0] * neigh.GetSize()[1]); double areaInv = 1 / area; double out = 0.; - + double sumProb = 0.; + + for (unsigned r = 0; r < this->GetHisto().size(); ++r) + { + for (unsigned s = 0; s < this->GetHisto()[r].size(); ++s) + { + double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; + sumProb += p; + } + } + double meanPOff = sumProb / static_cast<double>(this->GetHisto().size()); + double meanPNeigh = sumProb / static_cast<double>(this->GetHisto()[0].size()); + for (unsigned r = 0; r < this->GetHisto().size(); ++r) { for (unsigned s = 0; s < this->GetHisto()[r].size(); ++s) @@ -73,7 +86,7 @@ public: double sumPixel = (static_cast<double>(s) + 0.5) * this->GetNeighBinLength() + (static_cast<double>(r) + 0.5) * this->GetOffsetBinLength(); - out += vcl_pow(sumPixel - 2 * mean, 3) * p; + out += vcl_pow(sumPixel - meanPOff - meanPNeigh, 3) * p; } } diff --git a/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx b/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx index 7305fe6ae1b83cc45ae08e2a894c248bdc06a2d9..700fb04f6cca1a38d151ce35e2fda1773d8f0363 100644 --- a/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx +++ b/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx @@ -18,7 +18,7 @@ // Software Guide : BeginCommandLineArgs // INPUTS: {qb_RoadExtract.tif} -// OUTPUTS: {OBIARadiometricAttribute1.tif}, {qb_ExtractRoad_Radiometry_pretty.png} +// OUTPUTS: {OBIARadiometricAttribute1.tif}, {qb_ExtractRoad_Radiometry_pretty.jpg} // STATS::Ndvi::Mean 0 0.5 16 16 50 1.0 // Software Guide : EndCommandLineArgs