imagex: a pc program for visualizing large three-dimensional matrices

6
Compurvrs& Geo.~ciences Vol. 22, No. 8, pp. 943-948, 1996 Copyright Q 1996 Elsevier Science Ltd Printed in GreatBritain. All rights reserved PII: soo98-3004(%)ooosO-7 0098-3004/96 $15.00 + 0.00 SHORT NOTE IMAGEX: A PC PROGRAM FOR VISUALIZING LARGE THREE-DIMENSIONAL MATRICES MARTIN HANSEN Geological Survey of Denmark and Greenland, Thoravej 8, DK-2400, Copenhagen NV, Denmark (e-mail: [email protected]) (Received 9 September 1995; revised 20 March 1996) INTRODUCIION Geological modeling using stochastic modeling tools such as ISIM3D (Gbmez-Hemandes and Srivastava, 1990) and GSLIB (Deutsch and Joumel, 1992) often produces a large number of matrices. To obtain an overview of the internal structure of these matrices, it may be necessary to view the matrices in three-dimensions and to display and print differ- ent sections of the matrices. IMAGEX is a PC pro- gram capable of displaying and printing (color and gray scale PostScript files) large matrices (up to 10’ cells depending on computing environment and available RAM). IMAGEX is written in C using EMX-GCC (an OS/ZDOS port of the GNU C- compiler GCC) by Mattes (1995) and VESA graphi- cal libraries (SVGAKIT and VESA) by Martin (1995). IMAGEX needs at least a 386 PC (with 387 coprocessor) and runs under DOS, Windows (full screen DOS-box using Schnitker’s (Schnitker, 1994) DMPI extender RSX), and OS/2 (PM-window and full screen-mode). EMX-GCC, SVGAKIT, VESA, and RSX are available via anonymous ftp at ftp.uni-stuttgart.de /pub/systems/os2/emx-0.9b (the last part of the directory changes with new versions) and in the contribution directory under emx-0.9b. two DOS extenders, “emx.exe” for plain DOS, and “rsx.exe” for Windows (and others DPMI servers), and a PostScript header file (“head.ps”). To be able to run under OS/2 three dynamic link libraries (dll’s) are needed: “emx.dll” with standard func- tions, “emxio.dll” with I/O functions and one with graphical routines (e.g. “vesa_et4.dll” for full screen modes on PCs with Tseng 4000 based video control- lers). Installation in the DOS, Windows, and OS/2 environments is described as follows: DOS Windows OS/2 To install the IMAGEX to run under DOS, simply copy the 6les “imagex.exe” and “emx.exe” to a directory in the path. The file “head.ps” must be in the current directory or in c:\bin. To install the IMAGEX to run under Windows, copy the files “imagex.exe” and “rsx.exe”, to a directory in the path. The file “head.ps” must be in the current directory or in c:\bin. To install IMAGEX to run under OS/2 IMAGEX, copy the “imagex.exe” to a directory in the path. Place “emx.dll”, “emxio.dll”, and the graphic dll in the LIBPATH and add the following command in the “conFig. sys” file: VESDAL = driver - name Using IMAGEX it is possible to write PostScript (Adobe, 1985) 6les of the plots and using other pro- grams such as GhostScript (Alladin, 1995) the PostScript files may be. printed on a wide range of laser and ink-jet printers. GhostScript is available via anonymous ftp at ftp.tex.ac.uk/pub/ghost. SVGAKIT includes drivers for Presentation Manager windows and the following full screen devices: Standard VGA, Tseng Lab-based adapters, S3-based adapters, Trident-based adapters, and Cirrus Logic-based adapters. INSTALLATION COMMAND LINE OPTIONS IMAGEX consists of the executable file “imagex.exe” (same file for all three environments), IMAGEX is a command line driven program without menus. All the initial commands are given 943

Upload: martin-hansen

Post on 15-Sep-2016

216 views

Category:

Documents


4 download

TRANSCRIPT

Compurvrs & Geo.~ciences Vol. 22, No. 8, pp. 943-948, 1996 Copyright Q 1996 Elsevier Science Ltd

Printed in Great Britain. All rights reserved PII: soo98-3004(%)ooosO-7 0098-3004/96 $15.00 + 0.00

SHORT NOTE IMAGEX: A PC PROGRAM FOR VISUALIZING LARGE

THREE-DIMENSIONAL MATRICES

MARTIN HANSEN

Geological Survey of Denmark and Greenland, Thoravej 8, DK-2400, Copenhagen NV, Denmark (e-mail: [email protected])

(Received 9 September 1995; revised 20 March 1996)

INTRODUCIION

Geological modeling using stochastic modeling tools such as ISIM3D (Gbmez-Hemandes and Srivastava, 1990) and GSLIB (Deutsch and Joumel, 1992) often produces a large number of matrices. To obtain an overview of the internal structure of these matrices, it may be necessary to view the matrices in three-dimensions and to display and print differ- ent sections of the matrices. IMAGEX is a PC pro- gram capable of displaying and printing (color and gray scale PostScript files) large matrices (up to 10’ cells depending on computing environment and available RAM). IMAGEX is written in C using EMX-GCC (an OS/ZDOS port of the GNU C- compiler GCC) by Mattes (1995) and VESA graphi- cal libraries (SVGAKIT and VESA) by Martin (1995). IMAGEX needs at least a 386 PC (with 387 coprocessor) and runs under DOS, Windows (full screen DOS-box using Schnitker’s (Schnitker, 1994) DMPI extender RSX), and OS/2 (PM-window and full screen-mode). EMX-GCC, SVGAKIT, VESA, and RSX are available via anonymous ftp at ftp.uni-stuttgart.de /pub/systems/os2/emx-0.9b (the last part of the directory changes with new versions) and in the contribution directory under emx-0.9b.

two DOS extenders, “emx.exe” for plain DOS, and “rsx.exe” for Windows (and others DPMI servers), and a PostScript header file (“head.ps”). To be able to run under OS/2 three dynamic link libraries (dll’s) are needed: “emx.dll” with standard func- tions, “emxio.dll” with I/O functions and one with graphical routines (e.g. “vesa_et4.dll” for full screen modes on PCs with Tseng 4000 based video control- lers). Installation in the DOS, Windows, and OS/2 environments is described as follows:

DOS

Windows

OS/2

To install the IMAGEX to run under DOS, simply copy the 6les “imagex.exe” and “emx.exe” to a directory in the path. The file “head.ps” must be in the current directory or in c:\bin. To install the IMAGEX to run under Windows, copy the files “imagex.exe” and “rsx.exe”, to a directory in the path. The file “head.ps” must be in the current directory or in c:\bin. To install IMAGEX to run under OS/2 IMAGEX, copy the “imagex.exe” to a directory in the path. Place “emx.dll”, “emxio.dll”, and the graphic dll in the LIBPATH and add the following command in the “conFig. sys” file:

VESDAL = driver - name Using IMAGEX it is possible to write PostScript

(Adobe, 1985) 6les of the plots and using other pro- grams such as GhostScript (Alladin, 1995) the PostScript files may be. printed on a wide range of laser and ink-jet printers. GhostScript is available via anonymous ftp at ftp.tex.ac.uk/pub/ghost.

SVGAKIT includes drivers for Presentation Manager windows and the following full screen devices: Standard VGA, Tseng Lab-based adapters, S3-based adapters, Trident-based adapters, and Cirrus Logic-based adapters.

INSTALLATION COMMAND LINE OPTIONS

IMAGEX consists of the executable file “imagex.exe” (same file for all three environments),

IMAGEX is a command line driven program without menus. All the initial commands are given

943

944 Short Note

to the program using command line options (or by using BAT or CMD command files).

Help

If one of the following two options is used, the program will write the requested message to the screen and quit.

-h

-?

Print a short description of IMAGEX (and a copyright note) on the screen. Print an overview of the command line options and available video modes on the screen.

REQUIRED OPTIONS

Matrix size

The following three options specify the size of the matrix and (together with the file name of the matrix) always must be included.

-c# -r# -I#

Number of columns in the matrix. Number of rows in the matrix. Number of layers in the matrix.

OPTIONAL OPTIONS

Scaling of the plot

Using the following three options, it is possible to adjust the size of the individual cells on screen and plot (if the horizontal and vertical resolution on the screen is different, the plot may look different from the display). Default values are 1 for x, y, and z. To be able to display all cells in the three-dimensional plot, screen resolution (in pixels) must be several times the number of rows plus the number of col- umns in the matrix.

-x#

-Y#

-z#

Scaling factor in the x-direction for plot on the screen (integer Z 1). Scaling factor in the y-direction for plot on the screen (integer Z 1). Scaling factor in the z-direction for plot on the screen (integer Z 1).

It is possible to change the vertical exaggeration by specifying a z-factor different from the x- and y- factors.

Specification of minimum and maximum data values

Using the following two options it is possible to adjust the scaling of the numbers in the matrix. If the datafile requires scaling (if the data numbers are different from 0 to 9 in lo-color modes and different from 0 to 15 in 16-color modes) and the scaling fac- tors are not included, IMAGEX writes the largest

and smallest values on the screen after reading the file.

-S# A floating point number specifying the smallest number in the matrix.

-L# A floating point number specifying the largest number in the matrix.

Selection of color mode

Option to change the color scale. By default IMAGEX uses a color scale with sixteen colors ran- ging from blue (low values) to red (high values).

-C# An integer value specifying one of the fol- lowing color modes:

(1) Gray scale with sixteen intervals. (2) Color scale with sixteen intervals. (3) Gray scale with ten intervals. (4) Color scale with ten intervals.

The scales can be inverted (high values blue, low values red) by specifying a negative value for the re- spective color modes.

Type of input file

If none of the following three options is used, IMAGEX assumes an ISIM3D datafile. If needed the PostScript file can be edited to change the num- ber of intervals and their corresponding colors.

-g[#] GEO-EAS type of input file (Englund and Sparks, 1988). The optional number specifies the number of the column to be read. If no number is given, IMAGEX writes the column heading to the screen and prompts the user for a column number.

--Ii Two-dimensional UNIRAS ASCII grid file (Uniras, 1988).

-U Two-dimensional SURFER ASCII file (Golden Software, 1989).

If the files are not converted easily to ISIM3D or GEO-EAS formats, then other formats can be added by writing a procedure that transforms the datafile to an “array of chars” used by IMAGEX to store the matrix in memory.

Title

IMAGEX by default prints the name of the input file and the slice(s) shown on the plot below the legend. It is possible to add a primary heading using the following option. A secondary heading can be added by changing the line containing “0 subtitle” in the output PostScript file to “(My Subtitle) subtitle”.

-T Primary title to put on top of the plot. -T followed by the heading enclosed in quotes.

Short Note 945

Grundfor - Hinderup Distribution of sand and clay

n Sand

n u ncertain geology

W Clay I_sum.res 62,64,40

Figure 1. Cross-profile generated by IMAGEX’s 3D-mode. Size of matrix is 160 x 200 x 41 = 1,312,OOO cells. JMAGEX writes plot to fit on sheet of A4 paper. Size of plot can be changed by editing scale-fac-

tor in PostScript file and location on paper can be shifted by editing two offset values.

946 Short Note

Grundfor - Hinderup Distribution of sand and clay

n Sand

n Uncertain

Figure 2. User designed isometric consisting of ten slices defined in a “pit” file.

Short Note 947

Input file

The last item on the command line must be the name of the input datafile.

INPUT FILE FORMATS

ISIMjD file format

A simple file format where each cell in the matrix is represented by a single integer digit (O-9). The digits are ordered in the following way:

ISIM3D file with a 4 x 4 x 2 matrix

11234 row 1 12234 row 2 12344 row 3 22344 row 4

12223 row 1 22244 row 2 23344 row 3

layer 1 (uppermost)

layer 2 (lowermost)

22344 row 4

GEO-EASJile format

A general file format used for both matrices and irregularly spaced data in two- and three-dimen- sions. IMAGEX can read only regular matrices where each cell is represented by a real number as written by GSLIB. The following table shows a GEO-EAS datafile for a 2 x 2 x 2 matrix.

GEO-EAS file with a 2 x 2 x 2 matrix with two numbers for each cell

GEO-EAS Comment line datafile

2 number of data columns

porosity heading for data column 1

permeability heading for data

0.21 2.32 column 2 values for column 1 row 1 layer 1

(lowermost) 0.22 2.43 0.19 2.11 0.20 2.21 0.23 2.47

values for column 2 values for column 1 row 2 values for column 2 values for column 1 row 1 layer 2

(uppermost) 0.25 2.67 values for column 2 0.22 2.33 values for column 1 row 2 0.24 2.48 values for column 2

CAUTION

Be aware of the different orientation of the axes in the two file formats. In ISIM3D files, the x-axis increases eastwards, the y-axis southwards, and the z-axis downwards. In GEO-EAS files, the y-axis increases northwards and the z-axis upwards. This implies that in an ISIM3D file, cell [O,O,O] is in the uppermost northeastern comer while it is in the lowermost southeastern comer in GEO-EAS files. IMAGEX uses the ISIM3D type of coordinate sys-

tem so all plots are numbered using northeastern comer as the origin.

the uppermost

TWO-DIMENSIONAL PLOTS

IMAGEX can display and print sections perpen- dicular to the three axes. It is possible to flip through the layers, rows, or columns by pressing the up and down arrow-keys. It is possible to jump l-9 layers by preceding the arrow-key with one of the numbers l-9. It is possible to print the plot on the screen to a disk PostScript file by pressing “d”(ump). The files are named with a letter (axis), a number, and the “ps” extension (e.g. “z9.p~” if layer 9 (from the top) is plotted). The letter records which of the axes the section is crossing and the number which layer, row, or column is plotted.

THREE-DIMENSIONAL PLOTS

IMAGEX allows two different methods for dis- play and printing the three-dimensional matrices: (1) the 3D mode displays a cross-profile with move- able sections (Fig. 1) and (2) an EDIT mode where the user can build complex isometric blocks by spe- cifying which sections to draw and in which order (Fig. 2).

3D MODE

In this mode the lowermost layer is displayed along with two cross sections, one perpendicular to the x-axis and one perpendicular to the y-axis. The two vertical sections can be moved using the nu- merical keyboard (with numlock OK).

7=\ 8=t 9=/”

5=4- 6=-b

l=J 2=J 3=\

As in the two-dimensional mode, it is possible to jump a number of cells by preceding the “movement’‘-key with the numbers l-9. A plot is written to a PostScript file by pressing “d”(ump). The file is given the name “3dpltrznn.ps” where nnn is a number starting with 001 and increased by one each time “d” is pressed.

EDIT MODE

When starting the edit mode, IMAGEX executes the program EDIT with a filename consisting of the input file name with the extension “plt” (e.g. “gf- hi.plt”). To use another editor place a BAT (or

948 Short

CMD) with the following content file in the current directory.

Example EDIT.BAT to call QEDIT instead of EDIT c :\bin\qedit %1

The “plt” file must include:

(1) A comment line (max 80 characters). (2) A line with scaling factors for the x-, y-, and

z-directions and the angle of view (as tan(v)). (3) A number of lines (1 to n) with the following

content:

(1) Direction of the slice (x, y, or z). (2) The slice to plot. (3) Starting row. (4) Ending row. (5) Starting column. (6) Ending column.

Example IMAGEX “plt” file, the resulting plot is shown in Figure 2

Blockofgf-hidata 2 2 1 -1.0

; 40 0 0 0 199 159 0 0

; 0 0 2 ;o

40 19 0 20 X 40 0

Z 19 0 4’: : 109 0 40 40

Y 101 0 69 0

159 40

199 40

Comment line x, y, and z scaling and angle as tan(v). Direction, slice no., row from, to and column from and to.

A plot is written to a PostScript file by pressing “d”(ump). The PostScript file gets the name “3dmplnnn.ps” where nnn is a number starting with 001 and increased by one each time “d” is pressed. IMAGEX stays in edit-mode and will cycle through edit and display mode until “q”(uit) is pressed.

Acknowledgments-IMAGEX was inspired by the two- dimensional plotting programs in GSLIB (GSCALE and CSCALE) and the PostScript macros are based on the GSCALE and CSCALE macros. Thanks to Eberhard Mattes for his great work in porting GCC to OS/2 and DOS, to Johannes Martin for the public domain graphical library, and to Rainer Schnitker for the public domain RSX DPMI extender. Also thanks to Peter Frykman at the Geological Survey of Denmark and Greenland; he has, as the first user of IMAGEX, provided many useful com- ments, some of which have lead to changes in the pro- gram. Also thanks to Roy Sidle for correcting my English.

REFERENCES

Adobe, 1985, Adobe System Incorporated PostScript language tutorial and cook-book: Addison-Wesley, Menlo Park, California, 243 p.

Alladin, 1995, GhostScript: Alladin Enterprises, Menlo Park, California (ftp.tex.ac.uk /pub/ghost/).

Deutsch, C. V., and Joumel, A. G., 1992, GSLIB geosta- tistical software library and user’s guide: Oxford University Press, Oxford, 340 p.

Ennlund. E.. and &arks. A.. 1988. GEO-EAS -(Geostatistical Environmental Assessment Software) user’s guide: Environmental Monitoring Systems Laboratory Office of Research and Protection Agency, Las Vegas, Nevada 89193-3487, 214 p.

Golden Software, 1989, SURFER ver. 4.0 reference man- ual: Golden Software Inc., Golden, Colorado, variously paged.

Gomez-Hernandes, J., and Srivastava, R. M., 1990, ISIM3D: an ANSI-C three dimensional multiple indi- cator conditional simulation program: Computers & Geosciences, v. 16, no. 4, p. 395-440.

Martin, J., 1995, SVGAKIT-and VESA graphical library for EMX-GCC: Pfarrer-Darn-StraBe 25 D-55127. Mainz, Marienborn, E-mail: jmartin’@goofy.uni-main: z.de (anonymous ftp.uni-stuttgartde /pub/systems/os2/ emx-0.9a/contrib).

Mattes, E., 1995, EMX DOS and OS/2 port of the GNU C-Compiler: Teckstrape 81, D-71696 Miiglingen, Germany, E-mail [email protected] gart.de (anonymous ftp.uni-stuttgart.de /pub/systems/ os2/emx-0.9a).

Schnitker, R., 1994, RSX: DPMI-DOS 0.9jl.O extender for 80386 + processors: E-mail [email protected] feld.de (anonymous ftp.uni-stuttgart.de /pub/systems/ os2/emx-0,9a/contrib).

Uniras, 1988, AGL/CONTOURS, User guide and refer- ence manual: UNIRAS A/S, 15 Blokken DK-3460 Birkerad, Denmark, 135 p.