## NAME

         shrink - reduces the image size

## SYNOPSIS

          #include "CVIPtoolkit.h"
          #include "CVIPgeometry.h"

         Image *shrink( Image *input_Image, float factor );

          <input_Image> - pointer to an Image structure
          <factor> - scaling factor (0.1 - 1.0)

## PATH

         $CVIPHOME/GEOMETRY/shrink.c

## DESCRIPTION

         A pointer to the Image structure is passed to  the  function
         shrink   so  that  the original image can be accessed, along
         with the scaling factor which should be in the range 0.1  to
         1  (1 is the maximum scaling factor).  The function uses the
         first order scaling  algorithm  where,  depending  upon  the
         scaling factor the pixels from the original image are simple
         copied to the new image.  The scaling factor is tested first
         to  determine the size of the new resultant image as well as
         the pixels to be removed in  the  original  image.   If  the
         inverse of the scaling factor is an integer (example scaling
         factor = 0.25, ==> 1/0.25 = 4),  then  every  occurrence  of
         that  pixel  is  COPIED  to  the new image who image size is
         determined by the scaling factor (In the above  case,  every
         4nd pixel is copied to the new image).

         If the scaling factor is less than  0.5,  then  the  scaling
         factor  is  apparently modified so that the number of pixels
         COPIED to the new image is uniform thus  avoiding  quantiza-
         tion  in  the  resultant  image.  For example, for a scaling
         factor 0.4 (0.4 ==> 1/0.4 = 2.5), every  alternate  2nd  and
         3rd pixels are copied to the new image.

         If the scaling factor is greater than  0.5,  then  depending
         upon the scaling factor, those many pixels are SKIPPED while
         rest of the pixels are copied to the new image. For example,
         for a scaling factor 0.6, every alternate 2nd and 3rd pixels
         are skipped while the rest is written to the new image.  For
         a scaling factor of 0.8, every 5th pixel is skipped, for 0.9
         every 9th pixel is skipped and so on.

         After the scaling operation is performed, the pointer to the
         new resultant image of type Image is returned to the calling
         function so that the new image can be displayed.

## TYPES AND CONSTANTS

## RETURN VALUES

         Pointer to the shrinkd image

## HISTORY

         History information recorded: None

## EXAMPLE

          #include <CVIPtoolkit.h>
          #include <CVIPimage.h>
          #include <CVIPdef.h>
          #include <CVIPgeometry.h>
          #include <CVIPconvert.h>
          #include <CVIPview.h>
          #define VIEWER "picture"
          #define VIDEO_APP "SunVideo &"

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

          setDisplay_Image(VIEWER, "Default");

          print_CVIP("0Enter 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 shrinks the image size by a
          factor of .1 */
          cvipImage = shrink(cvipImage,.1);
          print_CVIP("0Enter 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

         libgeometry

## AUTHOR

         Copyright (C) 1996 SIUE - by Scott E. Umbaugh  and  Srinivas
         Madiraju.