NAME 
        mgif - display a GIF image in monochrome 

SYNOPSIS 
        mgif [ -i ] [ -v ] [ -N ] file...  

DESCRIPTION 
        Mgif displays  color GIF images on a monochrome ST display.  GIF
        files  carry  the extensions .GIF and are compressed  using  LZW
        codes.  It uses Floyd-Steinberg dithering to simulate color.  In 
        addition,   this  new  version  implements  flicker  palettes to
        simulate grayscale  on  a  monochrome  screen.      All   things
        considered, it does a decent job.  

        Mgif  now  also  contains numerous image processing functions to
        enhance images.  Included are: 

        	Histogram equalization
        	Contrast stretching
        	Blurring
        	Brightening (or darkening)
        	Histogram plot
        	Enlarge/reduce
        	Inversion (negation with threshold)
        	Log scaling
        	Thresholding
        	Median filtering

        Mgif allows each image processing function to be cummulative  or
        each operation  can  be independent.  Mgif is interactive (not a
        GEM program) and prompts for  commands.    It  also  has  online
        help.  

OPTIONS 
        The following command line options are recognized: 

        -i      Inquire about  the  file  but do not display it.  Output
                contains information like image size, number of bits per 
                pixel, and whether or not the  image  is  interlaced  or
                sequential.  

        -v      Verbose output.  

        -N      Use the classic NTSC equation for computing luminescense 
                from RGB values, that is: 


                        lum = 0.299 R + 0.587 G + 0.114 B 

                Otherwise the  values  are unweighted.  This option only
                makes sense for files with color maps in which the entry 
                for each color uses different values for red, green, and 
                blue.  Note that the actual equation used is: 


                        lum = 0.30 R + 0.59 G + 0.11 B 

                which is close enough.  Also note that NTSC luminescense 
                is a global option and must be set on program entry.  

        file    One or more GIF files.  

INTERACTIVE COMMANDS 
        The following commands are available at the prompt: 

        ?       help 

                Clears  the  screen  and  prints  a  brief  summary   of
                commands.  

        q       quit (next image) 

                Quit does  not  exit  the program.  It just moves to the
                next image from the command line.  

        ESC     exit program 

                Cleans up and exits.  

        SPACE   draw image 

                The current image, either original or new, is drawn  (or
                redrawn).  

        hi      histogram 

                Plots the  histogram  of the original or new image.  The
                histogram is based on intensity only.  Older versions of 
                the program displayed RGB  histograms  as  well.    That
                option  was  dropped,  though  it  was sometimes useful.
                Note that if o is toggled for original image, you should 
                toggle o again to plot  a  histogram  of  a  transformed
                image, then toggle back to work on the original.  

        o       original/new image 

                This   toggles   two   sorts   of   behavior:   1)   all
                transformations take place on the original image and are 
                not cummulative, 2) all transformations  take  place  on
                the new (last) image and are cummulative.  

        n       noise 

                Adds noise not to the image but to the  flicker  process 
                itself.   Can  help  in  images  which  have  artificial
                banding as a result of the dithering process.   You  are
                asked   for  a  value,  which  if  0,  turns  off  noise
                addition.  Otherwise, it is a  percentage  (0  to  100).
                Each time o is toggled, noise is reset to 0 (i.e. off).  

        g       Laplace filter 

                This, like noise, is not applied to the image itself but 
                rather in  the flicker process.  It helps to define hard
                edges in images and implements  a  Laplace  filter.    A
                quantity, Beta,  is required.  Use integers (1, 2, etc.)
                for this value.  A value of 1  corresponds  to  Beta  of
                0.25, a  value of 2 corresponds to Beta of 0.50, etc.  A
                value of 0 turns off Laplace filtering.  Each time o  is
                toggled,  Beta  is  reset  to  0 (i.e. Laplace filtering
                off).  

        e       enlarge 

                Enlarges images by 2x (only).  

        s       shrink 

                Reduces images by 2x (only).  Makes them  half  size  in
                height and width.  

        he      histogram equalization 

                Histogram  equalization  attempts  to  smooth out images
                with skewed or narrow histograms.    A  histogram  is  a
                graph  showing  the  relative number of pixels with each
                possible intensity value.  The practical use is to  make
                images  more uniform in contrast by making the histogram
                more uniform and hence representing all  intensities  as
                equally as possible.  

        i       inverse (negation) 

                Invert an  image, i.e.  make low intensity pixels bright
                and visa versa.   Inversion  is  implemented  here  more
                generally.  A  threshold  is  needed.    If it is 0, the
                entire image is inverted.  If it  is  a  negative  value
                between  0  and  -255,  only pixels below that level are
                inverted.  If it is a positive value between 0 and  255,
                only pixels above that level are inverted.  

        l       log scaling 

                Application of  log  scaling helps some images.  It more
                often will sort of solarize images.  

        t       threshold (black & white) 

                This process makes all pixels above  a  given  threshold
                intensity white  and  all below the threshold black.  It
                is useful in producing line art.  

        c       contrast expansion 

                Attempts to expand the contrast of an image to cover the 
                entire range of  256  allowable  grayscales.    Somewhat
                similar  to  histogram  equalization  but  it  does  not
                redistribute actual  pixels.    You  are  asked  for   a
                threshold which  is  a pixel count.  This determines the
                lowest and highest intensities, based on the  histogram,
                which are to be stretched.  

        br      brighten (or darken) 

                Here  a constant intensity is added (or subtracted) from
                every pixel.  A negative number causes  image  darkening
                and a  positive number causes image brightening.  Pixels
                which would otherwise go less than 0 or greater than 255 
                are limited to these values, respectively.  

        bl      blur 

                Blurring an image can also help contrast, though at  the
                expense of  loss  of detail.  Here a 3x3 neighborhood is
                used.  Often in practice a 5x5 neighborhood is used, but 
                that tends to take a relatively long time.  

        m       median filter 

                Median filtering can remove noise from an image.  Here a 
                3x3 neighborhood is used with the median value  of  each
                of the  9  pixels replacing the pixel of interest.  This
                is done in place so that the next pixel examined  within
                the  row  or  the  next  row  will  see  pixels  already
                filtered.  

        v       convolution filters  

                Apply one of a number of 3x3 convolutions to  an  image.
                Choose  one of the built-in filters (number greater than
                0) or enter 0 for user defined.  In the latter case, you 
                enter the 9 elements of  the  convolution  kernel  along
                with  a flag if there will be a multiplier (or divisor).
                Then enter that scaling factor.  All quantities  are  to
                be integers.  

FILES 
        *.gif     GIF image files

SEE ALSO 
        gif(5) 
        Gonzalez and Wintz, Digital Image Processing.  
        Lindley, Practical Image Processing In C.  
        Burger and Gillies, Interactive Computer Graphics.  

DIAGNOSTICS 
        Various warnings  attempting  to  isolate  corrupted files.  The
        usual messages about errors openning files, etc.   If  an  error
        occurs  during  a  processing  function,  the  prompt  line will
        indicate the error.  

NOTES 
        Source code has standalone versions (i.e.  single  entry  point)
        for both reading GIF files and displaying grayscale bitmaps with 
        flicker.  

BUGS 
        Handles  images  up  to 400,000 bytes (hardwired) or 640x600 (or
        any other combination  totaling  400,000).    It  needs  dynamic
        memory   but  I  generally  stay  away  from  GEMDOS  Malloc(2),
        prefering libc malloc(3) (i.e. off stack).  

        GIF decoding is slow and could be faster.    Some  of  the  area
        processes (blur, etc.) could also be faster.  

        Log  scaling needs logarithms but I did not want to use floating
        point so I get a crude (two significant digit) base 2 log.  

TODO 
        More than I wish to consider, but here is the short list: 

        	* Output file of some sort
        
        	* Zoom and pan
        
        	* Rotate, mirror, etc.

AUTHOR 
        Bill Rosenkranz (rosenkra@convex.com)
        Flicker adopted from code by Klaus Pedersen (micro@imada.dk)

VERSION 
        mgif 3.2 91/6/3 rosenkra 
