Exception on getPixels() ImageProcessor method
Posted by nicola76b@libero.it on Jul 05, 2006; 2:03pm
URL: http://imagej.273.s1.nabble.com/Exception-on-getPixels-ImageProcessor-method-tp3702293.html
Hi all,
I'm developing a Java application that use ij libraries.
I'm writing a class that process a variable number of JPG input images and calculate averagePixels image.
Normally input images are like "blank" image (or enough bright..).
I've see that procedure work, but on some images (especially when images are particular bright..) a "java.lang.ClassCastException: [B" occours.
Here's a simplify parted of incriminated code:
------------------------------------------------------------------
int dim = (imp.getWidth() * imp.getHeight());
int[] pixelData = new int[dim];
pixelData = (int[]) imp.getProcessor().getPixels();
------------------------------------------------------------------
After many trying, I've see that if in place of "int" I use "byte" error does not occour.
On the whole I use jpg COLOR images, so I think to understand reading "writing ImageJ Plugins-A tutorial", I should use ColorProcessor that return the pixels array as an int[]....
How can I avoid this problem??
Is there a simple tip to obtain getpixels() as an integer array for ALL passed images???
Thanks,
Nicola