public static void onImageCapture(BufferedImage bimg) throws Exception{
            Scanner reader=new Scanner(System.in);
            int locationx;
            int locationy;
            int locationgrtstx;
            int locationgrtsty;
            Robot rob = new Robot();
            rob.setAutoDelay(100);
            double g=0;
            Dimension dim=Toolkit.getDefaultToolkit().getScreenSize();
            int centerx=(int)(640/2);
            int centery=(int)(480/2);
            locationgrtstx=centerx;
            locationgrtsty=centery;

            ArrayList<Integer[]> minLoc=new ArrayList();
            ArrayList min=new ArrayList();
            for(int x=1;x<bimg.getWidth()-1;x++){
                for(int y=1;y<bimg.getHeight()-1;y++){
                    //System.out.println(f(x,y,bimg)+", "+f(locationgrtstx,locationgrtsty,bimg));
                    if((Math.abs(f(x,y,bimg)))>Math.abs(f(locationgrtstx,locationgrtsty,bimg))){
                        locationgrtstx=x;
                        locationgrtsty=y;
                    }
                }
            }
            locationx=(int)(locationgrtstx*(dim.getWidth()/640));
            locationy=(int)(locationgrtsty*(dim.getHeight()/480));
            System.out.println("Max: "+locationx+", "+locationy);
            double minPartDeriv=Math.pow(10, -2.4066);
            if(reader.nextLine().equals("Stop")){
                
            }
//            for(int x=1;x<bimg.getWidth()-1;x++){
//                for(int y=1;y<bimg.getHeight()-1;y++){
//                    g=g(x,y,bimg);
//                    if(Math.abs(g)<minPartDeriv&&g!=0){
//                        Integer[] loc={x,y};
//                        minLoc.add(loc);
//                        min.add(new Integer((int)f(x,y,bimg)));
//                        System.out.println("added new min"+g(x,y,bimg));
//                    }
//                }
//            }

                if(minLoc.size()==1){
                    Integer[] locationBigInt=minLoc.get(0);
                    int[] location={(int)locationBigInt[0],(int)locationBigInt[1]};
                    rob.mouseMove(location[0],location[1]);
                    System.out.println("Location: "+location[0]+","+location[1]);
                }
                else if(minLoc.size()==2){
                    rob.mousePress(InputEvent.BUTTON1_DOWN_MASK);
                    rob.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
                }
                else if(minLoc.size()==3){
                    rob.mousePress(InputEvent.BUTTON1_DOWN_MASK);
                    rob.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
                }

        }