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


1.5
date	94.10.13.20.34.37;	author rjj;	state Exp;
branches;
next	1.4;

1.4
date	94.10.11.00.33.13;	author rjj;	state Exp;
branches;
next	1.3;

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

1.2
date	94.09.02.01.47.46;	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.5
log
@Corrected spelling and style.
@
text
@// neighborhood_example.01.c
// Averaging using neighborhoods and the neighborhood reduction
//   function sum().

// We will average the image at each point over a localized set
//   of 9 points, i.e. the point in question and it\'s eight
//   neighboring points.

// We will calculate the average by:
//    1) Creating a summation image, which will have a value equal
//       to the sum of values of the points in the neighborhood.
//    2) Divide the resultant image by the size of the neighborhood.

// Note: This approach has the failing that average calculated at the
//    boundary of the image maybe too small.  This is because this
//    method does not take into account that not every point has a
//    full neighborhood.


#include "IntDI.h"
#include "UcharDI.h"
#include "Nbh.h"


int main() {

    // Read in the image from the standard input stream: cin
    IA_Image<IA_Point<int>,int>
	in_image = read_int_PGM( cin );

    // Declare the intermediate and final result images
    IA_Image<IA_Point<int>,int>
	sum_image,
	avg_image;

    // Define the point set of the 9 points centered at <0,0>
    IA_Set<IA_Point<int> >
	nbhd_ps = IA_boxy_pset( IA_Point<int>(-1,-1),
				IA_Point<int>( 1, 1) );

    // Now create the neighborhood based on the point set just defined.
    IA_Neighborhood<IA_Point<int>,IA_Point<int> >
	nbhd( 2,          // The dimension of the pointset
	      nbhd_ps );  // This is similar to a template\'s image

    // Now we will create the summation image
    sum_image = sum( in_image,
		     nbhd,
		     in_image.domain()  // Resultant image domain
		     );


    // Finally calculate the image by simple division
    avg_image = sum_image/( nbhd_ps.card() );


    // Write the result to the standard output stream
    avg_image.write_PGM( cout );

    return 0;
}
@


1.4
log
@Modified to use 'return 0;' rather than 'exit(0);'.
@
text
@d6 2
a7 2
//   of 9 points, the point in question, and it\'s eight
//   neighborhooding point.
@


1.3
log
@Deleted debug stmts from this example file.
@
text
@a19 1
#include <stdlib.h>
d60 1
a60 1
    exit( 0 );
@


1.2
log
@Modified to be iac++ v2.0 compliant.
@
text
@d32 1
a32 1

a52 4
    cerr << "min(sum_image) = " << min(sum_image) << endl;
    cerr << "max(sum_image) = " << max(sum_image) << endl;

    display( to_uchar( sum_image ) );
a53 2
    sum_image.write_PGM( "/tmp/foo.pgm");

a55 4

    cerr << "nbhd_ps.card() = " << nbhd_ps.card() << endl;
    cerr << "min(avg_image) = " << min(avg_image) << endl;
    cerr << "max(avg_image) = " << max(avg_image) << endl;
@


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

d20 1
d23 1
a23 2
#include "Neighborhood.h"

d26 1
a27 2
main() {

d70 2
@
