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


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

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

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

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


desc
@Initial version of the Otsu algorithm, with debug msgs intact.
@


1.4
log
@Added algorithm to standard header.  Comment and style changes.
@
text
@// test-otsu.c          Section: 3.7
// Threshold Selection by Maximizing Between Class Variance
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.
// Test program for the the Threshold Selection by Maximizing
//      Between Class Variance algorithm


#include "PSIter.h"
#include "histogram.h"
#include "otsu.h"


int main(int argc, char *argv[]) {

    // if a value was passed on the command line, use that as the
    // number of partitions, otherwise default to 2 partitions
    // => 1 Tau point.
    int argvalue = ( argc > 1 ? atoi(argv[1]) : 0);
    unsigned int partitionCount = (argvalue > 1 ? argvalue : 2);
    cerr << "Using partition count = " << partitionCount << endl;

    IA_Image<IA_Point<int>,u_char>
	a = read_uchar_PGM(cin);

    IA_Set<IA_Point<int> >
	tau_ps = otsu( partitionCount, a );

    cout << "The number of different partitions "
	 << "that have maximal value are: "
	 << tau_ps.card() << endl;


    // Each tauPt represents a partitioning of the image histogram
    //   that have maximum values in the OtsuImage image.
    IA_Point<int> tauPt = tau_ps.choice();
    cout << "For " << partitionCount << " partitions, threshold at:";
    for ( int tc=0; tc < tauPt.dim(); tc++ ) {
	cout << "  " << tauPt( tc );
    }
    cout << endl;

    return 0;
}
@


1.3
log
@Removed unnecessary include, added exit() to main() for picky systems.
@
text
@d2 1
d19 2
a20 2
    int argvalue( argc > 1 ? atoi(argv[1]) : 0);
    unsigned int partitionCount(argvalue > 1 ? argvalue : 2);
d24 1
a24 1
	a = IA_Image<IA_Point<int>,u_char>::read_PGM(cin);
d35 1
a35 1
    //   that are maximum values in the OtsuImage image.
d43 1
a43 1
    exit( 0 );
@


1.2
log
@First version of Otsu without debug stmts.  Seems to work, however the
  closure still had problems, it generates spurious iac++ instantiations.
@
text
@a10 1
#include "otsu-image.h"
d13 1
a13 1
void main(int argc, char *argv[]) {
d41 2
@


1.1
log
@Initial revision
@
text
@d17 1
a17 1
    // number of partitions, otherwise default to 2 partions
d29 3
a31 4
    IA_PSIter<IA_Point<int> >
	tauIter( tau_ps );
    int tau_card = tau_ps.card();
    cerr << "tau_ps.card() = " << tau_card << endl;
d33 1
a33 8
/*    if (tau_card == 0) {
	IA_Image<IA_Point<int>,float>
	    nh = normalized_histogram(a);
	OtsuImage
	    otsu_im(partitionCount-1, nh);
	otsu_im.print_this(cout);
    }
    */
d36 4
a39 3
    IA_Point<int> tauPt;
    while ( tauIter( tauPt ) ) {
	cout << tauPt << " ";
@
