Go to the USGS Home Page

USGS MIPS Twfgen Documentation






This program generates a geometric transformation file containing the information necessary for the program GEOM to geometrically transform/project an image . Note, this program does not perform the actual geometric transformation of the image but instead creates the transformation file necessary for the program GEOM to carry out the actual transformation(i.e., GEOM moves the pixels around). Geometrically projecting one image onto another means that one image, referred to as the slave, is warped so that its geometry matches the one of the second image which, referred to as the master. For TFWGEN to create the transformation file, it needs a user-defined control point file that defines how the transformation for the given image is to be carried out. There are generally two types of geometric transformations that are of interest: 1) image-to-image geometric warping and 2) image-to-map geometric transformations.

In the image-to-image option, a slave image is warped so that it has the same geometry as the master image using line and sample locations from both the slave and master images to define the required transformation. The format of an image-to-image control point file is:

      slave_nl,slave_ns,master_nl,master_ns
      id1,slave_line,slave_sample,master_line,master_sample
      id2,slave_line,slave_sample,master_line,master_sample
      id3,slave_line,slave_sample,master_line,master_sample
      .
      .
      .
      .
      .
      .
      idn,slave_line,slave_sample,master_line,master_sample
Nl and ns are equal to the number of lines and samples in the slave and master images. The slave versus master line and sample locations can be selected several different ways. Typically the points can either be selected interactively using the image display device or automatically using the automatic control point procedure(see MASTERCTL).

In the image-to-map option a slave image is warped so that it has the same geometry as a selected map(i.e., in latitude and longitude and a given projection). The format of the image-to-map control point file is:

      slave_nl,slave_ns
      id1,slave_line,slave_sample,map_latitude,map_longitude
      id2,slave_line,slave_sample,map_latitude,map_longitude
      id3,slave_line,slave_sample,map_latitude,map_longitude
      .
      .
      .
      .
      .
      .
      idn,slave_line,slave_sample,master_latitude,master_longitude
The maximum number of control points that the control point file can have is 3000(typically they have much fewer than 3000). Based on the control points specified by the user's file a set of mapping equations are calculated in order to generate the required transformation file. The equations are 2-variable polynomials with a user selected order of degree. That is, if the user selects a 2nd degree polynomial the equations would look something like this:

  sl = a1 + a2*ml + a3*ml*ml + a4*ms + a5*ml*ms + a6*ms*ms
  ss = b1 + b2*ml + b3*ml*ml + b4*ms + b5*ml*ms + b6*ms*ms
Where,

  sl,ss  are the slave line/sample positions
  ml,ms  are the master line/sample positions or map latitude/longitude
  a, b   are coefficients calculated using least squares
The degree can be as high a 10 but usually 2 or 3 is sufficient. The minimum number of control points needed is a function of the degree requested and can be calculated by :

  (degree + 1) * (degree + 2) / 2
Once the equations are calculated they are then used to produce a transformation file(TFILE). The transformation file has corresponding input line/sample and output line/sample values over a grid; the grid can be thought of as a grid that lays on top of the output image(master). In the example below the grid has four columns and three rows:

  *-------*-------*-------*-------*
  |   |   |   |   |
  |   |   |   |   |
  |   |   |   |   |
  *-------*-------*-------*-------*
  |   |   |   |   |
  |   |   |   |   |
  |   |   |   |   |
  *-------*-------*-------*-------*
  |   |   |   |   |
  |   |   |   |   |
  |   |   |   |   |
  *-------*-------*-------*-------*
-- from program documentation --

At each intersection of the grid a least square curve is calculated. However, the control points are weighted depending how close they are to the grid intersections. Points close to the intersections are heavily weighted while those farther away will have little effect on the equation. The weight is 1 / d**2 where d is the distance the control point is from the intersection.

-- end documentation --

-- from Tfgen documentation --

At each intersection of the grid (*) the equation is used to calculate the slave line/sample position that corresponds to that output line/sample. The top left corner is position 1,1 in the output/master image. These are used as the values for ml(=1) and ms(=1) in the equations given above. Using those equation we can calculate sl and ss, the slave position for that intersection. This is done for all 20 intersections in the grid. Note that the bottom right corner is the position that corresponds to (nl,ns) number of lines/samples in the master image. The calculated values at all the intersections used to generate the transformation file that is used by the program GEOM to apply the transformation to the slave image. Note that the number of rows and columns in the grid is selectable by the user; a denser grid usually makes the geomed image fit the control points better if high frequency distortions are present.

-- end tfgen documentation --

  

Files

This program requires as input a user supplied control point file(in ascii) and will generate a transformation file(TFILE) to be used as input into the program Geom. Again, the control point file can be generated severaly different ways(e.g., with a text editor or auto control point selection procedure).

    

Parameters

NROWS and NCOLS

These parameters are used to select the number of rows and columns the transformation grid will contain. The minimum number of rows/columns allowed can be greater than or equal to 2. The maximum number rows/columns allowed can be less than or equal to the number of lines/samples in the master image divided by 4; as long as it is not greater than 2048. The defaults for NROWS and NCOLS are, the sums of 1 and the number of lines in the master image divided by 100, and the sums of 1 and the number of lines in the master image divided by 100 respectively. If the calculated NROWS/NCOLS are less than 2, they will be set to 2. If they are greater than maximum number of rows/columns, they will be set to the maximum number of rows/columns respectively.

See Also

Geom 
Masterctl 
Tfcomp 
Tfgen 
Tfrotscl 
Scale 
U.S. Department of the Interior | U.S. Geological Survey | Jobs
Home | Search | Disclaimers & Privacy Web Rings
Send comments to webman@TerraWeb.wr.usgs.gov
URL:
Last Modified: Thu Oct 31 15:08:21 MST 2002
FirstGov: Your First Click to the U.S. Gov ernment