Here you can find the source of imageToGrayscale(BufferedImage img)
public static BufferedImage imageToGrayscale(BufferedImage img)
//package com.java2s; //License from project: Open Source License import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; public class Main { private static ColorConvertOp colorConvert = new ColorConvertOp( ColorSpace.getInstance(ColorSpace.CS_GRAY), null); public static BufferedImage imageToGrayscale(BufferedImage img) { colorConvert.filter(img, img);/*ww w. j a va2s . c o m*/ return img; } }