FMEDIAN (August,1997)         ftools.fimage        FMEDIAN (August,1997)



NAME
    fmedian -- Convolve a FITS image  with  a  median  value  within  an
    user  defined rectangular box.
    
    
USAGE
    fmedian input output xwindow ywindow
    
    
PARAMETERS
    
    infile [string]
        Input  FITS  file  and extension number to be convolved with the
        median filter.
    
    outfile [string]
        Output FITS file where the convolved image will be written.
    
    xwindow [integer]
        The size of the smoothing window in pixels in the  x  direction.
        If  not  an  odd  number  it  will be incremented to nearest odd
        number.
    
    ywindow [integer]
        The size of the smoothing window in pixels in the  y  direction.
        If  not  an  odd  number  it  will be incremented to nearest odd
        number.
    
    (boundary = "nearest") [string]
        The algorithm used to compute the values of the  out  of  bounds
        pixels. The options are:
        
        nearest
            Use the value of the nearest boundary pixel.
        
        constant
            Use a constant value.
        
        reflect
            Generate a value by reflecting around the boundary.
        
        wrap
            Generate  a value by wrapping around to the opposite side of
            the image.
    
    (constant = 0.0) [double]
        The constant for constant-valued boundary extension.
    
    (datatype = "-") [character]
        The data type for the resulting smoothed image. A  "-"  or  "  "
        results  in  storing  the smoothed image with the same data type
        as the original input image. The letter B or b represents  byte,
        the  letter  I  or i represents short integer, the letter J or j
        represents  integer,  the  letter  E  or  e  represents   single 
        precision  reals  and  the  letter  D  or  d  represents  double 
        precision reals.
    
    (nullval = 0.0) [double]
        Value to substitute for any undefined pixels within the image.
    
    (copyprime = yes) [boolean]
        If true, all of the primary header keywords, the  primary  array
        (if  any)  and  all of the extension keywords of the first input
        file are copied to the output  file.   If  false,  only  minimal
        headers are created.
    
    (copyall = no) [boolean]
        If  true,  all other extensions, including the primary array are
        copied to the output file.
    
    (clobber = no) [boolean]
        If true, an existing output  file  of  the  same  name  will  be
        overwritten.
    
    
    
DESCRIPTION
    
    FMEDIAN  convolves  the  FITS  image  in  input  with a median value
    within a rectangular box specified by xwindow,  ywindow  and  places
    the  convolved  images in output FITS file. Out of bounds pixels are
    computed using the algorithm specified by boundary. The  FITS  image
    to  be  smoothed  can  be in either the primary array or in an image
    extension. The resulting smoothed image will  be  placed  in  either
    the  output  files  primary array or in an image extension depending
    on three things; the location of the image in the  input  file,  the
    value of the copyprime flag and the value of the copyall flag.
    
    If  the input image is in the primary array then the resulting image
    will always be placed in the primary array. In  this  case,  if  the
    copyprime  flag  is yes then all the keywords from the input primary
    header will be copied to the output primary header,  otherwise  only
    the  required  keywords will be placed in the output primary header.
    Setting the copyall flag will cause all the FITS extensions  in  the
    input FITS file to be copied over to the output FITS file.
    
    If  the input image is in an image extension the the resulting image
    will be placed in one of three places depending  on  the  values  of
    the  copyprime  and  copyall  flags. If the copyprime flag is no the
    the resulting smoothed image  will  always  appear  in  the  primary
    array.  If  the  copyall flag is also set then all extension will be
    copied to the output FITS file and the input primary array  will  be
    stored  in  the image extension that the image was originally stored
    in the input FITS file. If the  copyprime  flag  is  yes   then  the
    primary  array  of the input FITS file will always be copied over to
    the primary array of the output FITS file.  In  this  case,  if  the
    copyall  flag  is  no  then the smoothed image will be stored in the
    first extension of the output  FITS  file,  otherwise  the  smoothed
    image  will  appear  in  the  same  extension  in both the input and
    output FITS file and all other extensions  will  be  copied  to  the
    output FITS file.
    
    
    
EXAMPLES
    
    1.  Convolve  an  image  with  a  square  3  by  3 box using nearest
    neighbor boundary extension.
    
        cl> fmedian image.fits gimage.fits 3 3
    
    2. Convolve an image with a  rectangular  3  by  5  box  using  wrap
    around boundary extension.
    
        cl> fmedian img.fits gimg.fits 3 5 bound=wrap
    
    3.  Convolve an image in the 3rd extension with a rectangular 7 by 5
    box  using  nearest  neighbor  boundary  extension  and  store   the 
    resulting image in the primary array.
    
        cl> fmedian imgx.fits[3] gimg.fits 7 5 copyprime=no
    
    
    
BUGS
    
    
NOTE:  This tool works identically as that of another image smoothing tool
    fboxcar.   The  difference is in the smoothing procedure.  In latter
    case (fboxcar), it is the average value within the  rectangular  box
    and for fmedian, it is the median value within the rectangular box.
    
    
    
SEE ALSO
    fgauss, fboxcar