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


1.6
date	95.01.13.00.59.47;	author rjj;	state Exp;
branches;
next	1.5;

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

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

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

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

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


desc
@Initial verions of the holefile algorithm.
@


1.6
log
@Deleted 'File:' from the header.
@
text
@// holefill.c     Section: 11.5, Hole Filling
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.


#include "holefill.h"
#include "UcharDI.h"
#include "Nbh.h"
#include "DDTempl.h"
#include "UcharConv.h"


IA_Image<IA_Point<int>,IA_Bit>
holefill( const IA_Image<IA_Point<int>,IA_Bit> & a ) {

    // Create s template.  First construct the associated image.

    IA_Set<IA_Point<int> >  s_ps;  // construct as union of two point sets
    s_ps =
	IA_boxy_pset( IA_Point<int>(0,0), IA_Point<int>(-1,1) )
	|  IA_Set<IA_Point<int> >( IA_Point<int>(0,-1) );

    IA_Image<IA_Point<int>,u_char>
	s_im( s_ps, 8 );  // Most common value

    // Correct the other image values
    s_im[ IA_Point<int>(-1,0) ] = 4;
    s_im[ IA_Point<int>( 0,0) ] = 3;
    s_im[ IA_Point<int>( 0,1) ] = 2;


    // s template created
    IA_DDTemplate<IA_Image<IA_Point<int>, u_char> >
	s( 2, s_im );

    // Create the n neighborhood.

    IA_Neighborhood<IA_Point<int>,IA_Point<int> >
	n( 2,
	   IA_boxy_pset( IA_Point<int>(-1,0), IA_Point<int>(1,0) )
	   |  IA_boxy_pset( IA_Point<int>(0,-1), IA_Point<int>(0,1) )
	   );


    IA_Image<IA_Point<int>,u_char>
	udi_a = a,                 // a as an UDI
	b = a,                     // b initialized with a\'s value
	c(a.domain(), u_char(0));  // c is zero valued image

    IA_Set<u_char> hfSet( 14, 22 );

    while (b != c) {
	c = b;
	b += IA_Image<IA_Point<int>,u_char>(
	    chi_contains( linear_product(b,s), hfSet ) );
    }

    c = 0;   // Zero  c  out again
    while ( b != c) {
	c = b;
	b = max( min(b,n), udi_a );
    }

    return to_bit( b );
}
@


1.5
log
@Added standard header.
Modified to replace characteristic template t usage with
   a neighborhood.  Made appropriate modifications to support this.
Deleted unnecessary variables and combined multi-step stmts into one.
@
text
@d1 1
a1 1
// File: holefill.c     Section: 11.5, Hole Filling
@


1.4
log
@Repackaged to be an external routine, rather than just an example.
@
text
@d1 1
a1 1
// File: holefill.c     Section: 11.5, Hole-fills
d8 1
a12 1

d36 1
a36 2
    // Create t template.  This one is somewhat simplier
    // Do this in one statement
d38 4
a41 6
    IA_DDTemplate<IA_Image<IA_Point<int>, u_char> >
	t( 2,
	   IA_Image<IA_Point<int>,u_char>(
	       IA_boxy_pset( IA_Point<int>(-1,0), IA_Point<int>(1,0) )
	       |  IA_boxy_pset( IA_Point<int>(0,-1), IA_Point<int>(0,1) ),
	       u_char(0) )  // Just 0 could be confused as null pointer
d46 3
a48 5
	udi_a( a ),                // a as an UDI
	b(a),                      // b initialized with a\'s value
	lpbs,                      // linear_product(b,s)
	c(a.domain(), u_char(0)),  // c is zero valued image
	chi_results;
d54 2
a55 3
        lpbs = linear_product(b,s);
	chi_results = chi_contains( lpbs, hfSet );
	b = b + chi_results;
d58 1
a58 1
    c = u_char( 0 );   // Zero  c  out again
d61 1
a61 1
	b = max( addmin_product(b,t), udi_a );
@


1.3
log
@Adopted use of the chi_contains() image function.
Corrected usage of  ||  instead of max(_,_).
@
text
@d6 2
d13 2
a14 1
int main() {
d16 1
a16 1
// Create s template.  First construct the associated image.
a46 1
    // Let\'s read the image in.
d49 1
a49 3
	a( IA_Image<IA_Point<int>,u_char>::read_PGM( cin ) );

    IA_Image<IA_Point<int>,u_char>
d53 1
a53 2
	chi_results,
	f(a.domain(), u_char(0));  // f is zero valued image
a54 2
    c = u_char(1);
    b = a;
a58 1

a60 1

d64 4
a67 4

    while ( b != f) {
	f = b;
	b = max( addmin_product(b,t), a );
d70 1
a70 3
    f.write_PGM(cout);

    exit( 0 );
@


1.2
log
@Modified file header and include stmts to be iac++ 2.0 compliant.
Added exit() to main() for picky systems.
@
text
@d53 1
a53 1
	d14, d22,
d58 2
d64 1
a64 2
	d14 = chi_eq(14, lpbs);
	d22 = chi_eq(22, lpbs);
d66 1
a66 1
	b = b + d14 + d22;
d72 1
a72 1
	b = addmin_product(b,t) || a;
@


1.1
log
@Initial revision
@
text
@d1 2
a2 2
// File: holefill.c
//      Copyright 1993, Center for Computer Vision and Visualization,
d7 1
a7 1
#include "UcharConvolutions.h"
a9 12
/////////////////////////////////////////////////////////////////////////////
//
// 7.5 Hole Filling
//
// Reference:  Image Algebra Handbook (IAH)
//
// Assumptions:
//    o  Image is read from standard in
//    o  Image format is PGM
//    o  The image is binary
//
/////////////////////////////////////////////////////////////////////////////
d11 1
a11 1
main() {
d75 2
@
