Re: Convolve bug
Posted by
dscho on
Jul 16, 2008; 2:37pm
URL: http://imagej.273.s1.nabble.com/Convolve-bug-tp3695581p3695582.html
Hi,
On Wed, 16 Jul 2008, Francisco Javier Merino Guardiola wrote:
> I think I've discovered a bug in the convolver plugin:
> kernel index error: 25
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 25
> at ij.plugin.filter.Convolver.convolveFloat(Convolver.java:234)
> at ij.plugin.filter.Convolver.convolve(Convolver.java:173)
> at ij.process.FloatProcessor.convolve(FloatProcessor.java:819)
> at test_convolver.main(test_convolver.java:23)
> Java Result: 1
>
>
> This only happens when I invoke the 'convolve' method TWICE in a
> 'non-plugin' program (if I invoke it only once it works). I also think that
> this doesnt happen when you try to implement a plugin :-S. I think the best
> way to illustrate this is using an example that reproduce the error:
>
> ------ <Code> ------
>
> import ij.process.FloatProcessor;
> import java.util.Random;
>
>
> public class test_convolver {
> public static void main(String []args) {
> Random rand = new Random();
> // Generates random image
> int w = 2048, h = 2048;
> float[] pixels = new float[w*h];
> for(int i=0;i<pixels.length;i++)
> pixels[i]=rand.nextFloat();
> FloatProcessor image = new FloatProcessor(w, h, pixels, null);
> // Random kernel
> int kw = 5, kh = 5;
> float[]kernel = new float[kw*kh];
> for(int i=0;i<kernel.length;i++)
> kernel[i]=rand.nextFloat();
>
> // Convolve twice
> image.convolve(kernel, kw, kh);
> image.convolve(kernel, kw, kh); // Commenting this line works!
> }
> }
>
> ------ </Code> ------
>
>
>
> I think this is an unexpected behavior... is this really a bug? how
> could it be fixed?
Thank you for including the code. I tested it here, and it works just
fine. My platform is Linux/Athlon (32-bit), java -version says
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)
Oh, and I use an ImageJA based on ImageJ 1.41g.
Ciao,
Dscho