diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-03-11 21:55:19 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2007-03-12 14:48:11 -0700 |
commit | 14cab8b020f429d346561d8ab70b154b2e3f0668 (patch) | |
tree | 29d26196558665483855aeeada98b2b9ae7997f4 /test/pdiff | |
parent | 789aada06b52e068662f0ac0f7a424c51bcba510 (diff) |
Correct an off-by-one in the reflection of the convolution index.
Currently the convolution code uses the formula 2*(N-1)-n to reflect the index
n when n is greater than or equal to N.
This is wrong as n=N -> 2*(N-1)-N = N-2 instead of N-1.
Furthermore when the image is small, e.g. at the highest levels of the
pyramid, this causes the code to index before the start of the array and
causes valgrind to issue a warning.
Diffstat (limited to 'test/pdiff')
-rw-r--r-- | test/pdiff/lpyramid.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/pdiff/lpyramid.c b/test/pdiff/lpyramid.c index 02fcf2b4..b81d67d7 100644 --- a/test/pdiff/lpyramid.c +++ b/test/pdiff/lpyramid.c @@ -46,8 +46,8 @@ convolve (lpyramid_t *pyramid, float *a, float *b) ny=y+j; if (nx<0) nx=-nx; if (ny<0) ny=-ny; - if (nx>=width) nx=2*(width-1)-nx; - if (ny>=height) ny=2*(height-1)-ny; + if (nx>=width) nx=2*width - nx - 1; + if (ny>=height) ny=2*height - ny - 1; a[index] += Kernel[i+2] * Kernel[j+2] * b[ny * width + nx]; } } |