% @(#)rebin_deco.hlq	19.1 (ESO-IPG) 02/25/03 13:30:33 
\se
SECTION./DECONVOLVE
\es\co
REBIN/DECONVOLVE                                            04-OCT-1988  LL,DB
\oc\su
REBIN/DECONVOLVE frame psf result zoom_x,zoom_y n_iter
	rebin image linearly in space and simultaneously deconvolve it with psf
\us\pu
Purpose:      Rebin an image linearly in space and simultaneously deconvolve
              it with user-supplied point spread function.
              (Reference: L.B. Lucy: 1974, Astron. J. 79, 745-754)
\up\sy
Syntax:       REBIN/DECONVOLVE frame [psf] result zoom_x,zoom_y [n_iter]
\ys\pa
              frame     = name of input image
\ap\pa
              psf       = name of point spread function image (default: psf)
\ap\pa
              result    = name of result frame
\ap\pa
              zoom_x,zoom_y = zoom factors in X and Y
\ap\pa
              no_iter   = number of iterations, defaulted to 1
\ap\no
Note:         1.) It is highly recommendable first to remove the
                  background to the lowest possible level, however NOT
                  thereby introducing pixels with negative fluxes. See also
                  commands FIT/FLAT_SKY, SUBTRACT/SKY, and FILTER/FILL.
\\
              2.) The PSF must have odd numbers of pixels in both X and Y
                  (which however do not have to be same for both coordinates);
                  it must be centered on the central pixel. The step sizes
                  must be the ones desired for the result frame. If the
                  empirically determined PSF (not zoomed) is n pixels wide,
                  it is recommended to construct from it the required
                  zoomed (by a factor z) PSF to have (n+2)*z pixels.
\\
              3.) The zoom factors must be odd integers and consistent with
                  the ratios of the step sizes of inframe and psf. Zoom
                  factors less than unity are illegal. For zoom_x =
                  zoom_y = 1, the command is functionally equivalent to
                  DECONVOLVE/IMAGE (but slower!).
\\
              4.) The result frame must have the same step size as the
                  point spread function. The number of pixels must be
                  compatible with the number of pixels of the input frame
                  and the zoom factors.
\\
              5.) If MID_WORK contains a file 'result.bdf', this file
                  will be interpreted as an initial approximation of the
                  result. Using the command n times with n_iter=1
                  therefore has the same effect as using it once with
                  n_iter=n except that intermediate results can be inspected.
\\
              6.) The command can be used particularly profitably in order
                  to improve the appearance of images with sparsely sampled
                  PSF's where the smearing effects of conventional rebinning
                  unwanted. It may also help to bring out faint features
                  more strongly against the background. Depending on various
                  factors, a larger number of iterations does not necessarily
                  imply better results.
\\
              7.) The contents of each pixel is interpreted as flux density
                  (e.g. surface brightness), i.e. flux per unit area in world
                  coordinates. This means that the sum over all output pixels
                  equals the sum over all input pixels times zoom_x times
                  zoom_y.
\\
              8.) Edge effects are suppressed by extrapolating the frame
                  beyond its edges at a constant level and with the flux of
                  the last pixel observed.
\\
              9.) Large frames in combination with large zoom factors may
                  exceed the available virtual memory.
\on\exs
Examples:
\ex
              REBIN/DECO observed seeing true 3,5 2
              Expand image observed.bdf by factors 3 and 5 in X and Y,
              respectively. At the same time deconvolve with psf seeing.bdf
              using 2 iterations. The result will be stored in frame
              true.bdf which will be newly created if not already existing.
              Issuing the very same command again will execute iterations
              Nos. 3 and 4 on frame true. The net effect is the same as
              the one of REBIN/DECO observed seeing true 3,5 4
\xe\sxe
