SGMMERGE

Merge nadir-forward and nadir-backward epipolar digital surface models (DSM)


EnvironmentsPYTHON :: EASI
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Related

Back to top

Description


SGMMERGE is specific to tri-stereo cameras, such as an ADS aerial line scanner or a Pleiades satellite). The algorithm merges a nadir-backward and nadir-forward epipolar DSM, created with the EPIPOLARDSM algorithm, into a single, final DSM, and then applies optional filtering. The final DSM has typically higher quality and accuracy than either input DSM. Both input DSMs must be identical in nadir-epipolar space.
Back to top

Parameters


sgmmerge(file_bn, file_fn, filo, demfilt, segsize, demopts)

Name Type Caption Length Value range
FILE_BN * str File name of input nadir-backward DSM 1 -    
FILE_FN * str File name of input nadir-forward DSM 1 -    
FILO * str File name of output DSM 1 -    
DEMFILT str Filter level 0 -    
SEGSIZE List[int] Threshold size of isolated segments to remove 0 - 1  
DEMOPTS str Merging options 0 -    

* Required parameter
Back to top

Parameter descriptions

FILE_BN

The nadir-backward DSM generated by EPIPOLARDSM.

The nadir image used in generating the DSM must be the same as that specified for FILE_FN.

FILE_FN

The nadir-forward DSM generated by EPIPOLARDSM.

The nadir image used in generating the DSM must be the same as that specified for FILE_BN.

FILO

The name of the output file. A file with the same name must not exist in the output folder. The file will be created using FILE_NB as a reference. The elevation and score channels will be replaced with the merged versions.

DEMFILT

The level of filtering to apply to the generated DSM. The process applies successive noise, median, and smoothing filters.

The available values are as follows:
You can apply a custom filter by specifying any of the following:
Regardless of the order you specify, SGMMERGE applies filtering in the following order:
  1. Noise
  2. Median
  3. Smoothing
A typical example of a filtering application is as follows: The preceding applies a medium noise filter, a hybrid 5 x 5 median filter, and a 3 x 3 bi-level-smoothing filter.
Note: If you specify a filter that is not in the preceding list, such as k=23, it is ignored.

SEGSIZE

The threshold at which to eliminate segments and interpolate values of the digital elevation model (DEM) from the surrounding data. A segment is a small, isolated group of matching pixels. Blunders often occur in these segments.

Typically, values ranging from 16 through 128 provide satisfactory results in most cases. The default value is 64. A value of zero (0) switches off the operation.

DEMOPTS

The various processing options to apply. Currently, only LAZ is supported, which is a lidar-point-cloud file in LAZ V1.2 format. The file contains all valid DEM points and any color and imagery data available. The file is created using the folder and file name of the output file you specified, and the file will have a .laz file name extension.

This parameter is optional.

The various processing options to apply.
Back to top

Details

SGMMERGE merges a forward-nadir and backward-nadir DSM (both in epipolar nadir space) into a new DSM. The merged DSM is of higher quality than that created with a single backward-forward pair, because the pair can be used to cross-check for blunders and occlusions, such as those due to building lean. If necessary, data in the backward-nadir DSM can be used to fix blunders and occlusions in the forward-nadir DSM, and vice versa. Because the geometry of the resulting DSM is epipolar nadir, less 'lean' is introduced.

At each point in the DSM, the forward-nadir and backward-nadir elevations are compared. When the threshold of difference between the two is small—that is, they more-or-less agree—the average of the two is used. When the threshold is exceeded, it is considered a blunder and the elevation is interpolated from the surrounding good data. All work is performed in epipolar-nadir space, so errors introduced by geocoding incorrect values are avoided.

SGMMERGE is useful only with true, tri-stereo sensors, such as the ADS aerial-strip camera and some tri-stereo-capable satellites, such as Pleiades or ZY3.

The resulting merged DSM may contain some residual blunders. Typically, these are small, disconnected patches surrounded by interpolated pixels. Such blunders can be removed by specifying a value for the SEGSIZE parameter. The default of the parameter is 64 pixels, but you can specify another size. You can also switch off the process by entering a value of zero (0). With forestry applications, a smaller value is preferred (to preserve tree crowns, for example), but with urban areas, or if DTMs will be produced from the DSM, a larger value may produce better results.

If necessary, you can create your output file in LAS or LAZ (V1.2) format by entering "LAZ" (or "LAS") as the value of DEMOPTS. By doing so, the file will be created in the folder you specified for the output file with the file name <output_file_name>_#.laz. For example, if the name of your output file is mergedsm.pix, the name of the output LAZ file is mergedsm_0.laz. If the number of output points is very large, several LAZ/LAS files may be created. Points are geocoded automatically.

The typical workflow is as follows:
  1. Create forward-nadir and backward-nadir pairs by running EPIPOLARDSM with no filtering
  2. Create a new, filtered, and merged DEM by running SGMMERGE
  3. Geocode the final DSM by running GEOCODEDEM
Back to top

Example

You have an ADS 100 tri-stereo Level 1 strip (forward.pix, nadir.pix, and backward.pix) from which you want to generate a DSM. The first step is to generate the forward-nadir and backward-nadir epipolar DSMs by running EPIPOLARDSM. In both cases, the left image will be the nadir view, and only simple noise filtering will be performed (DEMFILT="nh"). More advanced filtering and smoothing of the DSM will occur during merging.

from pci.epipolardsm import epipolardsm
from pci.sgmmerge import sgmmerge

leftfile    = "nadir.pix"
rghtfile    = "backward.pix"
extinter    = [2]
filedem     = "nadir_backward.pix"
demfilt     = "nh"
costfunc    = "MI"
penalty     = []
segsize     = []
demopts     = ""

epipolardsm(leftfile, rghtfile, extinter, filedem, demfilt, costfunc, penalty, segsize, demopts)

leftfile    = "nadir.pix"
rghtfile    = "forward.pix"
filedem     = "nadir_forward.pix"

epipolardsm(leftfile, rghtfile, extinter, filedem, demfilt, costfunc, penalty, segsize, demopts)

file_bn    = "nadir_backward.pix"
file_fn    = "nadir_forward.pix"
filo       = "merged_dsm.pix"
demfilt     = "medium"
segsize     = [32]
demopts     = ""

sgmmerge(file_bn, file_fn, filo, demfilt, segsize, demopts)

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