summaryrefslogtreecommitdiffstats
path: root/src/kernels/interpolator.cl
diff options
context:
space:
mode:
authorTomas Farago <sensej007@email.cz>2021-12-15 16:22:05 +0100
committerTomas Farago <sensej007@email.cz>2021-12-15 16:22:05 +0100
commite032d752dc9e4723445d82a099cc02163df3ddd3 (patch)
tree86430966d84e68633da666f470f98aa5a045157c /src/kernels/interpolator.cl
parent4c5d52debe42d0ad3d04df03e0bb462d11854b51 (diff)
downloadufo-filters-e032d752dc9e4723445d82a099cc02163df3ddd3.tar.gz
ufo-filters-e032d752dc9e4723445d82a099cc02163df3ddd3.tar.bz2
ufo-filters-e032d752dc9e4723445d82a099cc02163df3ddd3.tar.xz
ufo-filters-e032d752dc9e4723445d82a099cc02163df3ddd3.zip
horizontal-interpolate: add use-one-sided-gradient
Which gives finer contol over what happens when the mask spans to the border.
Diffstat (limited to 'src/kernels/interpolator.cl')
-rw-r--r--src/kernels/interpolator.cl23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/kernels/interpolator.cl b/src/kernels/interpolator.cl
index 6600af9..4d4eae8 100644
--- a/src/kernels/interpolator.cl
+++ b/src/kernels/interpolator.cl
@@ -53,7 +53,8 @@ interpolate_horizontally (global float *a,
kernel void
interpolate_mask_horizontally (global float *input,
global float *mask,
- global float *output)
+ global float *output,
+ const int use_gradient)
{
const int idx = get_global_id (0);
const int idy = get_global_id (1);
@@ -73,9 +74,13 @@ interpolate_mask_horizontally (global float *input,
if (left < 0) {
/* Mask spans to the left border, use only the right value */
if (right < width - 1) {
- /* There are two valid pixels on the right, use gradient */
- diff = input[offset + right] - input[offset + right + 1];
- output[offset + idx] = input[offset + right] + diff * (right - idx);
+ if (use_gradient) {
+ /* There are two valid pixels on the right, use gradient */
+ diff = input[offset + right] - input[offset + right + 1];
+ output[offset + idx] = input[offset + right] + diff * (right - idx);
+ } else {
+ output[offset + idx] = input[offset + right];
+ }
} else if (right == width - 1) {
/* There is only one valid pixel on the right, which is the only
* valid pixel in this row, so use it's value everywhere */
@@ -87,9 +92,13 @@ interpolate_mask_horizontally (global float *input,
} else if (right >= width) {
/* Mask spans to the right border, use only the left value */
if (left > 0) {
- /* There are two valid pixels on the left, use gradient */
- diff = input[offset + left] - input[offset + left - 1];
- output[offset + idx] = input[offset + left] + diff * (idx - left);
+ if (use_gradient) {
+ /* There are two valid pixels on the left, use gradient */
+ diff = input[offset + left] - input[offset + left - 1];
+ output[offset + idx] = input[offset + left] + diff * (idx - left);
+ } else {
+ output[offset + idx] = input[offset + left];
+ }
} else if (left == 0) {
/* There is only one valid pixel on the left, which is the only
* valid pixel in this row, so use it's value everywhere */