public static Image dynamicCompression(Image original) {
		if (original == null) {
			return null;
		}
		double L = Image.MAX_VAL;
		double RRed = 0, RGreen = 0, RBlue = 0;
		for (int x = 0; x < original.getWidth(); x++) {
			for (int y = 0; y < original.getHeight(); y++) {
				RRed = Math.max(RRed, original.getPixel(x, y, RED));
				RGreen = Math.max(RGreen, original.getPixel(x, y, GREEN));
				RBlue = Math.max(RBlue, original.getPixel(x, y, BLUE));
			}
		}
		double cRed = (L - 1) / Math.log(1 + RRed);
		double cGreen = (L - 1) / Math.log(1 + RGreen);
		double cBlue = (L - 1) / Math.log(1 + RBlue);
		Image image = original.shallowClone();
		for (int x = 0; x < image.getWidth(); x++) {
			for (int y = 0; y < image.getHeight(); y++) {
				double rRed = original.getPixel(x, y, RED);
				double rGreen = original.getPixel(x, y, GREEN);
				double rBlue = original.getPixel(x, y, BLUE);
				double colorRed = (double) (cRed * Math.log(1 + rRed));
				double colorGreen = (double) (cGreen * Math.log(1 + rGreen));
				double colorBlue = (double) (cBlue * Math.log(1 + rBlue));
				image.setPixel(x, y, RED, colorRed);
				image.setPixel(x, y, GREEN, colorGreen);
				image.setPixel(x, y, BLUE, colorBlue);
			}
		}
		return image;
	}