head	1.3;
access;
symbols;
locks; strict;
comment	@// @;


1.3
date	94.10.11.00.27.28;	author rjj;	state Exp;
branches;
next	1.2;

1.2
date	94.09.02.01.47.45;	author rjj;	state Exp;
branches;
next	1.1;

1.1
date	94.09.01.00.11.08;	author rjj;	state Exp;
branches;
next	;


desc
@Placing under RCS.  This should be the source corresponding to UM 1.0
@


1.3
log
@Modified to use 'return 0;' rather than 'exit(0);'.
@
text
@// image_example.02.c      Image centroid calculation

#include "PSIter.h"
#include "IntDI.h"


int main()
{

    IA_Image<IA_Point<int>,int> a;  // Image should be binary

    a = read_int_PGM(cin);

    IA_Image<IA_Point<int>,int>
	bx(a.domain(),(int) 0 ),
	by(a.domain(), (int) 0 );

    IA_PSIter<IA_Point<int> >  psi(a.domain());


    IA_Point<int>  ip;

    // bx: image with each pixel\'s value as the point\'s 1st coordinate
    // by: image with each pixel\'s value as the point\'s 2nd coordinate
    while( psi(ip) ) {
	bx[ip] = ip[0];
	by[ip] = ip[1];
    }

    int  sa, cx1, cx2;

        sa = sum( IA_Image<IA_Point<int>,int>( chi_ne(a,(int)0) ) );

    cx1 = sum((bx*a));
    cx1 = cx1/sa;

    cx2 = sum((by*a));
    cx2 = cx2/sa;

    cout << "Image is bound by points: "
	 << a.domain().inf() << " and "
	 << a.domain().sup() << "\n"
	 << "Image centroid is at: "
	 << IA_Point<int>(cx1,cx2) << "\n";

    return 0;
}
@


1.2
log
@Modified to be iac++ v2.0 compliant.
@
text
@a2 1
#include <stdlib.h>
d46 1
a46 1
    exit( 0 );
@


1.1
log
@Initial revision
@
text
@a0 2
// Emacs: -*- C++ -*-

d3 1
d8 1
a8 3
typedef IA_PSIter<IA_Point<int> >  IA_IPSIter;

main()
a12 1
//    a = IA_Image<IA_Point<int>,int>::read_PGM(cin);
d19 1
a19 1
    IA_IPSIter  psi(a.domain());
d46 2
@
