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


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

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

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


desc
@This should probably be moved into the thresholding category.
@


1.3
log
@Added standard header.
Changed calculation of empty set so the function works,
  (in theory) with discrete IPS and FPS sets.
Added a few comments.
@
text
@// find-max-points.c    Section: 10.3, Line Detection using the Hough Transform
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.

#include "find-max-points.h"


// This routine may find a few more points than asked because
//    it extracts the max image value at each iteration, and
//    then adds all points associated with that value.
// Hence it is possible to get more than you ask for.

template <class P, class T>
IA_Set<P>
find_max_points( const IA_Image<P,T> & image,
		 unsigned int & how_many ) {

    int hMin = min( image );

    int max_to_be_found = image.domain().card();

    if ( max_to_be_found < how_many ) {
	how_many = max_to_be_found;
	// They want all the points in the image....ok
	return
	    image.domain();
    }

    int found = 0;
    IA_Set<P> result( image.domain() / image.domain() ); // empty set
    IA_Set<T> vs( image.range() );

    while( ( ! vs.empty() ) &&
	   ( found < how_many ) ) {
	T maxval = vs.max();
	vs       = vs / maxval;               // No  vs /= maxval;
	IA_Set<T> maxvs( maxval );

	// There are points to add to the result;
	IA_Set<IA_Point<int> >
	    maxips( image.restrict( maxvs ).domain() );

	result |= maxips;
	found += maxips.card();
    }

    how_many = found;   // set the reference param return value
    return result;
}
@


1.2
log
@Modified file header to reflect the iac++ standard.
@
text
@d1 1
a1 1
// find-max-points.c    Section: 10.3, Hough
d14 1
a14 1
IA_Set<IA_Point<int> >
d30 1
a31 1
    IA_Set<IA_Point<int> > result( IA_empty_ipset( 2 ) );
d36 2
a37 2
	vs = vs / maxval;               // No  vs /= maxval;
	IA_Set<int> maxvs( maxval );
d47 1
a47 1
    how_many = found;
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
// find-max-points.c
d4 2
@
