public static Image substract(Image img1, Image img2) {
		if (img1 == null || img2 == null) {
			return null;
		}
		Image img = img1.shallowClone();
		double min = 0, max = 255;
		for (int x = 0; x < img1.getWidth(); x++) {
			for (int y = 0; y < img1.getHeight(); y++) {
				double red = img1.getPixel(x, y, RED)
						- img2.getPixel(x, y, RED);
				double green = img1.getPixel(x, y, GREEN)
						- img2.getPixel(x, y, GREEN);
				double blue = img1.getPixel(x, y, BLUE)
						- img2.getPixel(x, y, BLUE);
				min = min(red, green, blue, min);
				max = max(red, green, blue, max);
				img.setPixel(x, y, RED, red);
				img.setPixel(x, y, GREEN, green);
				img.setPixel(x, y, BLUE, blue);
			}
		}
		normalize(img, min, max);
		return img;
	}