APUNDISTORT

undistort aerial photos


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

Back to top

Description


Convert aerial photos to conform to the ideal pin-hole camera model by removing lens distortions in image space. If specified, it also computes the ideal coordinates for GCPs and/or Tie points from their observed or matched coordinates in image space.
Back to top

Parameters


apundistort(oeproji, distort, imgset, oeprojo, outbgd, outdir, resample)

Name Type Caption Length Value range
OEPROJI * str Input OrthoEngine project file 1 -    
DISTORT str Algorithm to use to undistort photos 0 -   Default: LENS
IMGSET str Set of photos to process 0 -   Default: ALL
OEPROJO * str Output OrthoEngine project file 1 -    
OUTBGD List[float] Output background value 0 - 1 Default: 0
OUTDIR str Deliverable output file folder (directory) 0 - 256  
RESAMPLE str Resampling method 0 -   NEAR|BILIN|CUBIC|SINC8|SINC16|AVERAGE|MEDIAN|LAGRANGE4|LAGRANGE8|GAUSSIAN
Default: CUBIC

* Required parameter
Back to top

Parameter descriptions

OEPROJI

The path and file name of the OrthoEngine project file (*.prj) containing the aerial photos to remove distortions.

The aerial camera in the OrthoEngine project file must have undergone a self-calibration. Otherwise, an exception will be thrown.

DISTORT

Specifies the undistort algorithm. The following values are valid:
Example parameter values are:

IMGSET

Specifies which photos should be processed.

Available options are:

OEPROJO

The path and file name of the output OrthoEngine project file to export the undistorted photos.

The output OrthoEngine project file cannot already exisit. If a file with the same name exists, an error message will be thrown.

OUTBGD

The background (NoData) value to use for pixels that are not populated. Each channel is set to the same background value. The background value provided is truncated to the range allowed by the source image data type.

OUTDIR

A folder (directory) to which the distortion-free images will be written. If the folder does not exist, it is created automatically.

If no value is specified for this parameter, a folder that is the basename of OEPROJO is created automatically.

The name of a generated image file has generally the same base name as that of the source image file.

RESAMPLE

The resampling method to use in the undistorting process.

The following methods are supported:

For each resampling method, the parameters MIN=[min], MAX=[max], and FILL=[NN or BGD] can be appended as a comma-delimited list. MIN and MAX define the clamp range for output pixels; this is useful when you want to keep pixel values within a certain range (for example, 1 to 2047 if 11-bit data is stored in a 16-bit file). FILL defines the behavior when the resampling window contains NoData pixels: NN directs the resampler to use the nearest-neighbor method, while BGD indicates that the output pixel will be set to the background value. By default, NN is used as the value of FILL.

Back to top

Return Value

Returns: Execution status

Type:  PCI_INT

The return value is 0. This function returns only if it executes successfully; otherwise, it throws an exception.

Back to top

Details

APUNDISTORT resamples raw image to compensate for lens distortions. The lens distortions can be represented in radial, decentering and grid forms. Especially the distortion grid can be a discrete form from a mix of all types of contiguous distortion models such as from various added self-calibration parameters. With BINGO, the grid can even represent non-lens distortions including corrections from atmospheric refraction and/or earth curvature.

This function has two major steps in processing. First, the transformation relationship is established for the distortion-free photos. This is done by computing the actual coordinates on the raw photo given any ideal coordinates on the distortion-free photo using camera's intrinsic parameters. Second, the values of pixels on the distortion-free photo are obtained by a specified resampling method from the raw photos employing the afore-mentioned transformation.

APUNDISTORT output new disotrtion-free photos to the output directory as well as a new OrthoEngine project file.

Back to top

Example

In the following example, all photos are processed with grid distortions removed, and image observation distortions are removed from GCPs. while all Tie points are deleted from the output OE project file.

from pci.apundistort import apundistort

oeproji = "airphoto_model.prj"
distort = "LENS GRID, POINTS GCP"
imgset = ""
oeprojo = "airphoto_model_undistort.prj"
outbgd = [0]
outdir = ""
resample = "CUBIC"

apundistort(oeproji, distort, imgset, oeprojo, outbgd, outdir, resample)
       

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