NAME

     glr_compress - Performs grey level runlength coding

SYNOPSIS

      #include "CVIPtoolkit.h"
      #include "CVIPconvert.h"
      #include "CVIPdef.h"
      #include "grey_RLC.h"
      #include <sys/types.h>
      #include <sys/stat.h>

     int glr_compress(Image *inputImage, char *filename, int win)
      <inputImage> - a pointer to an Image structure
      <filename> - pointer to char string containing filename
      <win> - size of window (1-128)

     Image *glr_decompress(char filename)

      <filename> - name of the compressed file

PATH

     $CVIPHOME/COMPRESSION/grey_RLC.c

DESCRIPTION

     glr_compress takes three parameters,   the  pointer  to  the
     input  image  array of type byte, the file name to which the
     compressed image is to be stored, and the window length. The
     valid window length is (1-128). The user is suggested to use
     window length from 1-75 as this range gives better  results.
     The higher the window range the higher the compression ratio
     and vice versa. At the end of the compression, this  routine
     automatically  writes  to  the  working window the following
     data: the size of the original image, size of the compressed
     file, compression ratio.

     Algorithmic details can be found in "A Dynamic  Window-Based
     Runlength Coding Algorithm Applied to Gray-Level Images", M.
     Kumaran, S.E Umbaugh, GRAPHICAL MODELS AND IMAGE PROCESSING,
     Vol. 57, No. 4, July 1995, pp. 267-282.

     glr_decompress takes pointer  to  the  character  array  and
     returns pointer to the image. The character array represents
     the filename to be decoded. It  returns  a  pointer  to  the
     decoded image structure.

TYPES AND CONSTANTS

     None

RETURN VALUES

     glr_compress: 0 on success, -1 on failure

     glr_decompress: an uncompressed image pointer on success,  a
     NULL pointer on failure

HISTORY

     History information recorded: None

EXAMPLE

      #include <CVIPtoolkit.h>
      #include <CVIPimage.h>
      #include <CVIPdef.h>
      #include <CVIPconvert.h>
      #include <CVIPview.h>
      #include <sys/types.h>
      #include <sys/stat.h>
      #define VIEWER "picture"
      #define VIDEO_APP "SunVideo &"

      void main()
      {
      Image *cvipImage;
      IMAGE_FORMAT format;
      char *inputfile,*outputfile;

      setDisplay_Image(VIEWER, "Default");
      print_CVIP("\n\t\tEnter the  Input File Name:  ");
      inputfile =(char *) getString_CVIP();
      format = getFormat_CVIP(inputfile);
      cvipImage = read_Image(inputfile,1);
      view_Image(cvipImage, inputfile);
      free(inputfile);
      /* the following call performs the gray level run length
      coding with the window size equal to 32 */
      glr_compress(cvipImage,"file1",32);
      /* the following call performs the gray level run length
      decoding of the "file1" */
      cvipImage=glr_decompress("file1");
      print_CVIP("\n\t\tEnter the Output File Name:  ");
      outputfile = getString_CVIP();
      view_Image(cvipImage,outputfile);
      write_Image(cvipImage,outputfile,CVIP_NO,CVIP_NO,format,1);
      free(outputfile);
      }

SEE ALSO

     libcompress

DIAGNOSTICS

     The Grey level Runlength coding and decoding  algorithm  was
     designed to work only on monochrome images.

AUTHOR

     Muthu Kumar, SIUE

     Copyright (C) 1995 SIUE - by Scott Umbaugh and Muthu Kumar.