diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2019-03-14 20:15:34 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2019-03-14 20:15:34 (GMT) |
commit | c571963e83bbc75781b1885b0ef7ca6860ea4fa7 (patch) | |
tree | b343920aedc8771a8627297647f82066e77efcba /tksao/util | |
parent | f11ec933aa77ef7b53e584b4878438cd30a73bc4 (diff) | |
download | blt-c571963e83bbc75781b1885b0ef7ca6860ea4fa7.zip blt-c571963e83bbc75781b1885b0ef7ca6860ea4fa7.tar.gz blt-c571963e83bbc75781b1885b0ef7ca6860ea4fa7.tar.bz2 |
thread contour
Diffstat (limited to 'tksao/util')
-rw-r--r-- | tksao/util/convolve.C | 24 | ||||
-rw-r--r-- | tksao/util/convolve.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tksao/util/convolve.C b/tksao/util/convolve.C index bdc6739..51b5f15 100644 --- a/tksao/util/convolve.C +++ b/tksao/util/convolve.C @@ -116,3 +116,27 @@ void dumpKernel(double* kernel, int k) << kernel[(yy+k)*kk+(xx+k)] << endl; } +void* convolve(double* kernel, double* src, double* dest, + int width, int height, int k) +{ + int kk = 2*k+1; + + double* dptr = dest; + for (int jj=0; jj<height; jj++) { + for (int ii=0; ii<width; ii++, dptr++) { + + for (int nn=jj-k, qq=0; nn<=jj+k; nn++, qq++) { + if (nn>=0 && nn<height) { + register int nd = nn*width; + register int qd = qq*kk; + for (int mm=ii-k, pp=0; mm<=ii+k; mm++, pp++) { + if (mm>=0 && mm<width) + *dptr += src[nd+mm]*kernel[qd+pp]; + } + } + } + } + } + + return NULL; +} diff --git a/tksao/util/convolve.h b/tksao/util/convolve.h index 90b8f74..5aeb551 100644 --- a/tksao/util/convolve.h +++ b/tksao/util/convolve.h @@ -10,4 +10,7 @@ void tophat(double* kernel, int r); void gaussian(double* kernel, int r, double sigma); void elliptic(double* kernel, int r, int m, double ss, double sm, double aa); +void* convolve(double* kernel, double* src, double* dest, + int width, int height, int k); + #endif |