reading black/white image in java with TYPE_USHORT_GRAY
问题 I have the following code to read a black-white picture in java. imageg = ImageIO.read(new File(path)); BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_USHORT_GRAY); Graphics g = bufferedImage.createGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); int w = img.getWidth(); int h = img.getHeight(); int[][] array = new int[w][h]; for (int j = 0; j < w; j++) { for (int k = 0; k < h; k++) { array[j][k] = img.getRGB(j, k);