private static double contrastValue(double pixel, int r1, int r2, int s1,
			int s2) {
		double m = 0;
		double b = 0;
		if (pixel < r1) {
			m = s1 / r1;
			b = 0;
		} else if (pixel > r2) {
			m = (Image.MAX_VAL - s2) / (Image.MAX_VAL - r2);
			b = s2 - m * r2;
		} else {
			m = (s2 - s1) / (r2 - r1);
			b = s1 - m * r1;
		}
		return m * pixel + b;
	}