RGB2PCT

Compress Image using PCT


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Examples :: Related

Back to top

Description


Takes a 24-bit RGB image and compresses it into a single 8-bit image, based on a defined Pseudocolor Table (PCT). For each pixel in the input image, this function establishes the nearest color in the supplied PCT, and places a corresponding color index in the output channel. This capability is useful when exporting color images for hardware/software systems that do not support 24-bit color.
Back to top

Parameters


Name Type Caption Length Value range
FILE * String Input file name 1 - 192  
DBIC * Integer Input raster channel(s) or layer(s) 3 - 3  
DBOC * Integer Output raster channel(s) or layer(s) 1 - 1 1 - 1024
DBPCT * Integer Pseudocolor Layer 1 - 1  
MONITOR String Monitor mode 0 - 3 ON, OFF
Default: ON

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the file that contains the input data to be processed.

DBIC

Specifies the three 8-bit channels in the RGB image.

Ranges of channels or segments can be specified with negative values. For example, {1,-4,10} is internally expanded to {1,2,3,4,10}. When you are not specifying a range in this way, only 48 numbers can be specified explicitly.

DBOC

Specifies the single 8-bit output channel in which to store the compressed image.

DBPCT

Specifies the Pseudocolor Table (PCT) segment used to define the set of available colors to which the image should be compressed.

MONITOR

The program progress can be monitored by printing the percentage of processing completed. A system parameter, MONITOR, controls this activity.

Available options are:

Back to top

Details

RGB2PCT compresses a 24-bit color (RGB) image into a single 8-bit channel based on the specified pseudocolor table (PCT, segment type: 171). The pseudocolor table is used to color the compressed image so that it looks similar to the original 24-bit color image. This capability is useful when preparing color images for export to other third-party software systems with limited color capability.

The input file (FILE) contains the input RGB channels (DBIC) and the channel to which to write the compressed result (DBOC).

Due to the 8-bit nature of a pseudocolor table, the input RGB channels and the output compressed channel must be 8-bit. While any type of image channel may be used, values are internally converted to 8-bit data. Using non 8-bit data may result in unexpected or poor results.

Note: If the imagery is to be enhanced with an LUT, this should be applied to the RGB channels ahead of time using the LUT function.
Back to top

Examples

The user wishes to transfer a 24-bit color image to a GIS system, to be used as a backdrop for digitizing vectors. The GIS system supports only 8-bit images in SUN Rasterfile format. We would like to export the contents of /demo/map100.pix with the most accurate Pseudocolor Table possible.

The ADAPT function is used to generate a PCT well distributed to represent this particular image.

EASI>FILE = "map100.pix"
EASI>DBIC = 1,2,3
EASI>RUN ADAPT
            

RGB2PCT is used to transform the RGB image into a Pseudocolored image, based on the adaptive PCT (segment 3).

EASI>DBIC = 1,2,3
EASI>DBOC = 1   ! Overwrite channel 1
EASI>DBPCT=LASC ! Use newly created segment
EASI>RUN RGB2PCT            
            

The 8-bit image is now made into a SUN Rasterfile.

EASI>FILI = FILE! map100.pix
EASI>FILO = "map100.im8"
EASI>DBIC = 1
EASI>DBIW =
EASI>FTYPE="SUN"
EASI>RUN FEXPORT
            

The file map100.im8 can now be used by the GIS system.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.