public static void huiDuHua(BufferedImage img) {
        int sWight = img.getWidth();
        int sHight = img.getHeight();
        BufferedImage newImage = new BufferedImage(sWight, sHight,
                BufferedImage.TYPE_BYTE_GRAY);
        for (int x = 0; x < sWight; x++) {
            for (int y = 0; y < sHight; y++) {
                int rgb= img.getRGB(x, y);
                newImage.setRGB(x, y, rgb);
            }
        }
         try {
            ImageIO.write(newImage, "jpg", new File("f:/aa.jpg"));
        } catch (IOException e) {
            e.printStackTrace();
        }  
        
    }