User's Guide

IMGCORNER

Determines actual corner points of image data which is surrounded by fill.

Function:

Determines the actual corner points of image data which is surrounded by fill. These corner coordinates can then be used to trim the scene.

Parameters:

IN
Input image. The input image which will have the image corners found. This image may be multi-banded. See USERNOTE #1.

OUTLT
Output labeled table The output labeled table contains the set of the four corner coordinate pairs needed to trim the fill around the valid scene data.

OFFSET(0)
Offset distance. The distance the corner pixels will be moved toward the center. The corner will be moved OFFSET in both the line direction and the sample direction.

FILLVAL(0)
Fill value. The value of the fill that surrounds the image data. If a range of values exist, the first value is the lower bound and the second value will be considered the upper bound. Two ranges can be specified by setting FILLVAL=(lower_value1 upper_value1 lower_value2 upper_value2).

METHOD(NOFILL)
Calculation method. The method used to calculate the image data corners.

  = NOFILL:   NOFILL.  The first values that are 
              not fill values are used as image 
              corners.
  = LSE:      Least squared error fit.  A least 
              squared error fit is used to 
              calculate the corner values.

PRINT(TERM)
Output destination. The destination of the output.

  = TERM:      Terminal.  Output is sent to the user's
               terminal.
  = LP:        Line printer.  Output is sent to the
               printer defined by $PRINTER.
  = Filename:  User-supplied filename.  Output is sent
               to a disk file named "filename".

Examples:

  1. LAS> imgcorner in=image outlt=corners offset=10 fillval=0

    The image IMAGE is searched to find the corner points. The NOFILL method is used. The points are selected by finding the non zero data which is closest to each corner. Then the corners are moved toward the center by 10 pixels in both the line and sample directions. These points are then written to the labeled table file CORNERS, and to the terminal.

  2. LAS> imgcorner in=pmask outlt=corn offset=15 fillval=(0,10) method=lse

    The image PMASK is searched to find the points on the edge of the fill data and the image data. The fill value will be data with values which lie between 0 and 10 inclusive. A least squared error fit is applied to find the corners. Then the corners are moved toward the center by 15 pixels in both the line and sample directions. These points are then written to the labeled table CORN, and to the terminal.

Description/Algorithm:

For the NOFILL method the corners are found by finding the non-fill data which is the closest to the input image corners. Then these corners are moved toward the center by OFFSET pixels in both the line and sample directions.

For the LSE (least squared error) method, N valid data points along each edge of the scene, which is surrounded by fill, are found. These N points are used to estimate the equation of the line that best fits them. The Least Squares Method determines the slope and y-intercept for each line. The intersections of these lines are the corners of the scene's valid data. Next, the corner coordinates that create the largest possible polygon with the smallest amount of invalid or fill data are determined. These equations are


  m = {n*sum(x*y) - [sum(x) * sum(y)]} / {n*sum(x*x) - sum(x)*sum(x)}

  b = mean(y) - m*(mean(x))

  Where:	m is the slope,
		b is the y-intercept,
		x is the individual sample locations,
		y is the individual line locations.

The slope, m, and the y-intercept, b, are found for each set of data points representing each edge. An equation is created in the form of y = m*x + b. An equation of this form is determined for each of the four edges of the valid scene data. The y-intercept is adjusted to offset the line so that the values created from resampling are cut off. The corner points of the scene can be determined by calculating where the lines intersect. Intersection points are found by setting the intersection line equations equal to each other.

Two equations represent the two lines that intersect at a corner:

	y = m1*x + b1         y = m2*x + b2

Set the two equations equal and solve for the x coordinate:

             m1*x + b1 = m2*x + b

           m1*x - m2*x = b2 - b1

           (m1 - m2)*x = b2 - b1

                     x = (b2 - b1) / (m1 - m2)

Substitute back in to solve for y.  Use the known m and b from one of
the original equations:

                     y = m1*[(b2 - b1) / (m1 - m2)] + b1

The x and y found for each intersection represents the sample and line values, respectively, at that particular corner. The coordinates for each corner are determined in this manner for each band and saved. The corner points for each band are compared and the largest possible polygon containing the least amount of unwanted fill is determined.

These four corner points can then be used to trim the image to remove the fill and smeared resampling values. The final four coordinate pairs are written to OUTLT.

Nonfatal Error Messages:

  1. [imgcorner-nonfatal] Nonfatal error encountered

    A nonfatal error was encountered during processing. The program's data is valid and therefore saved. The message displayed immediately preceding this error message is the specific error encountered. Processing continues.

Fatal Error Messages:

  1. [imgcorner-alloc] Could not allocate appropriate space

    The amount of space needed to process could not be allocated. Check with system administrator for status of the system.

  2. [imgcorner-fatal] Fatal error encountered

    A fatal error was encountered during processing. The error message displayed immediately preceding this message is the specific error encountered. Processing is terminated.

  3. [imgcorner-open] Error opening temporary file

    An error ocurred opening the temporary file. Check to be sure that that there are sufficient privileges in the current directory.

  4. [imgcorner-window] Images do not have the same window sizes

    Images must have the same window size.

User Notes:

  1. For the method NOFILL, the input image may be multi-banded; however, only the first band will be used to calculate corner coordinates.

  2. For the method LSE only one set of four corners is calculated, not one set for each band. This set of corners should then be applied to each band.