; HLPTVSAD
;---------------------------------------------------------------
;! Finds and fits Gaussians to portions of an image with interaction
;# TASK ANALYSIS MODELING INTERACTIVE TV
;-----------------------------------------------------------------------
;;  Copyright (C) 2014
;;  Associated Universities, Inc. Washington DC, USA.
;;
;;  This program is free software; you can redistribute it and/or
;;  modify it under the terms of the GNU General Public License as
;;  published by the Free Software Foundation; either version 2 of
;;  the License, or (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU General Public License for more details.
;;
;;  You should have received a copy of the GNU General Public
;;  License along with this program; if not, write to the Free
;;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
;;  MA 02139, USA.
;;
;;  Correspondence concerning AIPS should be addressed as follows:
;;         Internet email: aipsmail@nrao.edu.
;;         Postal address: AIPS Project Office
;;                         National Radio Astronomy Observatory
;;                         520 Edgemont Road
;;                         Charlottesville, VA 22903-2475 USA
;-----------------------------------------------------------------------
C-----------------------------------------------------------------------
CURVALUE
This option will display the image or residual image intensities and
pixel position selected by the TV cursor.  Hit any button to terminate
the operation.
C-----------------------------------------------------------------------
TVFIDDLE
This option allows you to set the zoom factor and center to blow up the
data plot for more accurate cursor positioning.  It also allows you to
alter the look-up-tables.  Button A selects image enhancement, altering
between black-and-white and the AIPS-standard color contours.  Button B
increments the zoom or resumes zoom-center mode, while button C
decrements the zoom or resumes zoom-center mode.  Button D ends the
enhancing and returns to the menu.  Instructions appear on the terminal.
Note that this is a pixel replication zoom which appears when you are
doing operations but not when the menu is displayed.  The ZOOM IN
option instead allows to to re-display the island image with a different
interpolation factor.
C-----------------------------------------------------------------------
OFF TVZOOM
This option resets any TVzoom (pixel replication) factors and zoom
center.  The image is actually shown in zoom only during operations
(where zoom may help you point more accurately), during the setting of
the zoom and of the black-and-white or color enhancements, and during
image loading.
C-----------------------------------------------------------------------
OFF TRANS
This option turns of any black-and-white and color enhancements done
in TVFIDDLE.
C-----------------------------------------------------------------------
ZOOM IN
Reload the image with the pixel interpolation factor increased by one.
C-----------------------------------------------------------------------
ZOOM OUT
Reload the image with the pixel interpolation factor decreased by one.
C-----------------------------------------------------------------------
REBOX
This allows you to reset the rectangular window of image values used in
the fitting of the Gaussians.  The terminal will issue instructions.
While setting the lower left corner of the window for the first time,
any button will mark the corner and switch to setting the upper right
corner of the window.  While setting the upper right corner or resetting
the lower left, button A marks the current corner and switches to the
other corner, buttons B, C and D exit.
C-----------------------------------------------------------------------
ENTER GUESS
This option allows you to enter guesses for up to 4 Gaussians.
Instructions will appear on the terminal.  Point at Gaussian component 1
(its peak and peak position) with the TV cursor and hit buttons A, B, or
C.  Having done that, point at the half-power point along the major axis
and hit buttons A, B, or C.  Finally, point at the half-power point on
the minor axis and hit buttons A, B, or C.  Then the function loops and
asks for the same things for Gaussian component 2, 3, 4, and so on up
to 8.  At any time, if you press button D, the process stops and NGAUSS
is set to the last component which you specified completely.  The
CURVALUE function will operate will you move the cursor to the points
to be selected.
C-----------------------------------------------------------------------
REDO GAUSS <n>
This option allows you to change the guess for Gaussian number <n>,
leaving the guesses for all other Gaussians unchanged.  Instructions
will appear on the terminal.  Point at Gaussian component <n> (its
peak and peak position) with the TV cursor and hit buttons A, B, or C.
Having done that, point at the half-power point along the major axis
and hit buttons A, B, or C.  Finally, point at the half-power point on
the minor axis and hit buttons A, B, or C.  The CURVALUE function will
operate will you move the cursor to the points to be selected.  To
change the number of Gaussians, you must ENTER GUESS for all of them.
C-----------------------------------------------------------------------
DO FIT
This option tells the task to stop the TV interaction and to attempt the
fit of this island with the current initial guess.  If the fit fails
either in the mathematical routines or in finding unreasonable answers,
the current island will be re-displayed on the TV and you will need to
enter a new guess and/or a new window to re-try the fit.  You may also
elect to skip this island and go on to the next (NEXT ISLAND).
C-----------------------------------------------------------------------
TVOFF
This option is the same as DO FIT but it turns off TV interaction for
this and subsequent island until a failure of some sort occurs after
which TV interaction is restored.  The DO FIT option tells the task to
attempt the fit of this island with the current initial guess.  If the
fit fails either in the mathematical routines or in finding
unreasonable answers, the current island will be re-displayed on the
TV and you will need to enter a new guess and/or a new window to
re-try the fit.  You may also elect to skip this island and go on to
the next (NEXT ISLAND).
C-----------------------------------------------------------------------
NEXT ISLAND
This option tells the task to abandon any attempt to fit the current
island and to go on to the next island.
C-----------------------------------------------------------------------
QUIT
This option tells the task to abandon any attempt to fit the current
island or any more islands.  The task then stores all fit parameters
from previous islands, reports the results if requested, and writes
out the residual image and any tables requested.
C-----------------------------------------------------------------------
GOOD
This option appears with the residual image of the current island and
tells the task to accept this fit and to go on to the next island.
C-----------------------------------------------------------------------
RE-TRY
This option appears with the residual image of the current island and
tells the task to return to the main TV interaction to attempt to fit
this island over again.
C-----------------------------------------------------------------------
