diff --git a/pipi/filter/median.c b/pipi/filter/median.c index 0be5898..bb2da31 100644 --- a/pipi/filter/median.c +++ b/pipi/filter/median.c @@ -29,7 +29,7 @@ static int cmpint(void const *i1, void const *i2) { - return *(int const *)i1 > *(int const *)i2; + return *(double const *)i1 < *(double const *)i2; } pipi_image_t *pipi_median(pipi_image_t *src, int radius) @@ -104,12 +104,12 @@ pipi_image_t *pipi_median_ext(pipi_image_t *src, int rx, int ry) } /* Sort the list */ - qsort(list, size, sizeof(int), cmpint); + qsort(list, size, sizeof(double), cmpint); if(!gray) { - qsort(list + size, size, sizeof(int), cmpint); - qsort(list + 2 * size, size, sizeof(int), cmpint); - qsort(list + 3 * size, size, sizeof(int), cmpint); + qsort(list + size, size, sizeof(double), cmpint); + qsort(list + 2 * size, size, sizeof(double), cmpint); + qsort(list + 3 * size, size, sizeof(double), cmpint); } /* Store the median value */