Next / Previous / Contents / TCC Help System / NM Tech homepage

2. Definitions

These terms are used throughout:

2.1. Band

An image band is a set of values, one per image pixel. Monochrome or grayscale images have one band; color images in the RGB system have three bands, CMYK images have four, and so on. Photoshop users will recognize bands as similar to Photoshop channels.

2.2. Modes

The mode of an image describes the way it represents colors. Each mode is represented by a string:

"1"1Black and white (monochrome), one bit per pixel.
"L"1Gray scale, one 8-bit byte per pixel.
"P"1 Palette encoding: one byte per pixel, with a palette of class ImagePalette translating the pixels to colors. This mode is experimental; refer to the online documentation.
"RGB"3 True red-green-blue color, three bytes per pixel.
"RGBA"4 True color with a transparency band, four bytes per pixel, with the A channel varying from 0 for transparent to 255 for opaque.
"CMYK"4 Cyan-magenta-yellow-black color, four bytes per pixel.
"YCbCr"3Color video format, three 8-bit pixels.
"I"132-bit integer pixels.
"F"132-bit float pixels.

2.3. Sizes

The sizes of objects in the image are described as a 2-tuple (w, h), where h is the height in pixels and w is the width.

2.4. Coordinates

The coordinates of a pixel are of its upper left corner. Point (0,0) is the upper left corner of the image. The x coordinate increases to the right, and the y coordinate increases downward.

When directions are given as compass points such as east or southwest, assume north is up, toward the top of the display.

2.5. Angles

Angles are given in degrees. Zero degrees is in the +x (east) direction, and the angle increases counterclockwise, in the usual Cartesian convention. For example, angle 45 points northeast.

2.6. Bboxes (bounding boxes)

A bounding box or bbox is a rectangle in the image. It is defined by a 4-tuple, (x0, y0, x1, y1) where (x0, y0) is the top left (northwest) corner of the rectangle, and (x1, y1) is the bottom right (southeast) corner.

Generally, the area described by a bounding box will include point (x0, y0), but it will not include point (x1, y1) or the row and column of pixels containing point (x1, y1).

For example, drawing an ellipse inside the bounding box (0,0,5,10) will produce an ellipse 5 pixels wide and 10 pixels high. The resulting ellipse will include pixel column 4 but not column 5, and will also include pixel row 9 but not row 10.

2.7. Colors

You can specify colors in several different ways.

  • For single-band images, the color is the pixel value. For example, in a mode "1" image, the color is a single integer, 0 for black, 1 for white. For mode "L", it is an integer in the range [0,255], where 0 means black and 255 means white.

  • For multi-band images, supply a tuple with one value per band. In an "RGB" image, the tuple (255,0,0) is pure red.

  • You can use CSS-style color name strings of the form #rrggbb, where rr specifies the red part as two hexadecimal digits, gg specifies green, and bb blue. For example, "#ffff00" means yellow (full red + full green).

  • To specify RGB pixel values in decimal, use a string of the form "rgb(R,G,B)". For example, "rgb(0,255,0)" is pure green.

  • To specify RGB pixel values as percentages, use a string of the form "rgb(R%,G%,B%)". For example, you can get a light gray with "rgb(85%,85%,85%)".

  • To specify colors in the hue-saturation-lightness (HSV) system, use a string of the form "hsl(H,S%,L%)".

    H is the hue angle in degrees: 0 is red, 60 is yellow, 120 is green, and so on.

    S is the saturation: 0% for unsaturated (gray), 100% for fully saturated.

    The lightness L is 0% for black, 50% for normal, and 100% for white.

    For example, "hsl(180,100%,50%)" is pure cyan.

  • On Unix systems, you can use any of the standard color names from the locally installed set given in file "/usr/lib/X11/rgb.txt", such as "white", "DodgerBlue", or "coral".

2.8. Filters

Some operations that reduce the number of pixels, such as creating a thumbnail, can use different filters to compute the new pixel values. These include:


Uses the value of the nearest pixel.


Uses linear interpolation over a 2x2 set of adjacent pixels.


Uses cubic interpolation over a 4x4 set of pixels.


Neighboring pixels are resampled to find the new pixel value.