Convolve bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Convolve bug

Fco. Javier Merino Guardiola
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
Reply | Threaded
Open this post in threaded view
|

Re: Convolve bug

dscho
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
Reply | Threaded
Open this post in threaded view
|

Re: Convolve bug

Gabriel Landini
On Wednesday 16 July 2008 15:37:01 Johannes Schindelin wrote:
> 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

> 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.

There is a very strange bug -- at least in linux -- possibly in the JIT
compiler that pops up with *multi-core* cpus and gives a similar error.

See line 232 of /ImageJ/source/ij/plugin/filter/Convolver.java for a
workaround.

Cheers,

G.
Reply | Threaded
Open this post in threaded view
|

Re: Convolve bug

dscho
Hi,

On Wed, 16 Jul 2008, Gabriel Landini wrote:

> On Wednesday 16 July 2008 15:37:01 Johannes Schindelin wrote:
> > 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
>
> > 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.
>
> There is a very strange bug -- at least in linux -- possibly in the JIT
> compiler that pops up with *multi-core* cpus and gives a similar error.
>
> See line 232 of /ImageJ/source/ij/plugin/filter/Convolver.java for a
> workaround.

That's why I tested it on a 4-processor 4-core-per-cpu Xeon (64-bit)
machine, and it worked...

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Convolve bug

Fco. Javier Merino Guardiola
Thank you for your answers, I've found the problem but I'm not sure why this
happens :-S

I was running the JVM with the next arguments: -d64 -Xmx2500m but if I run
without those params the program works fine. I think its a problem of runing
the JVM with the 64bit compatibility option.

Im using OSX 10.5.3 on a macbook: Intel Core 2 Duo 2.2GHz + 4GB RAM, with
Java 1.5.0_13.

---
FJMG


2008/7/16 Johannes Schindelin <[hidden email]>:

> Hi,
>
> On Wed, 16 Jul 2008, Gabriel Landini wrote:
>
> > On Wednesday 16 July 2008 15:37:01 Johannes Schindelin wrote:
> > > 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
> >
> > > 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.
> >
> > There is a very strange bug -- at least in linux -- possibly in the JIT
> > compiler that pops up with *multi-core* cpus and gives a similar error.
> >
> > See line 232 of /ImageJ/source/ij/plugin/filter/Convolver.java for a
> > workaround.
>
> That's why I tested it on a 4-processor 4-core-per-cpu Xeon (64-bit)
> machine, and it worked...
>
> Ciao,
> Dscho
>