Results 1 to 7 of 7
  1. #1
    unexpert is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default 2 same methods and parameters

    Hello. I know that having 2 similar methods and parameters will not work in java but is there any way I can solve this without changing the parameters?

    Here's a summarized version of my codes.

    Java Code:
    import ij.ImagePlus;
    import ij.plugin.filter.PlugInFilter;
    import ij.process.ImageProcessor;
    import java.util.Arrays;
    
    public class Filter_Equalize implements PlugInFilter 
    {
        final int T = 4;
        public int setup(String arg, ImagePlus img) 
        {
            return DOES_8G;
        }
    
        public void run(ImageProcessor ip) 
        {
            //codes goes in here...
        } 
     	
        public void run(ImageProcessor ip) 
        {
    	//2nd codes in here
        }
    }
    Hope I can get some help here.

    Thanks

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Hi,
    You have two way or you change the parameters or you change the name method.
    But Why you want do it?
    Last edited by Petr; 01-25-2011 at 05:22 PM.
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default

    What are you trying to accomplish? What do you want to happen?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    unexpert is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default

    Ok, the thing that I would want to achieve is for the program to execute two different instructions.

    Before, I had done this separately. Now, I would like to integrate them together in just 1 file. So, the first run is to filter the noise and the second run is to enhance the image.

  5. #5
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    You can use interface for this.
    for example
    Java Code:
    package client;
    
    public interface ToDo {
        public double invoke(double arg1, double arg2);
    }
    
    
    package client;
    
    public class Sum implements ToDo {
        @Override
        public double invoke(double arg1, double arg2) {
            return arg1 + arg2;
        }
    }
    
    package client;
    
    public class Multiply implements ToDo {
        @Override
        public double invoke(double arg1, double arg2) {
            return arg1 * arg2;
        }
    }
    
    package client;
    
    public class RunEx {
        public static void main(String[] arg) {
            ToDo toDo = new Sum();
            System.out.println("Sum : " + toDo.invoke(1, 2));
            toDo = new Multiply();
            System.out.println("Miltiple : " + toDo.invoke(1, 2));
        }
    }
    Skype: petrarsentev
    http://TrackStudio.com

  6. #6
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by unexpert View Post
    Ok, the thing that I would want to achieve is for the program to execute two different instructions.

    Before, I had done this separately. Now, I would like to integrate them together in just 1 file. So, the first run is to filter the noise and the second run is to enhance the image.

    if the class raise an error like "Duplicate method run(ImageProcessor) in type Filter_Equalize" you will never be able to compile it. either you change the name of one method or the parameter in it.

  7. #7
    unexpert is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default

    err..lost for a lil there but anyways i might be able to solve if i change the parameters but before that i need to obtain the filtered image from the first instructions.

    Java Code:
    public void run(ImageProcessor ip) 
    {
      int w = ip.getWidth();
      int h = ip.getHeight();
      ImageProcessor copy = ip.duplicate(); //return a duplicate of the image
            
      //vector to hold pixels from 3x3 neighborhood
      int[] P = new int[2*T+1];
    
      for (int v=1; v<=h-2; v++) 
      {
         for (int u=1; u<=w-2; u++) 
          {
             //fill the pixel vector P for filter position (u,v)
             int k = 0;
             for (int j=-1; j<=1; j++) 
             {
                for (int i=-1; i<=1; i++) 
                {
                   P[k] = copy.getPixel(u+i,v+j);
                   k++;
                }
              }
              //sort the pixel vector and take center element
              Arrays.sort(P);
              ip.putPixel(u,v,P[T]);
             }
       }    
            
    
    }
    So, from this programme, I will get a filtered image but the problem for me is, how do I declare the new image so that I can include it in the next parameters?
    Last edited by unexpert; 01-25-2011 at 06:42 PM.

Similar Threads

  1. Replies: 8
    Last Post: 04-17-2012, 12:00 AM
  2. Replies: 5
    Last Post: 11-21-2010, 03:08 PM
  3. Parameters
    By MIA6 in forum New To Java
    Replies: 2
    Last Post: 12-22-2009, 02:25 PM
  4. methods with a lot of parameters
    By syncppl in forum New To Java
    Replies: 8
    Last Post: 09-16-2009, 12:39 PM
  5. get parameters in jsp
    By cecily in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-05-2007, 05:29 AM

Posting Permissions

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