The GIMP: A Channel Ops Tutorial for Artists

Originally by: Mena Quintero Federico
Updated and converted to HTML by: Michael J. Hammel


The GIMP currently (version 0.54) supports images with only 8 bits per channel. A channel can be thought of as one of the base colors of Red, Green and Blue (thats an over simplification, but we'll go with that for now) in RGB images or the range of intensities that White will range through in grayscale images. So, in RGB images you have three channels and in grayscale images you have one channel.

With 8 bits to work with, every pixel in a GIMP image occupies at least one byte (or more precisely, one octet) of memory. Grayscale images use 8 bpp (bits per pixel), and RGB images use 24 bpp.

Values in the range of 0 to 255 are possible using 8 bits. Grayscale images can therefore have 256 gray levels. RGB images use 8 bits for each of the red, green, and blue channels, so they can have at most

256 * 256 * 256 = 16,777,216
colors. The channel operations basically take two images of the same size and perform some trivial arithmetic operation on their corresponding pixels. If "OP" is an arithmetic operation or operator, the channel ops could basically be described as
For each pixel in source_image_1, 
   destination_image_pixel = source_image_1_pixel OP source_image_2_pixel
Below are explanations of all the channel ops plug-ins:
Channel Op Operation
Add Adds the corresponding pixel values of the two source images. If the destination pixel value is greater than 255, it gets clamped (forced) to 255. If you add a black image to another image, the resulting image will be identical to the other image. If you add a white image to some other image, the result will be a pure white image.

If you take one image and add it to an exact copy of itself the result will be a much lighter (brighter, washed out) image than the original. Remember that 0 is a black pixel, and 255 is a white pixel.

Blend Takes a weighted average of two images. By default the blend channel op will take 50% of the pixel values for each of the two images to be blended. Alternatively, instead of mixing them 50-50, you can mix the two images in unequal amounts, say 40%-60%.

The blend channel op only supports values between 0% and 100%. The value specified is the amount to use for the first image.

Composite Takes two images and blends them together using a compositing mask. Think of it as blend but with a different blending value for every pixel. Let's imagine that all the images' pixels are real numbers in the range [0, 1]. We have three images, src1, src2, and mask. The formula used is

dest = (1 - mask) * src1 + mask * src2

So for darker mask values you'll be using more of the first image. Lighter mask values mean you'll get more of the second image. A completely black mask image will result in a destination image identical to the first one. A completely white mask will result in a destination image identical to the second one. A 50% gray mask will be the same as a 50-50 blend of the two images. Since you can change the blending value for every pixel in the mask image, this gives you a lot of flexibility.

Darkest Outputs a destination image which consists of the darker pixels of two images. What happens is the darkest channel op looks at the first image pixel by pixel and compares each pixel to the corresponding pixel in the second image. If the first pixel is darker, then it goes into the output image. If the pixel in the second image is darker then it goes into the output image.

For the programmer, this could be viewed as

for (every pixel)
	if (pixel_from_image_1 < pixel_from_image_2)
		dest_pixel = pixel_from_image_1;
	else
		dest_pixel = pixel_from_image_2;
		
Difference Subtracts one image from the other and outputs the absolute value of that result (so that there are no negative values). This is useful for comparing very similar images.
Interpolate/
Extrapolate
Virtually identical to blend, but you are not restricted to values between 0% and 100%. You can use any real value. Here, 'normal' blending values are not taken from 0 to 100, but rather from 0 to 1. However, you can use values outside of this range --- this is called Extrapolation. This is very powerful tool. Check the Grafica Obscura home page for some excellent tips on using the Extrapolate function.

Note: this section needs some work.

Lightest Similar to Darkest, but takes the lightest values of two images.
Multiply Multiplies the pixels of one image by the pixels of the other one. If the pixels were in the real range [0, 1], it could be viewed as
for (every pixel)
	dest_pixel = source1_pixel * source2_pixel;
		
This would produce values in the range [0, 1]. However, our integer values are in the range of [0, 255], so the actual formula used is
dest_pixel = source1_pixel * source2_pixel / 255;
		
This forces the resulting values back into the range of [0, 255] and has the same effect of forcing the original values into the range of [0, 1] by dividing each of them by 255 before multiplying them together. Note that multiplying one image by another always produces an image darker than the first. This is because a number in the range [0, 1] multiplied by another number in the same range will always be smaller than or equal to either of them.
Subtract Similar to Add, but performs a subtraction instead. Negative values get clamped to 0. Note that this differs from the difference channel op in that here the result clamps to 0, whereas the result of a difference of two images is the absolute value of the result (which can be greater than 0).

A very good way to understand how the channel ops plug-ins work is to check the source code. These functions are really trivial (just a for loop and an operation among pixels) --- you do not need to understand all the dialog-setup stuff.

In Zach's page there are some very good examples of what you can do with channel operations. He also has a link to Kai's Power Tips and Tricks page (for Photoshop, but they work perfectly with The GIMP), which has some extensive and very useful tips for using channel operations to create special effects.

Quartic's GIMP pages can be found at http://polloux.fciencias.unam.mx/~quartic/gimp/el-the-gimp.html.


Back Back to The Gimp Page

(clear space) Michael J. Hammel <mjhammel@csn.net>
(clear space) Created: June 16, 1996
Updated: June 16, 1996