public static void equalizeChannel(Image original, Image image,
			ChannelType color) {
		int[] ocurrences = getColorOccurrences(original, color);
		int totalPixels = image.getWidth() * image.getHeight();
		double[] levels = new double[totalPixels];
		double s_min = 0;
		double s_max = Image.MAX_VAL;
		for (int i = 0; i < levels.length; i++) {
			int level = (int) Math.floor(original.getPixel(
					i / image.getHeight(), i % image.getWidth(), color));
			double levelVal = 0;
			for (int k = 0; k < level; k++) {
				levelVal += ocurrences[k];
			}
			levels[i] = levelVal / totalPixels;
			s_min = Math.min(s_min, levels[i]);
			s_max = Math.max(s_max, levels[i]);

		}
		for (int i = 0; i < levels.length; i++) {
			double aux = Image.MAX_VAL * (levels[i] - s_min) / (1 - s_min);
			levels[i] = Math.ceil(aux);
		}
		int i = 0;
		for (int x = 0; x < image.getWidth(); x++) {
			for (int y = 0; y < image.getHeight(); y++) {
				image.setPixel(x, y, color, levels[i++]);
			}
		}
	}