Here you can find the source of grayImage(BufferedImage image)
public static BufferedImage grayImage(BufferedImage image)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class Main { public static BufferedImage grayImage(String filename) { return grayImage(new File(filename)); }//from w w w. j av a2 s . c om public static BufferedImage grayImage(File file) { try { BufferedImage image = ImageIO.read(file); return grayImage(image); } catch (Exception e) { e.printStackTrace(); } return null; } public static BufferedImage grayImage(BufferedImage image) { int width = image.getWidth(); int height = image.getHeight(); BufferedImage grayImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int rgb = image.getRGB(i, j); grayImage.setRGB(i, j, rgb + 100); } } return grayImage; } }