From eebc4d5fb9cf6d78cbdba7a5aa9be713ddf9959c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 26 Jul 2017 18:01:15 +0200 Subject: blind{-make,}-kernel: apply identity kernel instead of null kernel to non-selected channels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-kernel.c | 25 +++++++++++++------------ src/blind-make-kernel.c | 25 +++++++++++++------------ 2 files changed, 26 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/blind-kernel.c b/src/blind-kernel.c index f670886..8d0382e 100644 --- a/src/blind-kernel.c +++ b/src/blind-kernel.c @@ -290,23 +290,23 @@ usage: int main(int argc, char *argv[]) { - int null_x = 1, null_y = 1, null_z = 1, null_a = 1; + int id_x = 1, id_y = 1, id_z = 1, id_a = 1; size_t rows, cols, y, x, n; const double *kernel, *kern; - double *buffer, *buf, *free_this; + double *buffer, *buf, *free_this, id_val; ARGBEGIN { case 'x': - null_x = 0; + id_x = 0; break; case 'y': - null_y = 0; + id_y = 0; break; case 'z': - null_z = 0; + id_z = 0; break; case 'a': - null_a = 0; + id_a = 0; break; default: usage(); @@ -315,8 +315,8 @@ main(int argc, char *argv[]) if (!argc) usage(); - if (null_x && null_y && null_z && null_a) - null_x = null_y = null_z = null_a = 0; + if (id_x && id_y && id_z && id_a) + id_x = id_y = id_z = id_a = 0; if (0); #define X(FUNC, NAME)\ @@ -337,10 +337,11 @@ main(int argc, char *argv[]) for (y = 0; y < rows; y++) { buf = buffer; for (x = 0; x < cols; x++) { - buf[0] = null_x ? 0.0 : *kern; - buf[1] = null_y ? 0.0 : *kern; - buf[2] = null_z ? 0.0 : *kern; - buf[3] = null_a ? 0.0 : *kern; + id_val = (x == cols / 2 && y == rows / 2) ? 1. : 0.; + buf[0] = id_x ? id_val : *kern; + buf[1] = id_y ? id_val : *kern; + buf[2] = id_z ? id_val : *kern; + buf[3] = id_a ? id_val : *kern; buf += 4; kern++; } diff --git a/src/blind-make-kernel.c b/src/blind-make-kernel.c index 4253a68..45f2cf9 100644 --- a/src/blind-make-kernel.c +++ b/src/blind-make-kernel.c @@ -82,10 +82,10 @@ main(int argc, char *argv[]) { int normalise = 0; double denominator = 1; - int null_x = 1, null_y = 1, null_z = 1, null_a = 1; + int id_x = 1, id_y = 1, id_z = 1, id_a = 1; size_t rows, cols, y, x, n; double *kernel, *kern, sum = 0, value; - double *buffer, *buf; + double *buffer, *buf, id_val; ARGBEGIN { case 'd': @@ -95,23 +95,23 @@ main(int argc, char *argv[]) normalise = 1; break; case 'x': - null_x = 0; + id_x = 0; break; case 'y': - null_y = 0; + id_y = 0; break; case 'z': - null_z = 0; + id_z = 0; break; case 'a': - null_a = 0; + id_a = 0; break; default: usage(); } ARGEND; - if (null_x && null_y && null_z && null_a) - null_x = null_y = null_z = null_a = 0; + if (id_x && id_y && id_z && id_a) + id_x = id_y = id_z = id_a = 0; if (argc) kernel = read_matrix_cmdline(argv, &rows, &cols); @@ -136,11 +136,12 @@ main(int argc, char *argv[]) for (y = 0; y < rows; y++) { buf = buffer; for (x = 0; x < cols; x++) { + id_val = (x == cols / 2 && y == rows / 2) ? 1. : 0.; value = *kern++ / denominator; - buf[0] = null_x ? 0.0 : value; - buf[1] = null_y ? 0.0 : value; - buf[2] = null_z ? 0.0 : value; - buf[3] = null_a ? 0.0 : value; + buf[0] = id_x ? id_val : value; + buf[1] = id_y ? id_val : value; + buf[2] = id_z ? id_val : value; + buf[3] = id_a ? id_val : value; buf += 4; } ewriteall(STDOUT_FILENO, buffer, n, ""); -- cgit v1.2.3-70-g09d2