\input COOK82.MAC
\input psfig
\def\doFIG{T}
\def\chapt{7}
\tsect{7.  ANALYZING IMAGES}

     In order to obtain useful astronomical information from the data,
software exists for the analysis of images, combining of images,
estimating errors, {\it et al}.  Only a few of the programs are
described here; the others should be self-explanatory using the HELP
and INPUTS files for the tasks listed in Chapter 14.  A complete list
of software in \AIPS\ for the analysis of images may also be obtained
at your terminal by typing {\us HELP ANALYSIS \CR}.

\subsect{7.1.  Combining images (\/{\tt COMB})}

     The task {\tt COMB} is a general purpose program for combining two
images, pixel by pixel, to obtain a third image.  Many options are
available and, as a first example, we illustrate inputs to derive the
polarization intensity and angle from the Q and U Stokes parameter images.

\subsubsect{7.1.1.  Polarized intensity and position angle images}

     To compute a polarized intensity image, enter:
\dispt{TASK\qs 'COMB' ; INP \CR}{to review the required inputs.}
\disptt{INDI\qs 0 ; MCAT \CR}{to help you find the catalog numbers of the
                        Q and U images that you want to combine.}
\dispt{INDI\qs{\it n1} ; GETN\qs {\it ctn1} \CR}{where {\it n1} and
                        {\it ctn1} select the Q image.}
\dispt{IN2D\qs{\it n2} ; GET2N\qs {\it ctn2} \CR}{where {\it n2} and
                        {\it ctn2} select the U image.}
\disptt{OUTN\qs '{\it xxxxx}' \CR}{where {\it xxxxx} is your choice of
                        outfile name for the polarized intensity image.}
\disptt{OUTC\qs '{\it ccc}' \CR}{where {\it ccc} is your choice of
                        classname for the polarized intensity image,
                        \eg\ {\us PCLN}.}
\dispt{OPCODE\qs 'POLC' \CR}{to select the $\sqrt{{\Qm}^2+{\Um}^2}$
                        algorithm with correction for noise.}
\dispt{BPARM\qs {\it ns1} , {\it ns2} \CR}{to specify the noise levels
                        of the 2 images.}
\dispt{GO \CR}{to compute the corrected, polarized intensity image.}
\pd

     The \AIPS\ monitor should note {\tt TASK COMB BEGINS} followed by a
listing of the {\tt POL.} {\tt INTENSITY} algorithm.  While it is running,
you can prepare the inputs to make a polarization position angle image.  Type:
\disptt{OUTN\qs '{\it yyyyy}' \CR}{where {\it yyyyy} is your choice of
                        outfile name for the polarization angle image.}
\disptt{OUTC\qs '{\it ddd}' \CR}{where {\it ddd} is your choice of
                                class name for the polarization
                                angle image, \eg\ {\us PSIMAP},
                                {\us CHICLN}.}
\dispt{OPCODE\qs 'POLA' \CR}{to select the
                    ${1\over2}\tan^{-1}\left( \Um\over\Qm \right) $
                                algorithm.}
\dispe{Once {\tt COMB} has finished, enter:}
\dispt{GO \CR}{to compute the polarization angle image.}
\pd

     The \AIPS\ monitor should note again {\tt TASK COMB BEGINS}
followed by a listing of the {\tt POL.} {\tt ANGLE} algorithm.  Once
both {\tt COMB} tasks have terminated with {\tt COMB: APPEARS TO END
SUCCESSFULLY} messages on the message monitor, you should find
the requested images in your catalog:
\dispt{MCAT \CR}{to list the images in your catalog.}
\pd

\botpage
\subsubsectl{7.1.2.  Other image combination options}

     {\tt COMB} may also be used to add or subtract images, to rescale them,
and to compute spectral indices, optical depths, {\it et al}.  Type:
\dispt{HELP\qs COMB \CR}{to review the available options.}
\dispe{At the time of writing the options include:}
\par\vskip 5pt
\centerline{\vbox{\halign{\lft{{\us #}}\qquad&\lft{#}\qquad
     &$\lft{#}$\cr
   'SUM '&Addition      &a_1\Times {\MAP}_1 + a_2\Times {\MAP}_2
                              + a_3\cr
 \noalign{\vskip 2pt}
   'MEAN'&Average      &a_1\Times {\MAP}_1 + a_2\Times {\MAP}_2 \qquad
                             except\quad {\MAP}_j\quad where\quad
                             {\MAP}_i\quad blanked\cr
 \noalign{\vskip 2pt}
   'MULT'&Multiplication&a_1\Times {\MAP}_1 \Times {\MAP}_2 + a_2\cr
 \noalign{\vskip 2pt}
   'DIV '&Division      &a_1\Times{{\MAP}_1 / {\MAP}_2} + a_2\cr
 \noalign{\vskip 3pt}
   'SPIX'&Spectral Index&a_1\Times \ln\left( {{\MAP}_1 / {\MAP}_2}\right) /
                         \; \ln\left( {\nu_1 / \nu_2}\right)  + a_2\cr
 \noalign{\vskip 3pt}
   'OPTD'&Opacity       &a_1\Times\ln\left(a_3 {{\MAP}_1 /
                              {\MAP}_2} + a_4\right) + a_2\cr
 \noalign{\vskip 3pt}
   'POLI'&RMS sum       &a_1\Times\sqrt{{\MAP}_1^2 + {\MAP}_2^2} + a_2\cr
 \noalign{\vskip 3pt}
   'POLC'&RMS sum       &a_1\Times C({\MAP}_1,{\MAP}_2)\sqrt{{\MAP}_1^2 +
                               {\MAP}_2^2} + a_2\cr
         &              &\qquad\qquad\qquad\hbox {where $C$ is a
                              noise-based correction for Ricean bias}\cr
 \noalign{\vskip 3pt}
   'POLA'&Arctangent    &a_1\Times{\tan^{-1}}\left( {{\MAP}_2 /
                              {\MAP}_1}\right) + a_2\cr
 \noalign{\vskip 3pt}
   'REAL'&Real part     &a_1\Times {\MAP}_1 \Times \cos \left(
                              a_2\Times {\MAP}_2 \right) + a_3\cr
 \noalign{\vskip 2pt}
   'IMAG'&Imaginary part&a_1\Times{\MAP}_1 \Times \sin \left(
                              a_2\Times {\MAP}_2 \right) + a_3\cr
 \noalign{\vskip 2pt}
   'RM\ \ '&Rotation measure&a_1\Times RM({\MAP}_1, {\MAP}_2) + a_2\cr
 \noalign{\vskip 2pt}
   'CLIP'&Clipping      &{\MAP}_1\qquad except\ blanked\ where\quad a_1 >
                              {\MAP}_2 > a_2\cr
   \     &\             &\phantom{{\MAP}_1\qquad except\ blanked\ whe}or\quad
                              a_2 > a_1 > {\MAP}_2\cr
   \     &\             &\phantom{{\MAP}_1\qquad except\ blanked\ whe}or\quad
                              {\MAP}_2 > a_2 > a_1\cr}}}
\dispe{where the $a_i$ are user-adjustable parameters and ${\MAP}_1$
and ${\MAP}_2$ are the images selected by {\tt INNAME}, {\it et al.}
and by {\tt IN2NAME}, {\it et al.}, respectively.  {\tt COMB} may also
be instructed to write an image of the estimated noise in the combination
rather than the direct result of the combination.}

\subsubsectl{7.1.3.  Considerations in image combination}

     For some applications of {\tt COMB}, undefined pixel values may occur.
For example, if the spectral index is being calculated and the intensity
level on either image is negative, the index is undefined.  In this case,
the pixel value is given a number which is interpreted as undefined or
``blanked.''  Blanking also arises naturally in operations of division,
opacity, polarization angle, and clipping and, of course, the input images
may themselves be blanked.  In addition, the output image can be blanked
(set {\us BPARM(4) = 0}) whenever either ${\MAP}_1 < ${\tt APARM(9)} or
${\MAP}_2 < ${\tt APARM(10)}.  Alternatively, blanking may be done on the
basis of the estimated noise (set {\us BPARM(4) = 1}) or signal-to-noise
ratio (set {\us BPARM(4) = 2}) in the combination.  See {\us HELP COMB \CR}
for a description of these options and certain limitations in their use.
With {\us APARM(8) = 1 \CR}, the user may specify that all undefined pixels
are to be assigned an apparently valid value of zero, rather than the
``magic'' undefined-pixel value.

     When combining two or more images, {\tt COMB}, {\tt PCNTR}, {\it et
al.}~must decide which pixels in the $2^{\und}$ image go with which pixels
in the $1^{\ust}$ image.  The user input parameter {\tt DOALIGN} controls
this process.  A value of 1 requires the two headers to be correct and
sufficiently similar that an alignment by coordinate value is possible.  A
value of $-2$ tells the programs to ignore the headers and align by pixel
number.  Enter {\us HELP DOALIGN \CR} for details and intermediate options.
In some cases, the images may have been created on different grids which are
correctly described in the headers.  The observations, for example, could
have differed in the phase reference position or projective geometry used
or the imaging could have been done with different axis increments.  Such
images should {\it not} be combined directly.  Instead, the header of one
should be used as a template for re-gridding the other.  Task {\tt HGEOM}
provides this service with up to $7^{\uth}$-order polynomial interpolation.
See \Sec 7.4.1 and type {\us EXPLAIN HGEOM \CR} for more information.

\vfill
\eject


\subsect{7.2.  Image statistics  and flux integration (\/{\tt IMEAN},
     {\tt IMSTAT}, {\tt TVSTAT}, {\tt BLSUM})}

     The task {\tt IMEAN} is used to determine the statistics of the image
over a specified rectangular area.  It derives the minimum and maximum
value and location, the rms, the average value and, if the image has been
Cleaned, an approximate flux density within the area.  A typical run
might be:
\dispt{TASK\qs 'IMEAN' ; INP \CR}{to list the input parameters.}
\disptt{INDI\qs{\it n} ; GETN\qs {\it ctn} \CR}{where {\it n} and
                                {\it ctn} select the disk and catalog
                                numbers of the relevant image file.}
\disptt{BLC\qs{\it n1}, {\it n2} ; TRC\qs{\it m1}, {\it m2} \CR}{to
                                set the window from ({\it n1},{\it n2})
                                to ({\it m1},{\it m2}) --- or use
                                {\tt TVWIN} with the cursor on the TV.}
\dispt{DOHIST\qs TRUE \CR}{to make a plot file of the pixel histogram.}
\dispt{PIXRANGE\qs{\it x1}, {\it x2} \CR}{to set the range of the
                                histogram from {\it x1} to {\it x2}.}
\dispt{NBOXES\qs{\it n} \CR}{to set the number of boxes in the histogram.}
\dispt{GO \CR}{to run the task.}
\pd

     The statistics will appear on the \AIPS\ monitor.  For a hard
copy type:
\dispt{PRTASK\qs 'IMEAN' ; PRTMSG \CR}{with {\tt PRIO} $\leq$ 5.}
\dispe{To see the histogram of the intensities, an example of which is shown
in \Sec 6.3.2.3, type one of:}
\dispt{GO\qs TKPL \CR}{to display histogram on the Tektronix.}
\dispt{GO\qs PRTPL \CR}{to display histogram on the printer/plotter.}
\dispt{GO\qs QMSPL \CR}{to display histogram on the laser printer.}
\pd

     The verbs {\tt TVSTAT} and {\tt IMSTAT} provide similar functions to
{\tt IMEAN} without the histogram option.  Both return their results as
{\tt AIPS} parameters {\tt PIXAVG} (mean), {\tt PIXSTD} (rms), {\tt PIXVAL}
(maximum), {\tt PIXXY} (pixel position of the maximum), {\tt PIX2VAL}
(minimum), {\tt PIX2XY} (pixel position of the minimum).  {\tt IMSTAT}
uses the same file name, {\tt BLC}, and {\tt TRC} parameters as {\tt IMEAN}.
{\tt TVSTAT}, however, works on the image plane currently displayed on the
TV and is not limited to a single rectangular area.  Instead, the TV cursor
is used to mark one or more polygonal regions over which the function is to
be performed.  Type {\us EXPLAIN\qs TVSTAT \CR} for a description of its
operation.

     The interactive task {\tt BLSUM} employs a method similar to that
of {\tt TVSTAT}.  The TV cursor is used to mark a region of interest
in a ``blotch'' image.  Then {\tt BLSUM} finds the flux in that region
not only in the blotch image but also in each plane (separately) of a
second image.  More than one region of interest may be done in any
given execution of the task.  In spectral-line problems, the blotch
image is often the continuum or the line sum while the second image is
the full ``cube'' in almost any transposition.  However, numerous
continuum applications also exist (\eg\ polarization, comparison
across frequency).  Type {\us EXPLAIN\qs BLSUM \CR} for a description
of the operation.


\subsect{7.3.  Fitting of images}

     There are three programs which estimate the position and intensity of a
component on a two-dimensional image.  The simple and fast method is the verb
{\tt MAXFIT}.  This fits a two-dimensional parabola to the maximum within a
few pixels of an image position, and gives the peak and its position.  The
tasks {\tt IMFIT} and {\tt JMFIT} are similar and fit an image subsection
with up to four Gaussian components with error estimates.  In one dimension,
the task {\tt SLFIT} fits Gaussian components to slice data and the task
{\tt XGAUS} fits Gaussian components to each row of an image.

\botpage

\subsubsect{7.3.1.  Parabolic fit to maximum (\/{\tt MAXFIT})}

     {\tt MAXFIT}'s speed makes it useful for simple regions.  Type:
\dispt{HELP\qs MAXFIT \CR}{to get a good explanation of the algorithm.}
%\dispt{INP\qs MAXFIT \CR}{to list the inputs.}
\dispe{These should be self-explanatory.  The {\tt IMSIZE} parameter can be
important in crowded fields.  {\tt MAXFIT} can be used conveniently by first
displaying the image on the TV and then typing:}
\dispt{IMXY ; MAXFIT \CR}{ }
\dispe{First the cursor will appear on the TV.  Move it close to a maximum
and hit any of the buttons behind the trackball.  The fit will then appear
on your terminal.}

\subsubsect{7.3.2.  Two-dimensional Gaussian fitting (\/{\tt IMFIT})}

     A more sophisticated least-squares fit of an image is obtained with
{\tt IMFIT}, which fits an image with up to four Gaussian components and
attempts to derive error estimates.  A linear or curved, two-dimensional
``baseline'' may also be fitted.  A sample set-up is as follows:
\dispt{TASK\qs 'IMFIT' ; INP \CR}{to list the input parameters.}
\disptt{INDI\qs{\it n} ; GETN\qs {\it ctn} \CR}{where {\it n} and
                               {\it ctn} select the disk and catalog
                               numbers of the required image.}
\disptt{BLC\qs{\it n1}, {\it n2} ; TRC\qs{\it m1}, {\it m2} \CR}{to
                                set the area to be fitted as
                                ({\it n1},{\it n2})
                                to ({\it m1},{\it m2}) --- or use
                                {\tt TVWIN} with the cursor on the TV.}
\dispt{NGAUSS\qs 2 \CR}{to set the number of components to be fitted
                                to 2.}
\dispt{CTYPE\qs 1, 1 \CR}{to have both components be Gaussians.}
\dispt{GMAX\qs 0.34\qs 0.20 \CR}{to give estimates of peak intensity
                                in Jy.}
\dispt{GPOS\qs 200, 100, 210, 110 \CR}{to give estimates of the pixel
                                locations of each component.}
\disptt{GWID\qs 6 4 20 6 4 20 \CR}{to give estimates of component sizes
                                  in pixels.  In this case, each
                                  component has a FWHP of 6 by 4
                                  pixels with the major axis at
                                  position angle 20 deg.}
\disptt{DOWID\qs FALSE \CR}{to hold all of the widths constant in
                                  the fitting process (if required).}
\dispt{INP \CR}{to review inputs.}
\dispt{GO \CR}{to run the task.}
\pd

     To save execution time, include as small an area as possible in the fit.
In some cases, it is useful to hold some of the parameters constant,
particularly when fitting a complex clump of emission with several
components.  The parameters can interact.  Error estimates are given
for each component.  {\tt IMFIT} will sometimes fail to converge in
complicated regions.  When this happens, you might try using the task
{\tt JMFIT}, which is very similar in function, but uses a different
mathematical method to minimize the rms and to estimate the errors.
Comparison of the results of {\tt IMFIT} and {\tt JMFIT} will sometimes
be instructive.  It is wise to treat the results of {\tt MAXFIT},
{\tt IMFIT} and {\tt JMFIT} with considerable caution, particularly the
estimates of the errors in the component widths after deconvolution.

     Use {\us RUN INPFIT \CR} (see \Sec 12.6) to obtain a procedure
which will help to supply input parameters to {\tt IMFIT}.  This
{\tt RUN} file loads a procedure called {\tt INPFIT} into {\tt AIPS}.
To invoke it, load the image which you want to fit onto the TV with
{\tt TVALL} and type:
\dispt{INPFIT ( 3 ) \CR}{to specify three components.}
\dispe{The procedure will prompt you to set the desired subimage window
with the TV cursor (it uses verb {\tt TVWINDOW}) and then to point the
TV cursor at the peaks of each of the Gaussians, hitting any button when
the cursor is correctly placed.  The inputs {\tt GMAX}, {\tt GPOS}, {\tt BLC},
and {\tt TRC} are set in this way.}

\eject
\subsubsect{7.3.3.  Gaussian fits to slices (\/{\tt SLFIT})}

     You can generate a one-dimensional slice (profile) through any
two-dimensional plane of an image file using the \AIPS\ task {\tt SLICE}.
The output file is appended to the image file as an {\tt SL} extension file.
Slices are computed along lines in the two-dimensional image joining any
valid pair of points selected by {\tt BLC} and {\tt TRC}.  The set of
software dealing with slice file analysis and display can be obtained on your
terminal by typing {\us HELP SL1D}.  The list is also given in Chapter
14.

     To generate a slice:
\dispt{TASK\qs 'SLICE' ; INP \CR}{reviews the inputs to {\tt SLICE}.}
\dispe{Use {\tt INDISK} and {\tt GETNAME} to select the input
image.  The beginning ({\tt BLC}) and ending ({\tt TRC}) points for the
slice can be specified conveniently using the TV cursor if the image to be
sliced is first displayed on the TV with {\tt TVLOD} or {\tt TVALL}.  To
set these points with the TV, type:}
\dispt{TVSLICE \CR}{ }
\dispe{then set the TV cursor to the desired beginning point for the
slice, press any trackball button, and repeat for the ending point for
the slice.  Note that, for slices, {\tt BLC} need not be below or to the
left of {\tt TRC}.  Finally:}
\dispt{GO \CR}{to generate the slice file.}
\pd

     When {\tt SLICE} has terminated (watch the \AIPS\ monitor), the file
may be plotted on the Tektronix 4012 (graphics) terminal using the verb
{\tt TKSLICE}:
\dispt{INP\qs TKSLICE \CR}{to review what you can specify.}
\disptt{INEXT\qs 'SL' ; EXTL \CR}{to find the intensity range and number
                        of points in the interpolated slice.}
\dispe{The default scales will plot all slice points on a vertical scale
from the slice minimum to the slice maximum.  You can alter the part of the
slice that is plotted and the vertical scale by specifying, for example:}
\disptt{BDROP\qs 100 ; EDROP\qs 225 \CR}{to drop 100 points from the
                        beginning and 225 points from the end of the
                        plotted portion of the slice.}
\dispt{PIXRANGE\qs -0.001\qs 0.004 \CR}{to set the range of the vertical
                        axis to be $-1$ to 4 mJy/beam.}
\dispe{Then:}
\dispt{TKSLICE \CR}{to plot the slice on the TEK screen.}
\dispe{Note: several slices may be put on one TEK plot.  Use
{\us TKASLICE \CR} for the additional ones.}

     Slice files may be converted into plot files by:
\dispt{GO\qs SL2PL \CR}{ }
\dispe{The resulting plot files may then be output by:}
\dispt{GO\qs QMSPL \CR}{to display the plot file on the QMS laser printer.}
\dispt{GO\qs PRTPL \CR}{to display the plot file on the printer/plotter.}
\dispe{to obtain a better-quality plot than can be obtained with
the {\tt HARD} {\tt COPY} button on the graphics terminal.  In addition:}
\dispt{GO\qs TKPL \CR}{to display the plot file on the graphics terminal.}
\dispt{GO\qs TVPL \CR}{to display the plot file on a TV graphics plane.}
\pd

     Slice files are archived in your disk catalog as {\tt SL} extensions
to the image file from which they were derived.  Running {\tt SLICE} again
with new parameters does not overwrite the slice file, but makes another
with a higher ``version'' number.  To review and/or delete slice files,
follow the instructions for {\tt EXTLIST} and {\tt EXTDEST} of plot files
in \Sec 6.3 above, but use {\us INEXT\qs 'SL' \CR} in place of
{\us INEXT\qs 'PL' \CR}.

     The task {\tt SLFIT} fits Gaussian components to one-dimensional
data in slice files.  Assuming that the usual
{\tt GETNAME} step has been done, a typical session would go like:
\dispt{INEXT\qs 'SL'; EXTL \CR}{to list the parameters of the slice
                                files.}
\dispt{INVERS\qs{\it m} \CR}{to select the $m^{\uth}$ file for
                             analysis.}
\dispt{TKSLICE \CR}{to plot the slice on the graphics terminal.}
\dispt{EDROP\qs840 ; BDROP\qs 700 \CR}{to select a subsection to fit.}
\dispt{TKSLICE \CR}{to replot just the subsection.}
\dispt{NGAUS\qs 2 \CR}{to fit 2 Gaussians.}
\dispt{TKSET \CR}{ }
\dispe{This verb will prompt you to {\tt POSITION CURSOR AT CENTER
\char'046\ HEIGHT OF GAUSSIAN COMP 1} and will turn on the Tektronix
crosshairs.  Move the crosshairs with the thumbwheels to the
requested position and press any key {\it except} \CR\ on the
Tektronix 4012 keyboard.  The terminal then requests you to
{\tt POSITION CURSOR AT HALFWIDTH OF GAUSSIAN COMP 1} and turns
the crosshairs back on.  Move the crosshairs until they are at
the half-intensity point of the component and press any key except
\CR.  Continue until all components have been entered.  Then type:}
\dispt{TKAGUESS \CR}{to plot the guess on top of the slice plot.}
\dispe{If everything looks ok, then:}
\dispt{GO\qs SLFIT \CR}{to run the task.}
\pd

     When the task gets an answer, the solution will be displayed on the
\AIPS\ monitor, recorded in the message file, and recorded in
the slice file itself.  To get a hard copy of the results:
\dispt{PRTASK\qs 'SLFIT' ; PRTMSG \CR}{to print the message file.}
\dispe{and, to display the results on the graphics terminal, enter:}
\dispt{TKSLICE \CR}{to replot the slice.}
\dispt{TKAMODEL \CR}{to add the model results to the plot.}
\dispt{TKARESID \CR}{to add the residuals (data -- model)
                     to the plot.}
\dispe{To get a higher quality plot of the results, an example of which is
shown in \Sec 6.3.2.1, type:}
\dispt{DORES\qs TRUE ; DOMOD\qs TRUE \CR}{to request the model
                     and the residuals.}
\dispt{DOSLICE\qs FALSE \CR}{to leave the slice data out of the
                     plot.}
\dispt{TASK\qs 'SL2PL' ; GO ; WAIT \CR}{to make a plot file and
                     wait for it to be complete.}
\dispt{GO\qs PRTPL \CR}{to display it on the printer/plotter.}
\pd

\subsubsect{7.3.4.  Other one-dimensional Gaussian fits (\/{\tt XGAUS})}

     {\tt XGAUS} is an interactive task which can fit up to four
Gaussians and a linear baseline to each row of an image.  It writes its
results as a set of $n-1$ dimensional image files.  Although {\tt XGAUS}
was designed for use primarily on transposed spectral-line cubes
(see \Sec 8.5.2), it has a wide variety of other applications.  The
interaction is optional and uses both the terminal and the graphics
screen (Tektronix 4012 or TEK).  The data, initial guess, model fit,
and the residual for each row may be plotted on the TEK screen.  If
the number of Gaussians being fit is larger than one, you may choose
for each row to enter a revised initial guess using the TEK
crosshairs.  This process is similar to that of {\tt TKSET}
described above (\Sec 7.3.3).  This task has too many options to do
them justice here.  Enter {\us EXPLAIN\qs XGAUS \CR} for details.

\botpage
\subsect{7.4.  Image analysis}

     Image analysis is a very broad subject covering essentially all that
\AIPS\ does or would like to do plus specialized programs designed to
analyze a user's particular image in the light of his favorite astrophysical
theories.  \AIPS\ provides some general programs to perform geometric
conversions, image filtering or enhancement, and model fitting and
subtraction.  These are the subjects of the following sections.
Specialized programs for spectral-line and VLBI data reduction are described
in Chapter 9 and 10, respectively.

    Chapter~11 of {\it Synthesis Imaging in Radio
Astronomy}\footnote*{{\it Synthesis Imaging in Radio Astronomy},
A collection of Lectures form the Third NRAO Synthesis Imaging Summer
School, eds. R.\ A.\ Perley, F.\ R.\ Schwab and A.\ H.\ Bridle, Astronomical
Society of the Pacific Conference Series Volume~6 (1989)} covers the topic
of image analysis in more detail.

\subsubsect{7.4.1.  Geometric conversions}

     The units of the geometry of an image are described in its header by the
coordinate reference values, reference pixels, axis increments, axis
dimensions, and axis types.  The types of coordinates (celestial, galactic,
etc.) and the type of tangent-plane projection (SIN from the VLA, TAN from
optical telescopes, ARC from Schmidt telescopes, NCP from the WSRT) are
specified in the \AIPS\ headers by character strings.  See \AIPS\ Memo
No.~27 for details of these projections.  A ``geometric conversion'' is an
alteration of one or more of these geometry parameters while maintaining
the correctness of both the header and the image data.  The \AIPS\ tasks
which do this interpolate the data from the pixel positions in the input
image to the desired pixel positions in the output image.  Most of them
require very large internal buffers and hence, are available only on
virtual-memory computer systems.

     The simplest geometric conversion is a regridding of the data with
new axis increments and dimensions with no change in the type of projection
or coordinates.  Two tasks, {\tt GEOM} and {\tt LGEOM}, perform this basic
function and also allow rotation of the image.  One use of these tasks is
to obtain smoother displays by regridding a subimage on a finer grid.  To
rotate and blow up the inner portion of a $512^2$ image, enter:
\dispt{TASK\qs 'LGEOM' ; INP \CR}{to review the inputs.}
\dispt{INDISK\qs {\it n} ; GETN\qs {\it ctn} \CR}{to select the image.}
\dispt{BLC\qs 150 ; TRC\qs 350 \CR}{to select only the inner portion of the
                          image area.}
\disptt{IMSIZE\qs 800 \CR}{to get an $800^2$ output image.  This will allow
                        the subimage to be blown up by a factor of 3 and
                        rotated without having the corners ``falling'' off
                        the edges of the output image.}
\dispt{APARM\qs 0 \CR}{to reset all parameters to defaults.}
\dispt{APARM(3) = 30 \CR}{to rotate the image $30\deg$ CCW (East from North
                        usually).}
\dispt{APARM(4) = 3 \CR}{to blow up the scale (axis increments) by a factor
                        of 3.}
\dispt{APARM(6) = 1 \CR}{to use cubic polynomial interpolation.}
\dispt{INP \CR}{to check the inputs.}
\dispt{GO \CR}{to run the program.}
\dispe{{\tt LGEOM} allows shifts of the image center, an additional scaling
of the $y$ axis relative to the $x$ axis, and polynomial interpolations of
up to $7^{\uth}$ order.  Type {\us EXPLAIN LGEOM \CR} for more information
and advice.  {\tt GEOM} is a small-buffer version of {\tt LGEOM}.  As a
result, it works on non-virtual-memory computers, but is very limited in
the amount of rotation it can do on larger images. These tasks should be
used for rotation only if the pixels are square.}

     A much more general geometric transformation is performed by {\tt HGEOM},
which converts one image into the geometry of a second image.  The type of
projection, the axis increments, the rotation, and the coordinate reference
values and locations of one image are converted to those of a second image.
{\tt HGEOM} should be used before comparing images (with {\tt COMB},
{\tt GREYS}, {\tt PCNTR}, {\tt BLANK}, {\tt TVBLINK}, etc.) made with
different geometries, \ie\ radio and optical images in different types of
projection or VLA images taken with different phase reference positions.
Use {\us EXPLAIN HGEOM \CR} to obtain the details and useful advice.

     A  potentially very powerful transformation is performed by {\tt PGEOM}.
In its basic mode, it converts between rectangular and polar coordinates.
An example of this operation is illustrated in \Sec 7.4.4.  However,
{\tt PGEOM} can also ``de-project'' elliptical objects to correct for their
inclination and ``unwrap'' spiral objects.  Type {\us EXPLAIN PGEOM \CR} for
information.

\subsubsect{7.4.2.  Filtering}

     For our purposes here, we can define ``filtering'' as applying an
operator to an image in order to enhance some aspects of the image.  The
operators can be linear or nonlinear and do, in general, destroy some of
the information content of the image.  As a result, users should be cautious
about summing fluxes or fitting models in filtered images.  (Technically,
these remarks can also be made about Clean and self-calibration.)  However,
filtered images may bring out important aspects of the data and often make
excellent, if unfamiliar-looking, displays of particular aspects.

     {\tt NINER} produces an image by applying an operator to each cell
of an image and its 8 nearest cells.  The task offers three nonlinear
operators which enhance edges (regions of high gradient in any direction).
It also offers linear convolutions with a $3\times3$ kernel which can be
provided by the user or chosen from a variety of built-in kernels.  Among the
latter are kernels to enhance point sources and kernels to measure
gradients in any of 8 directions.  The {\tt 'SOBL'} edge-enhancement filter
can bring out jets, wisps, and points in the data, while the gradient
convolutions produce images which resemble a landscape viewed from above
with illumination at some glancing angle (as when viewing the Moon).  Both
are very effective when displayed on the TV or by the {\tt GREYS} / {\tt QMSPL}
combination (see \Sec 7.4.4).  Enter {\us EXPLAIN NINER \CR} for additional
information.

     {\tt MWFLT}, at present, applies any one of four nonlinear, low-pass
filters to the input image.  Each filter is applied in a user-specified
window surrounding each input pixel.  One of the operators is a
``normalization'' filter designed to reduce the dynamic range required for
the image while bringing out weaker features.  The others produce, at each
pixel, the weighted sum of the input and the median, the ``alpha-trimmed''
mean, or the alpha-trimmed mode of the data in the window surrounding the
pixel.  These last filters can be turned into high-pass filters by
subtracting the output of {\tt MWFLT} from the input with {\tt COMB}.
Type {\us EXPLAIN MWFLT \CR} for further information.

\subsubsect{7.4.3.  Modeling}

     The addition of model data to an image or \uv\ data set is often useful
either to simplify later processing steps or to study processing steps using
a ``source'' of known structure.  For example, the removal of the response
to an appropriate uniform disk from the \uv\ data for a planet will leave
Clean the task of deconvolving only the remaining fine-scale structure to
which it is well suited.  The removal of a few bright point sources of known
position and strength may allow imaging with significant tapers in a
numerically smaller field.  The tasks {\tt IMMOD} and {\tt UVMOD} will add
(or subtract) a point, Gaussian, disk, or rectangular source to the (scaled)
input image or \uv\ data, respectively.  Both tasks can also add noise and
both allow the original data to be replaced by the model.  Type {\us EXPLAIN
IMMOD ; EXPLAIN UVMOD \CR} for details.

     The task {\tt CCMOD} will create a clean-components file representing
the chosen Gaussian or disk model.  Clean may then be ``restarted'' with
the model as its initial set of components.  The task {\tt UVFIT} may be
useful for fitting Gaussian or uniform-sphere models to small ($ < 2000
$ visibility) \uv\ data sets.

\botpage
\subsubsect{7.4.4.  Examples}

\vfill
\if T\doFIG
   \centerline{\hss\psfig{figure=FIG/CNTR.PLT,height=3.85in}\hss
       \psfig{figure=FIG/LGEOM.PLT,height=3.85in}\hss}
\else
   \vbox to 3.85in{\vfill\omit\vfill}
\fi
\vfill
\hbox to \hsize{\hbox to 0.5\hsize{\hss input image\hss}\hss
\hbox to 0.5\hsize{\hss{\tt LGEOM} with rotation and interpolation\hss}}
\vfill
\if T\doFIG
   \centerline{\hss\psfig{figure=FIG/PGEOM.PLT,height=3.85in}\hss
      \psfig{figure=FIG/NINEG.PLT,height=3.85in}\hss}
\else
   \vbox to 3.85in{\vfill\omit\vfill}
\fi
\vfill
\hbox to \hsize{\hbox to 0.5\hsize{\hss{\tt PGEOM}\hss}\hss
\hbox to 0.5\hsize{\hss{\tt NINER}: {\tt 'SE  '} derivative\hss}}

\eject
\end
