Help for IMCORNER

PURPOSE

     IMCORNER finds the corners of data in an image and returns
     the (line,sample) coordinates as TAE TCL variables.  These
     can then be used in gengrid2 to generate a grid of points
     for program PICMTCH4.  Data in an image is defined as values 
     greater than a user-specified threshold.
     
     Additionally, if a second image is given, the corners of
     the intersection of data will be given.  For this option,
     the images must both have GeoTIFF labels.  The data are
     aligned by these geographic coordinates instead of by image
     line and sample.  This works nicely with the GeoTIFF label
     option in PICMTCH4.  There is an output parameter that can
     tell you if the first input goes outside the data area of
     the second input.  THIS OPTION PRESENTLY INOPERATIVE!!!!!
     
     The program also outputs the bounding box of the first image.
     The second image does not play a role in this calculation.
     If the corner points algorithm produced a weird result, then
     the bounding box data edges are put into the corner point
     output.
     
     The option corrfoot, if "y", calculates a maximal footprint for
     correlation and puts the coordinates into the bounding box
     output variables.

TAE COMMAND LINE FORMAT

     imcorner INP=(A,B) THRESH=N line1=l1 samp1=s1 line2=l2                samp2=s2 line3=l3 samp3=s3 line4=l4 samp4=s4

     where

     A                   is an image containing data usually 
                         with "gores", that is, null edges
     B                   is an image that geographically overlays A
     N                   is the integer value that defines 
                         gores in the image A.  Values less
                         than or equal N is part of a gore.
     l1                  is a TAE TCL variable to receive the 
                         real value of the line number of the
                         upper left data point
     s1                  is a TAE TCL variable to receive the 
                         real value of the sample number of the
                         upper left data point
     l2,s2               ditto upper right
     l3,s3               ditto lower left
     l4,s4               ditto lower right
OPERATION
     IMCORNER calculates the point at the middle of the image.  Then it
     reads the lines of the image and finds all of the first and last
     points of data in each line and puts them on a candidate list.  The
     point that is furthest from the center point becomes corner point
     number one.  The point on the candidate list that is furthest from
     point one is corner point number two.  The point that has the highest
     sum of squares of distance from those points is corner point number
     three.  The fourth is the point that has the highest sum of areas of
     triangles with all pairs of the other three points.
     
     If a second input is given, the same read operation is performed on
     it.  Then the four points are converted to a geographic coordinate
     and then back to (line,sample) in the first image.  A quadrilateral
     is formed, and the first image process then requires that the
     corner points also be in this quadrilateral.
     
     The program actually skips through the lines of the inputs by
     the square root of (input number of lines).  Then the four best
     points are searched more closely by single lines.  This is a 
     speedup for large images.
     
     IMCORNER also calculates the bounding box of the image for output
     to TAE TCL parameters.
     
RESTRICTIONS
     The mappings must be consistent (e.g. both UTM) but they can vary
     in offset, scale, and rotation.
TIMING

     The program reads the square root of the number of lines times 
     roughly two.  See the algorithm section above.  So it is faster
     than a simple read of the image.
     
WRITTEN BY:                   Al Zobrist         09 SEP 02
COGNIZANT PROGRAMMER:         Al Zobrist

REVISIONS
  2003-01-31 Al Zobrist - Line skipping speedup, and quadrilateral algorithm for 2d input.
  2004-08-11 Al Zobrist - More params for bounding quadrilateral.
  2004-11-29 Al Zobrist - New algorithm for finding four corner points.
  2008-01-11 Walt Bunch - Switched to USES_ANSI_C AND LIB_CARTO; misc cleanup  
  2015-11-05 Walt Bunch - Migrated to MIPL
  2019-09-05 Walt Buinch - IDS-7922 - Initialized some variables; cleaned up -Wall warnings


PARAMETERS:


INP

one or (optionally two) images containing data with "gores"

THRESH

Values less or equal to this are gores in the primary image

INSIDE

returns points this distance inside the corners, useful for picmtch4 correlation window

LINE1

TAE TCL variable to receive the real value of the line number of the upper left data point

SAMP1

TAE TCL variable to receive the real value of the sample number of the upper left data point

LINE2

TAE TCL variable to receive the real value of the line number of the upper right data point

SAMP2

TAE TCL variable to receive the real value of the sample num- ber of the upper right data point

LINE3

TAE TCL variable to receive the real value of the line number of the lower left data point

SAMP3

TAE TCL variable to receive the real value of the sample numb- er of the lower left data point

LINE4

TAE TCL variable to receive the real value of the line number of the lower right data point

BOUND2_1

TAE TCL variable to receive: 0 - if input 2 within input 1 1 - if input 2 exceeds input 1

SAMP4

TAE TCL variable to receive the real value of the sample numb- er of the lower right data point

SLDAT

sl of bounding box for data

SSDAT

ss of bounding box for data

NLDAT

nl of bounding box for data

NSDAT

ns of bounding box for data

CORRFOOT

put a max square of data for correlation in place of the bounding box variables

See Examples:


Cognizant Programmer: