private static short mag2gray(long mag) {
		short intensity = (short) (30.0 * Math.log(1.0 + (double) mag) - 256.0);

		// Make sure the returned intensity is in the range 0...255, regardless
		// of
		// the input value.
		if (intensity < 0) {
			intensity = 0;
		} else if (intensity > 255) {
			intensity = 255;
		}
		return intensity;
	}