diff options
author | Tomas Farago <sensej007@email.cz> | 2019-12-11 14:57:08 +0100 |
---|---|---|
committer | Tomas Farago <sensej007@email.cz> | 2019-12-11 14:57:08 +0100 |
commit | f3b94ec94002c9557ecd2c32dc619d7ddb3fba0c (patch) | |
tree | 047e1c2bf978125be7ab8eb0164b3b461ff07dbc | |
parent | 5115b59d5d6afbfc0599d26f410346fa07d73406 (diff) | |
download | ufo-filters-f3b94ec94002c9557ecd2c32dc619d7ddb3fba0c.tar.gz ufo-filters-f3b94ec94002c9557ecd2c32dc619d7ddb3fba0c.tar.bz2 ufo-filters-f3b94ec94002c9557ecd2c32dc619d7ddb3fba0c.tar.xz ufo-filters-f3b94ec94002c9557ecd2c32dc619d7ddb3fba0c.zip |
flatten: average two middle values on even depth
-rw-r--r-- | src/ufo-flatten-task.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ufo-flatten-task.c b/src/ufo-flatten-task.c index 36c45e7..c59e2be 100644 --- a/src/ufo-flatten-task.c +++ b/src/ufo-flatten-task.c @@ -136,7 +136,12 @@ ufo_flatten_task_process (UfoTask *task, tmp[i] = in_mem[i * width * height + y * width + x]; qsort ((gpointer) tmp, depth, sizeof(gfloat), cmp_float); - out_mem[y * width + x] = tmp[depth / 2]; + if (depth % 2) { + out_mem[y * width + x] = tmp[depth / 2]; + } else { + /* Average two middle values if depth is even */ + out_mem[y * width + x] = (tmp[depth / 2] + tmp[depth / 2 - 1]) / 2.0f; + } } } |