REC

Create Recode-LUT Segment


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Return Value :: Details :: Example :: Related

Back to top

Description


REC creates or overwrites a 256-value database lookup table layer, which can be used to transform or recode 8-bit image data stored in image layers. Unspecified lookup table values can be defaulted to either zero or identity. No image data is changed.
Back to top

Parameters


rec(file, dblut, back, dbsn, dbsd, r000, r016, r032, r048, r064, r080, r096, r112, r128, r144, r160, r176, r192, r208, r224, r240)

Name Type Caption Length Value range
FILE * str Input file name 1 -    
DBLUT List[int] Output lookup table segment 0 - 1  
BACK str Default background 0 - 4 IDEN, ZERO
Default: ZERO
DBSN * str Output LUT segment name 1 - 8  
DBSD str Output LUT segment description 0 - 64  
R000 List[int] Recode values: 0-15 0 - 16 0 - 255
R016 List[int] Recode values: 16-31 0 - 16 0 - 255
R032 List[int] Recode values: 32-47 0 - 16 0 - 255
R048 List[int] Recode values: 48-63 0 - 16 0 - 255
R064 List[int] Recode values: 64-79 0 - 16 0 - 255
R080 List[int] Recode values: 80-95 0 - 16 0 - 255
R096 List[int] Recode values: 96-111 0 - 16 0 - 255
R112 List[int] Recode values: 112-127 0 - 16 0 - 255
R128 List[int] Recode values: 128-143 0 - 16 0 - 255
R144 List[int] Recode values: 144-159 0 - 16 0 - 255
R160 List[int] Recode values: 160-175 0 - 16 0 - 255
R176 List[int] Recode Values: 176-191 0 - 16 0 - 255
R192 List[int] Recode values: 192-207 0 - 16 0 - 255
R208 List[int] Recode values: 208-223 0 - 16 0 - 255
R224 List[int] Recode values 224-239 0 - 16 0 - 255
R240 List[int] Recode values: 240-255 0 - 16 0 - 255

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the PCIDSK file from which the image data is to be read.

DBLUT

Specifies the segment to receive the output lookup table. If this parameter is specified, the lookup table segment is overwritten. If it is not specified, a new lookup table segment is created.

BACK

Specifies whether the default background lookup table values should be zero or identity. Valid values are:

DBSN

Specifies a name (up to 8 characters) for the output LUT segment.

DBSD

Describes (in up to 64 characters) the contents or origins of the output LUT segment.

R000

Specifies 16 lookup table (recode) values for gray levels between nnn and nnn+15 inclusive. In general, Rnnn(x) specifies a lookup table value for gray level nnn + x - 1, where 'nnn' is between 0 and 240 and is a multiple of 16, and where 'x' is between 1 and 16. Therefore, R000(1) specifies a lookup table value for gray level 0, and R240(16) specifies a lookup table value for gray level 255.

Values must be between 0 and 255. Default values are determined by the BACK (Default Background) parameter. Each value of Rnnn must be specified, if no defaults are desired.

Please refer to the 'Example' section for more information on specifying the various recode values.

R016

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R032

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R048

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R064

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R080

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R096

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R112

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R128

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R144

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R160

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R176

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R192

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R208

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R224

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

R240

Refer to the Parameter Details for R000 (Recode Values: (0 to 15)).

Back to top

Return Value

Returns: Last Segment Created

Type:  PCI_INT

If a new lookup table segment is created, then the LASC parameter is assigned the segment number of the new segment.

Back to top

Details

REC creates an arbitrary lookup table, which can be used to recode gray levels stored on 8-bit database image channels. You can perform the same function using LUTREAD, which reads lookup table values from a text file.

A lookup table for 256 gray levels (between 0 and 255) is created by assigning values to the various recode value parameters. The default value for these parameters is either zero or identity, as determined by the BACK (Default Background) parameter. The values can be any arbitrary 8-bit value and do not have to increase monotonically.

If DBLUT (Output) is not specified, REC creates a new database lookup table segment (type 170). The name and description of the new segment are specified by DBSN (LUT Layer Name) and DBSD (LUT Layer Description) parameters respectively.

If DBLUT (Output) is specified, REC overwrites the lookup table on the existing database segment. The name and description of the existing segment are not changed.

The number of the new segment is saved in the output parameter LASC.

Back to top

Example

Create a lookup table that does the following:
  • Leaves all values between 0 and 31 in the image unchanged (identity background)
  • Sets values between 32 and 99 to 1
  • Sets values between 100 and 149 to 2
  • Sets values between 150 and 199 to 4
  • Sets values between 200 to 255 to 3
from pci.rec import rec

file="irvine.pix"
dblut=[]
back="IDEN"
dbsn="RECODE"
dbsd="Recode values from 32 to 255"
r000=[]
r016=[]
r032=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
r048=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
r064=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
r080=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
r096=[1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2]
r112=[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
r128=[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
r144=[2,2,2,2,2,2,4,4,4,4,4,4,4,4,4,4]
r160=[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
r176=[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
r192=[4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3]
r208=[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]
r224=[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]
r240=[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]

lasc = rec(file, dblut, back, dbsn, dbsd, r000, \
r016, r032, r048, r064, r080, r096, \
r112, r128, r144, r160, r176, r192, \
r208, r224, r240)
        

The resulting lookup table is written to the file "irvine.pix". The segment number is written to the output parameter LASC.

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