[GRASS-dev] r.texture: nonsense values
Jarekj Jasiewicz
jarek.jasiewicz at gmail.com
Sun Apr 3 15:22:17 EDT 2011
Hi
Entropy map created by r.texture has nonsense values.
On uniform areas where there is only one category entropy shall be 0 but
is 0.127575
probably the reason is in formula used in source code:
line 567, h_measure.c
float f9_entropy(float **P, int Ng)
/* Entropy */
{
int i, j;
float entropy = 0;
for (i = 0; i < Ng; ++i)
for (j = 0; j < Ng; ++j)
entropy += P[i][j] * log10(P[i][j] + EPSILON); //<- here
return -entropy;
}
According to my knowledge about entropy it shall be
shall be:
entropy += P[i][j] * ln(P[i][j] +EPSILON)/ln(2.);
J.
More information about the grass-dev
mailing list