Home > Tutorials > Image Processing – Color Boost Up

Image Processing – Color Boost Up


Color boost technique is basically based on color filtering, which is to increase the intensity of a single color channel.

From the base image:

Original Image

Original Image

These are some boost effects:

Boost: Red 150%

Boost: Red 150%

Boost: Green 50%

Boost: Green 50%

Boost: Blue 67%

Boost: Blue 67%

Here the implementation:

	public static Bitmap boost(Bitmap src, int type, float percent) {
		int width = src.getWidth();
		int height = src.getHeight();
		Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());

		int A, R, G, B;
		int pixel;

		for(int x = 0; x < width; ++x) {
			for(int y = 0; y < height; ++y) {
				pixel = src.getPixel(x, y);
				A = Color.alpha(pixel);
				R = Color.red(pixel);
				G = Color.green(pixel);
				B = Color.blue(pixel);
				if(type == 1) {
					R = (int)(R * (1 + percent));
					if(R > 255) R = 255;
				}
				else if(type == 2) {
					G = (int)(G * (1 + percent));
					if(G > 255) G = 255;
				}
				else if(type == 3) {
					B = (int)(B * (1 + percent));
					if(B > 255) B = 255;
				}
				bmOut.setPixel(x, y, Color.argb(A, R, G, B));
			}
		}
		return bmOut;
	}

Hope you enjoy iy!

Cheers,
Pete Houston

Advertisements
Categories: Tutorials Tags: , , , ,
  1. Pako
    August 19, 2014 at 5:28 am

    Hi, I like your tutorials, good work, just a comment. It would be faster if you pull the “type” if out of the main loop and instead repeat the code for each color, it is more code, but it will run faster

  2. christophgewehr
    August 23, 2013 at 10:26 pm

    Type is a number (1,2,3) thats tells you what color is meant and since percent is float I guess 1.0f equals 100%.

  3. Arsalan Mehmood
    November 30, 2012 at 7:52 pm

    what are the values for type and percent ?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: