Convolve bug
Posted by Fco. Javier Merino Guardiola on Jul 16, 2008; 2:04pm
URL: http://imagej.273.s1.nabble.com/Convolve-bug-tp3695581.html
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?
---
FJMG