PSGMESH

Mesh Perspective Scene Generation


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

Back to top

Description


Generates a three dimensional wire mesh rendering using elevation data, and optionally drapes vectors over the mesh.
Note:
Back to top

Parameters


psgmesh(fili, dbec, escale, filo, dboc, backcol, dbow, meshcol, meshspac, vpoint, vfield, vangle, frontpix, dbvs)

Name Type Caption Length Value range
FILI* str Input file name 1 -    
DBEC* List[int] Input elevation layer 1 - 1  
ESCALE List[float] Elevation Scale and Offset (m) 0 - 2 scale, offset
Default: 1,0
FILO* str Output file name 1 -    
DBOC* List[int] Output perspective scene channel list 1 - 3  
BACKCOL List[int] Background color (RGB) 0 - 3 0,0,0 - 255,255,255
Default: 0,0,0
DBOW List[int] Output window 0 - 4 Xoffset, Yoffset, Xsize, Ysize
MESHCOL List[int] Mesh color (RGB) 0 - 3 0,0,0 - 255,255,255
Default: 128,128,128
MESHSPAC* List[int] Mesh Spacing Interval (X,Y) 1 - 2 1,1 -
VPOINT List[float] Viewing position (X,Y,Z) 0 - 4 Xpos, Ypos, Zpol, Zrel
VFIELD List[float] Field-of-view angle 0 - 1 0 - 170
Default: 0
VANGLE List[float] Viewing angles 0 - 2 0,0 - 360,90
Default: 180,30
FRONTPIX* List[float] Number of foreground pixels 1 - 1 1 -
DBVS List[int] Input vector segment(s) 0 - 6 0,0,0,0,0,0 -

* Required parameter
Back to top

Parameter descriptions

FILI

Specifies the name of PCIDSK file from which elevation and vector data is to be taken.

DBEC

Specifies the input layer or channel that contains the elevation data.

ESCALE

Optionally specifies the scale and offset to apply to the elevation values in the elevation channel (DBEC) to convert values to meters.

If unspecified, scale defaults to 1, and offset defaults to 0.

The equation for the conversion is:

elevation in meters = scale * (value + offset)

For example, to convert elevation values from feet to meters, where a value of 0 represents 1000 feet:

0.3048,1000        : meters = 0.3048 * (value + 1000)

Notes:

It is possible to exaggerate the effect of elevation by using a larger scale value.

It is critical that the ground size of pixels be properly set. This is done when the file is created (for example, CIM function); alternatively, it can be set directly using the APS function.

FILO

Specifies the name of PCIDSK file to which the generated perspective scene will be transferred. FILO must exist before running PSGIMAG.

FILO can be the same as FILI.

DBOC

Specifies which channels in FILO will receive the generated perspective scene.

BACKCOL

Specifies the background (sky) color for the generated perspective scene.

Each background color is in the range of 0-255.

A color can be specified for each channel in the output scene. If no colors are specified, the default is 0. If only one color is specified, that color is used for all other unspecified channels. If more colors are specified than there are channels in the output file, only as many colors as channels are used.

Background color is typically set to 0,0,0 (black), or variations of light blue (for example, 0,160,255) to simulate the sky.

DBOW

Optionally specifies a rectangular window in the output channels in which the generated perspective scene will be embedded.

By default, the perspective scene is embedded in the entire channel.

MESHCOL

Specifies the color used to draw the generated mesh.

Mesh colors are in the range of 0-255. If no color is specified, the mesh color is generated based on the elevation.

A color can be specified for each channel in the output scene. If only one color is specified, that color is used for all other unspecified channels. If more colors are specified than there are channels in the output file, only as many colors as channels are used.

MESHSPAC

Specifies the spacing, in pixels, of the mesh in the X and Y directions.

This spacing is applied to the input data from FILI. If not specified, Y spacing defaults to the X spacing.

VPOINT

Specifies the viewing position of the observer.

Values include:

You can default Zpos and Ypos, or Zpos, Ypos, and Xpos. Or you can specify all three values. Zrel represents an alternate Z dimension; when it is specified, Zpos is ignored.

VFIELD

Specifies the angle of the field of view (viewing cone) in the scene, in degrees from 0 to 170.

The field of view is comparable to camera focal length in photogrammetry; it defines the perspective for the generated scene.

For example:

VANGLE

Specifies the viewing angles in terms of direction and inclination.

If no angles are specified, the defaults are:

The direction angle is expressed in degrees using the following convention:

Example for an MxN image:
               0               
               ^               A direction of 0 looks from
               |               the bottom of the image (line N)
               |               to the top of the image (line 1).
   270 <-------+-------> 90
               |               A direction of 270 looks from the
               |               right of the image (pixel M) to
               V               the left of the image (pixel 1).
              180

The inclination value is expressed in degrees from 0 to 90 and specifies the angle for tilting the earth. This is useful for viewing objects positioned behind others, and provides a greater feeling of depth. A value of 0 provides a profile, 90 offers a straight-down view, and 30 provides a 'human eye' view.

FRONTPIX

Specifies the number of foreground pixels that are represented across the front of the output window.

Depending on the value specified, FRONTPIX (Number of Front Pixels) magnifies or shrinks the size of the foreground pixels. The amount of magnification is calculated as DBOW(3)/FRONTPIX.

FRONTPIX must be greater than 0; a typical value is 128. If a parallel view is being generated, this parameter is often set to the same value as DBOW(3), providing no magnification.

Note: If the viewpoint of the perspective scene is high above ground level, the foreground may appear to have many more pixels than specified by this parameter, due to perspective. Using a very small or very large value may generate a poor result.

DBVS

Specifies the name of the file that contains the input vector segments to be draped on the generated perspective. The input vector segment consists of sets of vectors (type VEC:116); up to 6 sets of vectors can be connected.

Vector sets are colored: red, green, blue, yellow, black, white. In BW perspectives, all vectors are colored white (except black).

Vectors typically represent elements such as roads, rivers and streams, contours, etc.

Vectors are always drawn 1 pixel wide, regardless of the perspective or foreground zooming.

Back to top

Details

PSGMESH generates a three dimensional wire mesh rendering using elevation data, and optionally drapes vectors over the mesh.

Most imagery, at least in remote sensing applications, is taken from high altitudes looking straight down. It is occasionally useful, however, to simulate the view an observer would have if he were standing on the ground looking out over the image at an oblique angle. This is generally known as "Perspective Scene Generation" and requires that elevation data be available for each pixel in the input imagery.

PSGMESH generates the perspective scene using a mesh (or wire model), rather than using solids like the functions PSG and PSGIMAG.

The parameters FILI, DBIC, and DBEC describe where the input imagery and elevation data are obtained.

The parameter ESCALE (Elevation) describes how to convert the elevation values in the input channel into meters.

The parameters FILO, DBOC, and DBOW define the output for the generated scene.

The BACKCOL (Background Color) parameter specifies how to color the background of the output scene for better effect.

The MESHCOL (Mesh Color) describes how to color the generated mesh. If the user specifies a color, the entire mesh is drawn using the specified single color. If no color values are specified, PSGMESH automatically generates colors for the mesh based on the input elevation. For color perspectives, generated colors vary smoothly from blue (low elevation), through green and yellow, to red (highest elevation). For black and white perspectives, colors vary from black (low elevation) through shades of gray, to white (high elevation).

The parameter MESHSPAC (Mesh Spacing, X and Y directions) specifies the spacing, in pixels, to use when generating the mesh.

The parameters VPOINT (Viewpoint), VFIELD (Height Above Sea Level, Height Above Surface, Field of View), and VANGLE (View Direction, View Inclination) describe the imaginary observer's point of view.

The FRONTPIX (Number of Front Pixels) parameter specifies the number of pixels that should be represented across the front of the rendered output window.

The parameter DBVS optionally specifies sets of vectors, held in vector segments, to drape over the rendered perspective. Vectors are drawn 1 pixel wide, regardless of distance or perspective. The first set of vectors is always drawn in red, the second in green, third in blue, fourth in yellow, fifth in black, and sixth in white. Because vector segments can be duplicated in DBVS, a specific color can be obtained by specifying a particular segment multiple times. For example, if segment 26 contains rivers and streams, these could be shown in blue by specifying as three 26 segment vectors.

PSGMESH will write segment 26 in red, then in green, and then in blue. Because blue was written last, only blue would be visible. Keep this overlapping feature in mind when you display these channels. The most important vector should be listed last so that it is not overlapped and hidden by other vector data.

If a single channel perspective (B&W) is being generated, all vectors are drawn in white except the fifth set, which is drawn in black.

The many parameters in PSGMESH, combined with the concepts of perspective geometry, angles and position can make PSGMESH initially difficult to use. Sketching out the extent of the database and carefully determining the view point (VPOINT) and viewing angles (VANGLE) can make PSGMESH much simpler to understand.

Memory usage

PSGMESH is CPU- and memory-intensive.

Memory is allocated dynamically, depending on the dimensions of the input data and the output scene generated. Using very large data sets can easily overload the available RAM on the host computer system, which can result in extremely poor performance or even function failure.

The amount of RAM required can be calculated as the sum of a through c, as shown below:

a) to hold input imagery = 4 * fileXsize * fileYsize

b) to hold output scene = 7 * DBOW(3) * DBOW(4)

c) to hold the largest (optional) vector segment (sizes here can be difficult to determine)

Input Elevation   Output Scene    Vectors    Total RAM Used

4*( 512* 512)  +  7*( 512* 512)  + 1Mbyte   =    3.75 Mbytes
4*(1024*1024)  +  7*( 512* 512)  + 1Mbyte   =    6.75 Mbytes
4*(2048*2048)  +  7*( 512* 512)  + 1Mbyte   =   18.75 Mbytes
4*(4096*4096)  +  7*(1024*2048)  + 1Mbyte   =   79.00 Mbytes

Camera notes

This section provides background information about the camera model used to generate the perspective.

The view point (VPOINT) used in PSGMESH is not the actual eye point, but the center of the bottom edge of the camera image plane. The actual eye point is some distance behind the camera image plane. This distance is determined by a calculation based on the field of view (VFIELD) and the number of foreground pixels (FRONTPIX).

Back to top

Examples

The user wishes to generate a mesh perspective using the elevation data in the file irvine.pix and drape it with vectors. The color of the mesh is to be determined by the elevation height.

The first step is to prepare the data set. Three new channels are created in irvine.pix to store the the output perspective image.

from pci.pcimod import *

fili='irvine.pix'
pciop='ADD'
pcival=[3]                     #Add three 8-bit channels

pcimod(fili,pciop,pcival)

To produce the mesh perspective, the user starts by drawing a diagram of the database and determines the viewing position and viewing angle, as shown below.

+-----------------------+
|                       |
|                       |
|                       |               0
|                       |               |
|                       |               |
|                       |       270 ----+---- 90
|       /               |               |
|      /                |               |
|     X                 |              180
|                       |
+-----------------------+

Because irvine.pix is 512 by 512 in size, the user estimates the viewing position as approximately (150x, 400y) and a viewing angle of 45 degrees. Channel 13 on the modified irvine.pix contains elevation data in meters. Segments 25 and 26 contain vectors representing roads and streams, which the user wishes to drape over the rendered mesh. Output is to three empty channels of irvine.pix.

from pci.psgmesh import *

fili = 'irvine.pix'
dbec = [13]                    #Elevation Channel
escale = []
filo = 'irvine.pix'
dboc = [10]
backcol = [0,0,0]              #Background colors,Black
dbow    = []
meshcol = []                   #Automatic color Generation
meshspac = [8]                 #Space Mesh every 8 pixels
vpoint   = [150,400]            #Viewing Position
vfield  = [40]                 #Field of View Angle 30 degree
vangle  = [45,30]              #View Angle (direction,inclination) in degree
frontpix = [64]                #Number of Pixel in the front
dbvs     = [25,26,26]

psgmesh(fili, dbec, escale, filo, dboc, backcol, dbow,
meshcol, meshspac, vpoint, vfield, vangle, frontpix, dbvs)

After viewing the results, the user decides to exaggerate the elevations in the image by a factor of 2 and try again:

from pci.psgmesh import *

escale = [2.0,0]     #Elevation Scale and Offset

psgmesh(fili, dbec, escale, filo, dboc, backcol, dbow,
meshcol, meshspac, vpoint, vfield, vangle, frontpix, dbvs)

In the final view, the user wants to see a special case: the parallel view (that is, a view with no perspective). FRONTPIX is set to the size of the database to provide an overview of the entire database.

from pci.psgmesh import *

vfield = [0]     #View Field
vpoint = [1,512] #View Point
frontpix = [512] #Number of Front Pixel

psgmesh(fili, dbec, escale, filo, dboc, backcol, dbow,
meshcol, meshspac, vpoint, vfield, vangle, frontpix, dbvs)

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