head	1.3;
access
	monica
	thoth;
symbols;
locks
	monica:1.3; strict;
comment	@// @;


1.3
date	94.08.24.00.30.59;	author monica;	state Exp;
branches;
next	1.2;

1.2
date	94.08.24.00.02.50;	author monica;	state Exp;
branches;
next	1.1;

1.1
date	94.08.23.20.18.35;	author monica;	state Exp;
branches;
next	;


desc
@@


1.3
log
@int main & exit(0)
@
text
@// Emacs: -*- C++ -*-
// $Log: test024.c,v $
//Revision 1.2  1994/08/24  00:02:50  monica
//added int main & return 0;
//
//Revision 1.1  1994/08/23  20:18:35  monica
//Initial revision
// $Id: test024.c,v 1.2 1994/08/24 00:02:50 monica Exp monica $
// image_example.02.c      Image centroid calculation

#include "PSIter.h"
#include "test.h"


typedef IA_PSIter<IA_Point<int> >  IA_IPSIter;

int main()
{

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

//    a = IA_Image<IA_Point<int>,int>::read_PGM(cin);
    a = read_int_PGM("/cis/research/iac++/depot/src/test_image/RCS/sr71.pgm");

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

    IA_IPSIter  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";
    exit(0);
}
@


1.2
log
@added int main & return 0;
@
text
@d3 3
d8 1
a8 1
// $Id: test024.c,v 1.1 1994/08/23 20:18:35 monica Exp monica $
d56 1
a56 1
    return 0;
@


1.1
log
@Initial revision
@
text
@d2 4
a5 1
// $Log$ $Id$
d14 1
a14 1
main()
d53 1
@
