可使用以下代码:

Graphics2D g2d = source.createGraphics();

ColorSpace grayCS = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp colorConvertOp = new ColorConvertOp(grayCS, g2d.getRenderingHints());
colorConvertOp.filter(source, source);

其中source为BufferedImage对象