.help irmatch2d Jan90 noao.nproto
.ih
NAME
irmatch2d -- align and match the elements of the mosaiced image
.ih
USAGE
irmatch2d input output database coords
.ih
PARAMETERS
.ls input
The mosaiced image to be aligned. This image must have been produced by
the IRMOSAIC task and have an accompanying database file specified by
\fIdatabase\fR.
.le
.ls output
The aligned and matched image produced by IRMATCH2D.
.le
.ls database
The database file from the IRMOSAIC task.
.le
.ls coords
If \fIalignment\fR = "coords", then \fBcoords\fR is
the text file listing the coordinates of objects in the input
image one object per line in the following
format: 1) the x and y coordinates of the object in the first subraster
2) the x and y coordinates of the same object in the second subraster
3) the x and y coordinates of the next object in the first subraster
etc.
If \fIalignment\fR = "file", then \fBcoords\fR is the text file listing
the x, y and intensity shifts in columns 1, 2 and 3 respectively,
of each input subraster relative to the reference subraster. The
most common use of this option is to make fine adjustments by hand
to the output of IRMATCH2D by editing the computed shifts slightly and rerunning
IRMATCH2D with the new shifts.
.le
.ls xshift
The x shift in pixel units if \fIalignment\fR = "shifts".
.le
.ls yshift
The x shift in pixel units if \fIalignment\fR = "shifts".
.le
.ls alignment = "coords"
The method of aligning the subraster.
.ls coords
The x and y positions of the marker points are listed in a file in the
format specified by the \fIcoords\fR parameter.
.le
.ls shifts
The x and y shifts of a subraster with respect to its neighbour are
set to \fIxshift\fR and \fIyshift\fR.
.le
.ls file
The x,  y  and intensity shifts of each input subraster with respect to the
reference subraster image.
.le
.le
.ls match = "*"
Match intensities using the overlap region between adjacent subrasters. The
median intensity is computed in the overlap region
and the intensity scale of the current subraster is scaled to that of
the previous subraster. Intensities are matched in two dimensions, first
in the order in which they
were placed in the output image and then in the orthogonal dimension.
The default is match everything.
Those subrasters to be matched must be listed by number. For example to
match intensities for subrasters 1 to 5 and 10 to 20 set match = "1-5,10-20".
To match all the subrasters set match = "1-999" or match="*".
.le
.ls nxrsub = INDEF, nyrsub = INDEF
The column and row index of the reference subraster. This will default
to the central subraster.
.le
.ls xref = 0, yref = 0
The x and y offset of the reference subraster in the output image. By default
the reference subraster is placed in the same position in the output image
that it occupied in the input image.
.le
.ls trimlimits = "[1:1,1:1]"
The number of rows and columns to be trimmed off each input subraster
before it is copied to the output image in section notation.
The default is to trim 1 row and column off each edge of the input
subraster.
.le
.ls nimcols = INDEF, nimlines = INDEF
The number of columns and lines in the output image. The default is the
number of lines and columns in the input image.
.le
.ls oval = INDEF
The value of undefined pixels in the output image. The default is the value
in the database file from IRMOSAIC.
.le
.ls interpolant = linear
The type of interpolant used to shift the subrasters. The options are:
.ls nearest
Nearest neighbour interpolation.
.le
.ls linear
Bilinear interpolation.
.le
.ls poly3
Bicubic polynomial interpolation.
.le
.ls poly5
Biquintic polynomial interpolation.
.le
.ls spline3
Bicubic spline interpolation.
.le
.le
.ls verbose = yes
Print messages on the terminal describing the progress of the task.
.le
.ih
DESCRIPTION
IRMATCH2D takes the mosaiced image \fIinput\fR, the database file \fIdatabase\fR
generated by IRMOSAIC and a list of coordinates \fIcoords\fR and computes
an output image \fIoutput\fR in which all the individual subrasters are aligned.
If \fIalignment\fR = "coords", IRMATCH2D accumulates the relative shifts
between adjacent subrasters
into a total shift with respect to the reference subraster. Shifts which
do not correspond to adjacent subrasters are ignored.
For subrasters which have no direct shift information, IRMATCH2D makes
a best guess at the x and y shift based on the shifts of nearby subrasters
which do have direct shift information. If the x and y shifts
are sufficiently uniform over the whole input image the user may set
\fIalignment\fR = shifts and input values of \fIxshift\fR and \fIyshift\fR.
Alternatively the shifts may be read for the file \fIcoords\fR if
\fIalignment\fR = "file".

Coordinate lists may be generated interactively on the Sun workstations
using the IRAF imtool facility and centered using the APPHOT CENTER
and APSELECT tasks.

The subrasters are inserted into the output image using the
interpolation scheme defined by 
\fIinterpolant\fR and is made with reference to the subraster defined
by \fInxrsub\fR and \fInyrsub\fR, using the shifts defined by
the coordinates in the file \fIcoords\fR.
Subrasters are inserted into the output image in the order they were
inserted into the original mosaic with pixels in the most recently
placed subrasters replacing those placed earlier in the overlap regions.
Undefined pixels in the output image
are given the value \fIoval\fR. The position of the reference subraster
in the output image can be shifted by setting the parameters \fIxref\fR and
\fIyref\fR. The \fItrimlimits\fR parameter can be used to trim each
input subraster before it is inserted into the output image.

Intensities of adjacent subrasters can be matched using the \fImatch\fR
parameter. At present matching is done by computing the median in the
overlap region between adjacent subrasters and applying difference in
these two numbers to the subraster in question. Intensity matching is
done in two dimensions,  first along the direction in which subrasters
were inserted into the mosaic and then in the orthogonal dimension.
For example if IRMOSAIC was run with \fIcorner\fR = "ll", \fIdirection\fR =
"row" and \fIraster\fR = "no", then the matching would proceed along
each row starting with the lower-left hand corner and then along
each column beginning again in the lower-left corner.

.ih
EXAMPLES

1. Align an 8 by 8 mosaic with respect to subraster 6, 5.

.nf
    pr> irmatch2d mosaic mosaic.al mosaic.db coords nxrsub=6 \
	nyrsub=5
.fi

2. Align an 8 by 8 mosaic as 1 above but shift the position of the
reference subraster in the output image by 2 pixels in x and 3 pixels
in y.

.nf
    pr> irmatch2d mosaic mosaic.al mosaic.db coords nxrsub=6 \
	nyrsub=5 xref=2 yref=3
.fi

3. Align an 8 by 8 mosaic as 1 above but trim 2 rows and columns off
of each input image before inserting into the output image.

.nf
    pr> irmatch2d mosaic mosaic.al mosaic.db coords nxrsub=6 \
	nyrsub=5 trimlimits="[2:2,2:2]"
.fi

4. Rerun the above example saving the verbose output in a file. Use the 
PROTO package fields task to select the xshift, yshift and intensity
shift fields, edit the shifts slightly and rerun irmatch2d with the
new shifts.

.nf
    pr> irmatch2d mosaic mosaic.al mosaic.db coords nxrsub=6 \
	nyrsub=5 trimlimits="[2:2,2:2]" > shifts1

    pr> fields shifts1 3,4,6 > shifts2

    pr> edit shifts2

	... make whatever changes are desired

    pr> irmatch2d mosaic mosaic.al mosaic.db shifts2 align=file \
	nxrsub=6 nyrsub=5 trimlimits="[2:2,2:2]"
.fi

.ih
TIME REQUIREMENTS
.ih
BUGS
.ih
SEE ALSO
irmosaic, iralign, irmatch1d, apphot.center, apphot.apselect
.endhelp
