NUMREAD

Read image data from text file


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

Back to top

Description


Reads image gray-level values stored in a text file, then writes the data to output image channel(s).
Back to top

Parameters


Name Type Caption Length Value range
FILE * String Output file name 1 - 192  
DBGEO Integer Input georeference segment 0 - 1 Default: 1
DBOC * Integer Output raster image channel or layer 1 -    
DBOW Integer Output processing window 0 - 4 Xoffset, Yoffset, Xsize, Ysize
NUMFORM * String Input data numeric format 4 - 8 COORD | DATA | GEOCOORD
Default: COORD
TFILE * String Input data text file name 1 - 192  
MEMSIZE Float Working memory size (MB) 0 - 1 0 - 2000
Default: 16
MONITOR String Monitor mode 0 - 3 ON, OFF
Default: ON

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the PCIDSK image file to receive the data values stored in the text file. The specified file must already exist.

DBGEO

Optionally specifies the input georeferencing segment.

This parameter is required if the input coordinates are in georeference units instead of the default pixel,line units.

Note: Only simple georeferencing is supported; for example meters, UTM, equirectangular long/lat. Other projections are not supported.

DBOC

Specifies the raster image image channel(s) or layer(s) to receive the data values stored in the text file (TFILE).

Duplicate output channels are NOT allowed.

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.

DBOW

Specifies the window or bitmap that defines the area within the output raster to which the gray-level values from the text file will be written. Gray levels that fall outside this defined area are ignored.

If a single value is specified, that value represents the channel number of the bitmap segment in the input file. Only the pixels under the bitmap are processed; the rest of the image remains unchanged.

If four values are specified, they define the x,y offsets and x,y dimensions of a rectangular window identifying the area to process. Xoffset, Yoffset define the upper-left starting pixel coordinates of the window. Xsize is the number of pixels that define the window width. Ysize is the number of lines that define the window height.

If no value is specified, the entire channel is processed.

NUMFORM

Specifies the format in which image data is stored in the input text file.

Image data may be stored in one of the following formats:

See the Details section for more information.

TFILE

Specifies the path and file name of the text file that contains the data to be read into the image channel(s).

MEMSIZE

Specifies the amount, in megabytes, of internal memory that is allocated to this function. The default amount of internal memory is 16 MB.

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

NUMREAD transfers image data from a text file (TFILE) to a specified output image channel (DBOC) on a PCIDSK file (FILE).

If desired, the data input may be restricted to a specified area (DBOW) within the output channels.

Image data can be stored in the text file in one of three formats: coordinate (COORD), georeferenced coordinate (GEOCOORD), or data (DATA). The georeferencing segment DBGEO may be specified if the numeric data format is "GEOCOORD".

If more than one output channel is specified, data in the text file is assumed to be stored in pixel-interleaved form (BIP).

Data values will be truncated if they exceed the minimum/maximum allowable values in the output channel(s) DBOC. For example, if DBOC is an 8-bit unsigned channel type, values less than 0 or greater than 255 will be truncated to 0 and 255, respectively.

The MEMSIZE (Working Memory Size) parameter can be used to control the size of the internal working buffer of the output image. Specifying a large value -- ideally large enough for the entire input image, may dramatically speed up processing of input data with a NUMFORM of GEOCOORD or COORD.

Note:

Input text files with X and Y coordinates (NUMFORM="COORD" or "GEOCOORD") will process quicker if the text file has been sorted on the Y coordinate prior to running NUMREAD. This can be done using system sort commands. For example, on a UNIX platform, if file.txt has one X, Y, and grayscale value per record, the following:

sys "sort +1 -2 file.txt > sorted.txt"

runs the UNIX sort command on the file named file.txt and sorts it primarily on the second field (the Y coordinate) and secondarily on the first field (the X coordinate) and directs the sorted text records to a new file named sorted.txt. This new file may then be used as the input text file (TFILE) for NUMREAD.

Format

The data format expected by NUMREAD is determined by the value of the NUMFORM (Numeric Format) parameter. Possible values are COORD, GEOCOORD, and DATA.

For the coordinate (COORD) format, the text file contains two values for each pixel: database x-position (pixel) and database y-position (line), and is followed by gray-level value(s) pertaining to each input channel (in pixel-interleave mode). The (x,y) position represents the pixel and line number on the image channel to which the corresponding gray level is written. The number of pixels on each line of text may be specified using the "COORDn" form. For example if n=2 (that is, "COORD2"), 2 pixels (6 values) are specified on each line for one input channel. If the number of input channels is four, and n=2 ("COORD2"), four pixels (x,y coordinate and two gray-level values) are specified on each line, for a total 12 columns. If no n value is specified, by default each line contains 1 pixel.

If the (x,y) position is not within the specified window (DBOW) or not on the image file, the pixel value is ignored and is not written to the image channel.

In the following example, eight pixels are represented at locations (5,5), (6,6), (6,5), (5,6), (11,4), (4,11), (1,1), and (10,10). They have image values of 10, 11, 12, 13, 14, 100, 1, and 10.

5  5 10     6  6 11    6  5 12    5  6 13    11  4 14    4  11 100
1  1  1    10 10 10

For the georeferenced coordinate (GEOCOORD) format, the content of the text file is similar to that of the COORD format except that the (x,y) position is expressed in georeferenced units. This is translated to a pixel/line coordinate using the information line in the georeferencing segment (DBGEO). The number of pixels on each line of text may be specified using the "GEOCOORDn" form. For example, if n=2 (that is, "GEOCOORD2"), 2 pixels (6 values) are specified on each line, if DBIC is equal to one. If no n value is specified, by default each line contains 1 pixel for 8-bit, 16-bit, or 32-bit channels.

428735 3734385 10
428795 3734355 22

For the data ("DATA") format, the text file contains a gray-level value for each pixel (one gray-level value for each input channel, DBIC). The number of pixels on each line of text may be specified using the "DATAn" form. For example, if n=2 (that is, "DATA2"), 2 pixels (2 values) are specified on each line. If no n value is specified, by default each line contains 1 pixel. Pixel and line positions are assumed to be sequential, starting from left to right, and from top to bottom.

 62  68  58  57  61  63  59  58  59  61
 62  60  59  56  59  63  60  63  63  57
 63  63  61  59  59  60  62  62  64  64
 61  63  63  64  58  58  57  61  66  61
 59  64  64  63  60  59  58  60  62  59
 59  60  62  64  65  62  62  60  58  55
 59  60  59  61  64  63  63  60  57  55
 62  60  58  56  62  65  60  58  57  58
 63  60  59  59  63  61  56  57  56  56
 61  60  59  63  63  57  57  57  56  55
Back to top

Examples

Read gray-level values from the text file TEST.TXT (where data is stored in coordinate form) and write to the output file (TEST.PIX) only those values which are within the specified image window (0,0,10,10). Values outside this window in TEST.TXT are ignored.

The text file TEST.TXT contains the following data values:

5  5 10     6  6 11    6  5 12    5  6 13    11  4 14    4  11 100
1  1  1    10 10 10

The output channel 5 is cleared using CLR.

EASI>FILE	=	"TEST.PIX"
EASI>DBOC	=	5
EASI>VALUE	=	0,255
EASI>DBOW	=	0,0,10,10

EASI>RUN CLR

Use NUMREAD to write gray-level values to the image file.

EASI>FILE	= "TEST.PIX"
EASI>DBGEO	=
EASI>DBOC	=
EASI>NUMFORM	=	"COORD"
EASI>TFILE	=	"TEST.TXT"
EASI>MEMSIZE	= 

EASI>RUN NUMREAD
            

Use NUM to print a report of numeric window (0,0,10,10) of image channel 5.

EASI>FILE	=	"TEST.PIX"
EASI>DBIC	=	5
EASI>dbiw	=	0,0,10,10

EASI>RUN NUM
            
 IM:[WILSON]TEST.PIX;1              [S 10PIC   256P   256L] 24-NOV-89
 8: NUMREAD Image data from Text file: test.txt       15:27 15-JAN-90

 Offset: (    0,    0)  Size: (   10,   10)

                                            1
        1   2   3   4   5   6   7   8   9   0
     +---------------------------------------
    1|  1   0   0   0   0   0   0   0   0   0
    2|  0   0   0   0   0   0   0   0   0   0
    3|  0   0   0   0   0   0   0   0   0   0
    4|  0   0   0   0   0   0   0   0   0   0
    5|  0   0   0   0  10  12   0   0   0   0
    6|  0   0   0   0  13  11   0   0   0   0
    7|  0   0   0   0   0   0   0   0   0   0
    8|  0   0   0   0   0   0   0   0   0   0
    9|  0   0   0   0   0   0   0   0   0   0
   10|  0   0   0   0   0   0   0   0   0  10

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