Results 1 to 4 of 4
  1. #1
    tommy9avh is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Question Image filter Assignment help

    For my assignment I have to create an emboss filter class and a test program which displays the original image and filtered image.




    This is my test code
    Java Code:
    //
    import java.io.*;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    import java.io.File;
    import java.io.IOException;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.image.Kernel;
    import java.awt.image.ConvolveOp;
    
    
    public class FilterTest{
    public static void main(String[] args) throws IOException
    {
    
    MyEmbossFilter Filter1= new MyEmbossFilter();
                                    
    //Read in image
    BufferedImage img=null;
    
    File imgFile=new File("C:\\Users\\tommy\\Documents\\college2010\\software\\lab5\\Color.jpg");
    try
    {
      img=ImageIO.read(imgFile);
    }
    catch(IOException e)
    {
      e.printStackTrace();
    }
    
    //Display image
    ImageIcon icon=new ImageIcon(img);
    JLabel label=new JLabel(icon);
    
    final JFrame f=new JFrame("Image Display1");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(label);
    f.pack();
    SwingUtilities.invokeLater(new Runnable()
              {
      public void run()
      {
        f.setLocationRelativeTo(null);
        f.setVisible(true);
      }
    }
    );
    
    //Apply filter to image
    
      Filter1.Apply(BufferedImage img2);
      
      System.out.println("\ndebug 5 \n");
    
    //Display filtered image
    ImageIcon icon2= new ImageIcon(img2);
      JLabel label2=new JLabel(icon2);
    
    final JFrame f2= new JFrame("Image Display2");
    f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f2.getContentPane().add(label);
    f2.pack();
    SwingUtilities.invokeLater(new Runnable()
              {
      public void run()
      {
        f2.setLocationRelativeTo(null);
        f2.setVisible(true);
      }
    }
    );
    
    }
    }
    Im getting errors for this line in the test code
    Filter1.Apply(BufferedImage img2);

    Errors:
    1. ')' expected
    2. illegal start of expression


    What am I doing wrong here?
    Is there something missing out of my test program?
    Last edited by tommy9avh; 12-12-2010 at 01:19 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Java Code:
    Filter1.Apply(BufferedImage img2);

    The error occurs because you should not mention the type of img2 when you call the method.

  3. #3
    tommy9avh is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi pbrockway2

    How would I use my Apply(); function to filter the image?

    I then display the filtered image. Is my test ok or does anything need to be changed?

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Call the method like this:

    Java Code:
    Filter1.Apply(img2);

Similar Threads

  1. servlet filter
    By redforce.bala in forum Java Servlet
    Replies: 3
    Last Post: 10-07-2010, 09:21 AM
  2. data filter
    By karq in forum Java Servlet
    Replies: 3
    Last Post: 10-07-2010, 05:40 AM
  3. web content filter or internet filter
    By sundarjothi in forum Advanced Java
    Replies: 3
    Last Post: 05-15-2008, 11:36 AM
  4. Need a filter
    By revathi17 in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 07:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •