java坐标越界:BuffereImage(getrgb)
我必须先找到图像的矩阵,我有这个代码,这给了我一个错误L[row][col] = image.getRGB(row, col);
the error is
“java.lang.ArrayIndexOutOfBoundsException:坐标超出范围!”
这个错误的原因是什么
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import Jama.EigenvalueDecomposition;
import Jama.Matrix;
public class eigenvalues {
double L[][], A[];
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users\\lina\\workspace\\eigen\\koala.jpg");
BufferedImage image= ImageIO.read(file);
int width = image.getWidth();
int height = image.getHeight();
double[][] L = new double[height][width];
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
L[row][col] = image.getRGB(row, col);
}
}
Matrix A=new Matrix(L);
EigenvalueDecomposition e = A.eig();
Matrix V = e.getV();
Matrix D = e.getD();
System.out.print("A =");
A.print(9, 6);
System.out.print("D =");
D.print(9, 6);
System.out.print("V =");
V.print(9, 6);
共 (0) 个答案