A digital image is a rectangular array of picture elements (pixels), arranged in m rows and n columns. The resolution of the image is m × n. Images can be categorized into bi-level, grayscale, and color images. A natural scene, such as a picture taken by a digital camera or obtained by using a scanner, is typically a continuous-tone image, where the colors vary continuously to the eye and there is a lot of noise in the picture. An artificial image, such as a graphical image, does not have the noise or blurring of a natural image. A cartoon-like image consists of uniform color in each area, but adjacent areas have different colors.
The features in each type of image can be exploited to achieve a better compression. For example, for the bi-level image, each pixel is represented by one bit. A pixel has a high probability of being the same as its neighboring pixels, and thus RLE is suitable for compressing such image. The image can be scanned column by column or in zigzag. For the grayscale image, each pixel is represented by n bits, and a pixel tends to be similar to its immediate neighbors but may be not identical, thus RLE is not suitable. By representing the image using a Gray code that differs in only one bit for two consecutive integers, a grayscale image can be separated into n bi-level images, and each can be compressed by using RLE.