Found this on the net only this could be done better

tried to recode it a week ego but failed :(
Can someone try to make this one better?
public static boolean Searchimage(String imagename, int tolerance, boolean movemouse, int random) {
return findImage(imagename, new Dimension(0, 0), new Dimension(Toolkit.getDefaultToolkit().getScreenSize()), tolerance, movemouse, random);
}
public static boolean findImage(String path, Dimension start, Dimension end, int tolerance, boolean move, int random) {
boolean found = false;
try {
Robot r = new Robot();
int checkSum = 0;
BufferedImage searchImg = null;
try {
searchImg = ImageIO.read(new File(path));
} catch (Exception ex) {
System.out.println("Couldn't load the image we are searching for.");
}
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
BufferedImage canvasImg = r.createScreenCapture(new Rectangle(d.width, d.height));
Color firstPixel = new Color(searchImg.getRGB(0, 0));
for (int y = start.height; y < end.height; y++) {
for (int x = start.width; x < end.width; x++) {
Color curPixel = new Color(canvasImg.getRGB(x, y));
if (Math.abs(firstPixel.getRed() - curPixel.getRed()) <= tolerance && Math.abs(firstPixel.getGreen() - curPixel.getGreen()) <= tolerance && Math.abs(firstPixel.getBlue() - curPixel.getBlue()) <= tolerance) {
for (int px = 1; px < searchImg.getWidth(); px++) {
for (int py = 1; py < searchImg.getHeight(); py++) {
Color lapsePixel = new Color(searchImg.getRGB(px, py));
if (px + x >= end.width && py + y >= end.height) {
return false;
}
Color canvasPixel = new Color(canvasImg.getRGB(x + px, y + py));
if (Math.abs(lapsePixel.getRed() - canvasPixel.getRed()) <= tolerance + 10 && Math.abs(lapsePixel.getGreen() - canvasPixel.getGreen()) <= tolerance + 10 && Math.abs(lapsePixel.getBlue() - canvasPixel.getBlue()) <= tolerance + 10) {
checkSum++;
if (checkSum >= .35 * (searchImg.getWidth() * searchImg.getHeight())) {
if (move) {
mouse.Movemouse(x + (searchImg.getWidth() / 2) + (int)(random*Math.random()), y + (searchImg.getHeight() / 2) +(int)(random*Math.random()));
}
return true;
}
} else if (lapsePixel.getRed() == 0 && lapsePixel.getGreen() == 240 && lapsePixel.getBlue() == 240) {
checkSum++;
if (checkSum >= .35 * (searchImg.getWidth() * searchImg.getHeight())) {
if (move) {
mouse.Movemouse(x + (searchImg.getWidth() / 2) + (int)(random*Math.random()), y + (searchImg.getHeight() / 2) + (int)(random*Math.random()));
}
return true;
}
} else {
checkSum = 0;
}
}
}
}
}
}
} catch (Exception ex) {
}
return found;
}