Here you can find the source of imageToMatrix(BufferedImage image)
public static int[][] imageToMatrix(BufferedImage image)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { public static int[][] imageToMatrix(BufferedImage image) { int w = image.getWidth(); int h = image.getHeight(); int[][] imageMatrix = new int[w][h]; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { imageMatrix[i][j] = image.getRGB(i, j); }// w w w . j a va 2s . com } return imageMatrix; } }