NAME

     spatial_quant - reduces the  image  size  by  one  of  three
     methods

SYNOPSIS

      #include <CVIPimage.h>
      #include <CVIPmatrix.h>
      #include "CVIPgeometry.h"

     Image * spatial_quant(Image *cvipImage, int  row,  int  col,
     int method)

      <cvipImage> - pointer to an Image structure
      <row> - number of rows for reduced image
      <column> - number of columns for reduced image
      <method> - reduction method to use where
                       1 = average
                       2 = median
                       3 = decimation

PATH

      $CVIPHOME/GEOMETRY/spatial_quant.c

DESCRIPTION

     spatial_quant allows the user to specify the number of  rows
     and  columns  in  the  resultant image, corresponding to the
     height and width of the new image.  The  integers  specified
     for  row  and column sizes must be equal to or less than the
     input image sizes or an error results.

     Three methods are available for image reduction:
     1) AVERAGE - each pixel in the new image represents an aver-
     age of the original image pixels it replaces
     2) MEDIAN - each pixel  in  the  new  image  represents  the
     median value of the original image pixels it replaces
     3) DECIMATION - each pixel in the new  image  has  the  same
     value  as a corresponding pixel in the original image; other
     original-image pixels are discarded

     Because the user may enter different values for  height  and
     width,  spatial_quant  may  be used to geometrically distort
     the image in a rubber-sheet fashion.

TYPES AND CONSTANTS

     none

RETURN VALUES

     Returns a reduced image upon successful completion;  returns
     NULL upon error in size specification.

EXAMPLE

       #include <CVIPtoolkit.h>
       #include <CVIPconvert.h>
       #include <CVIPimage.h>
       #include <CVIPmatrix.h>
       #include "CVIPquant.h"

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

      setDisplay_Image("picture", "Default");

      system("ln -s /opt/cvipimages/Gray/lena.pgm lena.pgm");
      print_CVIP("\nqThis  demonstration  uses   the   decimation
     method of spatial quantization.\n\n");
      print_CVIP("Please enter the image 'lena.pgm' at  the  fol-
     lowing prompt:\n\n");
      print_CVIP("Enter the Input File Name:  ");
      inputfile =(char *) getString_CVIP();
      format = getFormat_CVIP(inputfile);
      cvipImage = read_Image(inputfile, 1);
      display_Image(inputfile,format);
      cvipImage = (Image *)spatial_quant(cvipImage, 200,480,3);
      print_CVIP("Enter the Output File Name:  ");
      outputfile = getString_CVIP();
      write_Image(cvipImage,   outputfile,CVIP_NO,CVIP_NO,format,
     1);
      display_Image(outputfile,format);
      free(inputfile);
      free(outputfile);
      }

BUGS

     None at this time

SEE ALSO

     none

AUTHOR

     Copyright (C) 1995 SIUE - by Scott Umbaugh and Kun Luo.