NAME:
  collapse
 PURPOSE:   (one line only)
  Take a detection image and collapse into a list of unique local maxima
 DESCRIPTION:
 CATEGORY:
  CCD data processing
 CALLING SEQUENCE:
  collapse,image,detect,gap,xmax,ymax
 INPUTS:
  image  - Digital image that is being scanned for discrete sources
  detect - Byte image of same size as image.  Each element of this array
             indicates a level of detection of the corresponding image
             pixel.  Zero would indicate that pixel is of no particular
             interest.  In this routine, a non-zero value of detect is
             taken to indicate that there is something interesting in the
             image at that location.
  gap    - Minimium distance allowed between any two sources when done.
             Whenever there are two apparent detections closer than this,
             the brightest one is recorded.
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
 OUTPUTS:
  detect - This flag array is eroded to leave only those pixels at the
             local maxima turned on.  All nearby points are eliminated.
  xmax   - Array of x locations of local maxima in the image
  ymax   - Array of y locations of local maxima in the image
             These two arrays are an alternate form of detect and are
             provided on output if you want them since they had to be
             generated anyway.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  Written by Marc W. Buie, Lowell Observatory, 2004/07/14
    This routine was extracted from within findsrc.pro