## NAME

         centroid - calculates centroid coordinates of an  object  of
         interest

## SYNOPSIS

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

         int * centroid(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

         The program  calculates  the  centroid  coordinates  of  the
         object  of  interest on the labeled image according to equa-
         tions given in chapter 2 of the soon-to-be-published book:

                    Computer Vision and Image Processing:
                     A practical Approach Using CVIPtools

                       S.E.Umbaugh, Prentice Hall, 1997

## TYPES AND CONSTANTS

         None

## RETURN VALUES

         A pointer to int; first value is the row coordinate,  second
         is column coordinate.

## HISTORY

         History information recorded: None

## EXAMPLE

          #include "CVIPtoolkit.h"
          #include "CVIPobject.h"
          #include "CVIPconvert.h"
          #include "CVIPfeatures.h"

          #include <math.h>
          #include "ObjectContour.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, format, TRUE);
             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 = centroid(labeledImage, r, c);
             print_CVIP("The centroid of the object  (r,  c)  =  (%d,
         %d)", *result, *(result+1) );
             print_CVIP("\n");

             free(inputfile);
           }

## DIAGNOSTICS

         The labeled image can only of data type CVIP_INTEGER

## SEE ALSO

         libfeature

## AUTHOR

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