summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Farago <sensej007@email.cz>2019-07-31 17:54:31 +0200
committerTomas Farago <sensej007@email.cz>2020-02-05 10:16:26 +0100
commitb0166f3f68323add5d405b10b8468441b8ab0df9 (patch)
treee2b65fa55b0ae0a357e01e0e99ca6fc537b7bf0e
parent2009b00e1d086e6ccef2d3fab84da2eba7b41c60 (diff)
downloadufo-filters-b0166f3f68323add5d405b10b8468441b8ab0df9.tar.gz
ufo-filters-b0166f3f68323add5d405b10b8468441b8ab0df9.tar.bz2
ufo-filters-b0166f3f68323add5d405b10b8468441b8ab0df9.tar.xz
ufo-filters-b0166f3f68323add5d405b10b8468441b8ab0df9.zip
NLM: use fmax (0.0f, value) only at the end
-rw-r--r--src/kernels/nlm.cl8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/kernels/nlm.cl b/src/kernels/nlm.cl
index d2f6b0f..a094f34 100644
--- a/src/kernels/nlm.cl
+++ b/src/kernels/nlm.cl
@@ -44,16 +44,14 @@ compute_dist (read_only image2d_t input,
tmp = read_imagef (input, sampler, (float2) ((p.x + i) / width, (p.y + j) / height)).x -
read_imagef (input, sampler, (float2) ((q.x + i) / width, (q.y + j) / height)).x;
if (window_coeffs) {
- /* Use gaussian window.
- * Cutoff negative numbers which would cause large weights. */
- dist += fmax (0.0f, window_coeffs[(j + radius) * wsize + (i + radius)] * (tmp * tmp - 2 * variance));
+ dist += window_coeffs[(j + radius) * wsize + (i + radius)] * (tmp * tmp - 2 * variance);
} else {
- dist += fmax (0.0f, tmp * tmp - 2 * variance);
+ dist += tmp * tmp - 2 * variance;
}
}
}
- return dist * coeff;
+ return fmax (0.0f, dist) * coeff;
}
kernel void