| Environments | PYTHON :: EASI :: MODELER |
| Batch Mode | Yes |
| Quick links | Description :: Parameters :: Parameter descriptions :: Details :: Algorithm :: Related |
| Back to top |
| Back to top |
| Name | Type | Length | Value range |
|---|---|---|---|
| FILE * | String | 1 - | |
| Input: Input channels or layers * | Raster port | 3 - 3 | |
| Output: Output channel or layer * | Raster port | 1 - 1 | |
| InputPCT: Input pseudocolor segment or layer * | PCT port | 1 - 1 |
| Back to top |
FILE
Specifies the name of the PCIDSK image file that contains the imagery to be compressed.
Input: Input channels or layers
Specifies the three 8-bit channels or layers that contain the RGB image to be compressed.
Output: Output channel or layer
Specifies the single 8-bit black and white channel or layer that receives the compressed image.
InputPCT: Input pseudocolor segment or layer
Specifies the PCT segment or layer that supplies the set of available colors to which the image is compressed.
| Back to top |
ERRDIFF compresses a 24-bit color (RGB) image into a single 8-bit channel, based on a PCT (segment type: 171) that you provide. The PCT is used to color a compressed image so that it looks similar to the original 24-bit color image. This capability can be used when preparing color images for exporting to other third-party software (for example, a GIS system with limited color capability).
ERRDIFF can be used when color images must be exported to other hardware or software systems without 24-bit color support.
The error diffusion algorithm used by ERRDIFF attempts to select a nearby color in the PCT, (but not always the nearest one) in proportions such that, at a distance (as the pixels merge visually), a better approximation of the color of a region is achieved.
The input file contains the input RGB channels and the channel to which to write the compressed result. If the imagery is to be enhanced with a lookup table (LUT), apply it to the RGB channels ahead of time with the LUT function.
The input RGB channels and the output compressed channel must be 8-bit because of the nature of a PCT. Although any type of image channel can be used, values are internally converted to 8-bit data. Using non 8-bit data can result in unexpected or poor results.
| Back to top |
The error diffusion algorithm used by ERRDIFF is based on the concept of remembering the cumulative error in approximating the error for each pixel and attempting to err in the opposite direction in red, green, and blue image space for the next pixel.
For each pixel, the following process takes place.
P1 -- P2
/ | \
/ | \
P3 P4 P5
Finding the nearest color in the PCT to an RGB color is performed by building a large three-dimensional table with red, green, and blue values as the indices. This table is populated in advance with the nearest color for each possible RGB value to avoid computing by exhaustive comparison for each pixel in the image.
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.