NAME

     perimeter - calculates a binary object's perimeter

SYNOPSIS

      #include <math.h>
      #include "ObjectContour.h"

     int perimeter(Image * labeledImage, int r, int c)

      <labeledImage> -  pointer to a labeled image
      < r > - row coordinate of a point on the labled image
      < c > - column coordinate of a point on the labled image

PATH

     $CVIPHOME/FEATURE/binary_feature.c

DESCRIPTION

     We define the perimeter of an object to be the length of the
     outer edge of the object. This function first finds the max-
     imum and minimum values of the object of interest's row  and
     column. The length of the outer edge is then found by build-
     ing   chain   code   for   that   object   using    function
     build_ChainCode(). Chain code is a representation of a boun-
     dary as a connected sequence of  straight-line  segments  of
     specified  length  and  direction.  In build_ChainCode(), 8-
     connectivity of the segments is used, and the length of  the
     straight-line  segments  is the  distance between two neigh-
     boring pixels. By building chain code for  the  object,  the
     number  of  pixels  on the outer edge of the object is found
     and that is the perimeter of the object.

     The   function   build_ChainCode()   can   be    found    in
     $CVIPHOME/Object/ObjectContour.c.

TYPES AND CONSTANTS

     None

RETURN VALUES

     A value of type int: perimeter of the object

HISTORY

     History information recorded: None

EXAMPLE

      #include <math.h>
      #include "ObjectContour.h"
      #include "CVIPconvert.h"

      void main() {
         Image *inputImage, *labeledImage;
         IMAGE_FORMAT format;
         char *inputfile, *outputfile;
         int rows, cols, r, c;
         int result;

         setDisplay_Image("picture", "Default");

         print_CVIP("\nEnter the Input File Name:  ");
         inputfile = (char *) getString_CVIP();
         inputImage = read_Image(inputfile, 1);
         view_Image(inputImage,inputfile);

         labeledImage = label(inputImage);

         rows = getNoOfRows_Image(labeledImage);
         cols = getNoOfCols_Image(labeledImage);

         print_CVIP("\nEnter the row coordinate of any  pixel  on
     the labled image: ");
         r = getInt_CVIP(10, 0, rows);
         print_CVIP("\nEnter the col coordinate of any  pixel  on
     the labled image: ");
         c = getInt_CVIP(10, 0, cols);

         result = perimeter(labeledImage, r, c);
         print_CVIP("The perimeter of the object (r,  c)  =  %d",
     result );
         print_CVIP("\n");

         free(inputfile);
       }

DIAGNOSTICS

     The labeled image can only of data type CVIP_INTEGER

AUTHOR

     Copyright (C) 1996 SIUE - by Scott E.  Umbaugh  and  Wenxing
     Li.