@@ -0,0 +1,1367 @@
+package AppPackage;%0A%0Aimport java.awt.Color;%0Aimport java.awt.Dimension;%0Aimport java.awt.Graphics;%0Aimport java.awt.Image;%0Aimport java.awt.image.BufferedImage;%0A%0Aimport javax.swing.ImageIcon;%0Aimport javax.swing.JPanel;%0A%0Apublic class ConvertGreyscale %7B%0A%0A%09private BufferedImage im;%0A%09private JPanel panel;%0A%0A%09public void setImage (final ImageIcon ic, final JPanel p) %7B%0A%0A%09%09final ImageIcon icon = ic;%0A%09%09final BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),BufferedImage.TYPE_INT_RGB);%0A%09%09final Graphics g = bi.createGraphics();%0A%09%09icon.paintIcon(null, g, 0,0);%0A%09%09g.dispose();%0A%09%09this.im = bi;%0A%09%09this.panel = p;%0A%09%7D%0A%0A%09public ImageIcon Convert () %7B%0A%0A%09%09final Dimension panelSize = panel.getSize();%0A%09%09for(int w = 0; w %3C im.getWidth() ; w++)%09%09%0A%09%09%7B%09%09%09%0A%09%09%09for(int h = 0 ; h %3C im.getHeight() ; h++)%09%09%09%0A%09%09%09%7B%09%09%09%09%0A%09%09%09%09final Color color = new Color(im.getRGB(w, h));%0A%09%09%09%09final int redC = color.getRed();%0A%09%09%09%09final int greenC = color.getGreen();%0A%09%09%09%09final int blueC = color.getBlue();%0A%09%09%09%09final int averageColor = (int) (0.21*redC + 0.71*greenC + 0.07*blueC);%0A%09%09%09%09final Color avg = new Color(averageColor, averageColor, averageColor);%0A%09%09%09%09im.setRGB(w, h, avg.getRGB());%09%09%09%0A%09%09%09%7D%09%09%0A%0A%09%09%7D%0A%0A%09%09final Image scaledIM = im.getScaledInstance(panelSize.width, panelSize.height, Image.SCALE_SMOOTH);%0A%09%09final ImageIcon icon = new ImageIcon (scaledIM);%0A%09%09return icon;%0A%0A%09%7D%0A%0A%0A%7D%0A

Create ConvertGreyscale.java