NAME

     dpc_compress - compresses an image using differential  pulse
     code modulation

SYNOPSIS

      #include "CVIPimage.h"
      #include "CVIPcompress.h"
      #include <sys/stat.h>

     int dpc_compress(Image *inputImage,  char  *filename,  float
     ratio,  int   bit_length,  int  clipping, int direction, int
     origin)

      <inputImage> - a pointer to an Image structure
      <filename> - pointer to char string containing filename
      <ratio> - the correlation factor
      <bit_length> - number of bits for compression (1 to 8)
      <clipping> - clip to maximum value (1), otherwise 0
      <direction> - scan image horizontally (0) or vertically (1)
      <origin> - use original (1) or reconstructed (0) values

     Image *dpc_decompress(char *filename)

      <filename> - compressed file

PATH

     $CVIPHOME/COMPRESSION/dpcm.c

DESCRIPTION

     DPCM is a compression technique  that  uses  the  predictive
     method of differential pulse code modulation. It is based on
     the observation that adjacent pixels are  highly  correlated
     within  real  images,  and it is wasteful to store repeated,
     large values to represent consecutive pixels.  Rather,  DPCM
     stores  an initial value, followed by the difference between
     the initial value and subsequent pixel values. For  example,
     a  line  of  10  white pixels (value = 255) would usually be
     represented in 80 bits(8 bits/pixel X  10  pixels),  whereas
     with  DPCM, only 17 bits are needed: the first pixel needs 8
     bits, but each of the other  pixels  only  requires  1  bit,
     since  the difference between the initial value and the oth-
     ers is zero (255 - 255 = 0).

TYPES AND CONSTANTS

     none

RETURN VALUES

     dpc_compress: 0 on success, -1 on failure

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

HISTORY

     History information recorded: None

BUGS

     None at this time

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 differential
      predictive coding on the input image with the correlation
      factor equal to .9 and the number of bits equal to 3 */
      dpc_compress(cvipImage,"file1",.9,3,1,0,1,1);
      /* the following call performs the differential predictive
      decoding of the input image */
      cvipImage=dpc_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

AUTHOR

     Copyright (C) 1996 SIUE - by Scott Umbaugh.