When I first put convolveND in the distribution, there was some
discussion on this list about the wisdom of allowing the code to auto-
select the method used for convolution in the default case, and I
argued that it is OK since the two methods of convolution (direct and
FFT) give the same answer, to within numerical roundoff. Well, I have
finally been bit by that.
I was bit by using convolveND to dilate some binary image masks. The
mask images are either zero or one, and I want to expand all matched
features in the image plane, so I convolved the original mask with a
kernel to expand the nonzero regions; and simply treated the output of
convolveND as the new mask to use, ignoring the actual values in the
array and using only their nonzeroness in a subsequent logical
expression.
If you use convolveND to do mask dilation this way, you are likely to
get the wrong answer if you allow it to use the FFT method and
floating point operations, because "zero" values generally end up
accumulating a few quanta relative to the largest value in the FFT
(typically the sum of all image pixels), and therefore aren't truly
zero in the end. This is a heisenbug because the code autoselects the
convolution method by default, so small kernels, which are evaluated
directly, work and large kernels break.. The heisenbug can be
avoided by forcing integer arithmetic, forcing direct convolution, or
using a nonzero threshold to test for nonzeroness in the output data.
I believe that this is more a wart than a true bug - but needs
documentation. I've just pushed a patch to imageND that includes a
description of the problem and how to avoid it in the convolveND
documentation.
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl