Help for RPC_FIT

PURPOSE
   This takes an image and RPC coefficients that map project that image.
   The data is then matched against a reference image, and the results of
   that match are used to improve the RPC coefficients.

   The changed RPC coefficients are updated into the input file.

CALL
    rpc_fit INP REF_IMAGE DEM DATUM (MAXDIFF) (RPC_LNUM_FIT)          (RPC_SNUM_FIT)
  WHERE:
     INP             1) is the input data set (must have RPC metadata)
                     2) is the ground truth image (must have map projection 
                     metadata)  
                     3) is the DEM (must have map projection metadata)
                     4) is the land/water mask.
     MAXDIFF         optional maximum difference between initial warped 
                     INP and REF_IMAGE, in meters (default 1000 m)
     RPC_LNUM_FIT    optional line numerator RPC parameters to fit in range
                     0 to 19 (i.e., zero based) (default constant term (0) and
                     height term 3)
     RPC_SNUM_FIT    optional sample numerator RPC parameters to fit in range
                     0 to 19 (i.e., zero based) (default constant term (0) and
                     height term 3)

OPERATION

This does image matching between a INP and a REF_IMAGE, 
and adjusts the initial RPC coefficients read from the INP
to give a better match between this map projected imagery and the REF_IMAGE.

This is done in two steps. First we do a coarse fit to get the
map projected roughly right, and then we do a finer adjustment to
give a better fit.

The first step is the coarse fit. Since an RPC is usually based on
navigation data only, without and ground control points, it can
give relatively large errors. We do a coarse shift to the RPC to
reduce the errors enough that we can do a finer fit. 

We first average the image and the Ref_img. We average so that we
are coarse enough that the given image matching search window size
will contain errors up to MAXDIFF meters.
For example, with a 1000 m Max_diff, a search window of
15, and 5 m Ref_img, we would average by a factor of 14
(5 m x 14 factor x 15 search window = 1050 m error, allowing us to
find 1000 m differences).

We use a Forstner feature detector to determine where to match, starting
with a regular grid of points and then shifting to interest points. 
We then match at these features between the reference and map projected 
images using a cross correlation matcher.

We update the LINE_OFFSET and SAMPLE_OFFSET of the RPC only in the
first phase, reducing the difference between the map projected image
and the REF_IMAGE.

We repeat the coarse fit until the remaining differences between
the map projected data and the REF_IMAGE fall within matching search
window at full resolution.

We follow this with a fine fit. We again use the Forstner feature
detector to determine where to match. We then match at these features
between the reference and map projected images, but this time using a
combination of a cross correlation matcher followed by a least squares
matcher to get subpixel accuracy.

We fit for the RPC parameters given by the user.

This fine matching step is repeated until the change in average
difference from one step to the next is less than a tolerance (5%
change).

Restrictions
------------

The INP must have an RPC label (in the GeoTIFF property label for 
VICAR, at present NITF must be logged with VEXTRACT).

The REF_IMAGE, DEM and LANDWATER mask need to have map projection metadata
(i.e. the GeoTIFF labels for VICAR format).

The vertical datum for the RPC and the DEM MUST MATCH.  In all forseeable
cases these data will be WGS84 (a spheroid).


Original Programmer: Mike Smyth, 4 Mar, 2008
Current Cognizant Programmer: Mike Smyth

REVISIONS
2022-08-10 B. Crocco open source afids (untested)


PARAMETERS:


INP

The image to be map projected (updated)

REF_IMAGE

The reference image that supplies ground truth.

DEM

The Digital Elevation Model (DEM) to be used the the RPC.

LANDWATER

The land/water mask to use.

MAXDIFF

Maximum difference between initial warp of INP and REF_IMAGE, in meters.

RPC_LNUM_FIT

RPC Line Numerator parameters to fit for.

RPC_SNUM_FIT

RPC Sample Numerator parameters to fit for.

See Examples:


Cognizant Programmer: