i am getting an ArrayIndexoutOfBoundsException while trying to read pixels from image . the code returns the pixel values for some images and not for other images..i tried searching the net, and most of them referred to reading from 0 to n...
The code is given below..any help would be truly appreciated..
i tried writing saving the image in bi,and it gets saved..so bi is never getting null value.. and my image dimension is always 125*150.. i tried printing the values in inputFace,but in those images that doesn't give pixel values,i am not even getting any output while printing... Doesn't array get initialized with 0 as soon as memory is allocated??
And thanks in advance
private double[] getImageData(String imageFileName) {
BufferedImage bi = null;
double[] inputFace = null;
try{
bi = ImageIO.read(new File(imageFileName));
}catch(IOException ioe){
ioe.printStackTrace();
}
if (bi != null){
int imageWidth = bi.getWidth();
int imageHeight = bi.getHeight();
inputFace = new double[imageWidth * imageHeight];
bi.getData().getPixels(0, 0, imageWidth, imageHeight,inputFace);
}
else
{
System.out.println("Null in bi");
}
return inputFace;
}