| Environments | PYTHON :: EASI :: MODELER |
| Quick links | Description :: Parameters :: Parameter descriptions :: Details :: Examples :: Related |
| Back to top |
| Back to top |
rgb2pct(file, dbic, dboc, dbpct)
| Name | Type | Caption | Length | Value range |
|---|---|---|---|---|
| FILE * | str | Input file name | 1 - | |
| DBIC * | List[int] | Input raster channel(s) or layer(s) | 3 - 3 | |
| DBOC * | List[int] | Output raster channel(s) or layer(s) | 1 - 1 | 1 - 1024 |
| DBPCT * | List[int] | Pseudocolor Layer | 1 - 1 |
| Back to top |
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.
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.
| Back to top |
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.
| Back to top |
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.
from pci.adapt import adapt
file='map100.pix'
dbic=[1,2,3] # RGB image
dbpct = [] # Default is to create new PCT segment
dbsn = 'Adapt' # Name for new PCT segment
dbsd = ''
adapt(file, dbic, dbpct, dbsn, dbsd)
RGB2PCT is used to transform the RGB image into a Pseudocolored image, based on the adaptive PCT (segment 3).
from pci.rgb2pct import rgb2pct
file='map100.pix'
dbic=[1,2,3] # RGB image
dboc = [1]
dbpct = [3] # new PCT segment 3
rgb2pct(file, dbic, dboc, dbpct)
The 8-bit image is now made into a SUN Rasterfile.
from pci.fexport import fexport
fili=file
filo="irvine.im8"
dbiw=[]
dbic=[1] # channel from map100.pix
dbib=[]
dbvs=[]
dblut=[]
dbpct=[]
ftype='SUN'
foptions=''
fexport(fili, filo, dbiw, dbic, dbib, dbvs, dblut, dbpct, ftype, foptions)
The file map100.im8 can now be used by the GIS system.
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.