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


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

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

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

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

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


desc
@First cut at the Hough line detection algorithm.
@


1.5
log
@Added standard header and return.
@
text
@// test-hough.c         Section: 10.3, Line Detection using the Hough Transform
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.
// Test the Hough line detection algorithm


#include "hough.h"


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

    // We accept up to two arguments:
    // 1st arg: ROWS,    default = 20
    // 2nd arg: COLS,    default = 20
    unsigned int ROWS, COLS, i_arg;

    i_arg = ( argc > 1 ? atoi(argv[1]) : 0 );
    ROWS  = ( i_arg > 0 ? i_arg : 20 );

    i_arg = ( argc > 2 ? atoi(argv[2]) : 0 );
    COLS  = ( i_arg > 0 ? i_arg : 20 );

    cerr << "Accumulator size: " << 2*ROWS+1 << " x " << COLS << endl;

    IA_Image<IA_Point<int>,IA_Bit>
	in_image( to_bit( read_uchar_PGM(cin) ) );

    cerr << "\nCalculating Hough image ...." << endl
	 << "inf() = " << in_image.domain().inf() << ", "
	 << "sup() = " << in_image.domain().sup() << endl;

    Hough( in_image, ROWS, COLS ).write_PGM( cout );

    cerr << "done." << endl;

    return 0;
}
@


1.4
log
@Added exit() for picky systems.  Got rid of Set.h include.
@
text
@d1 1
a1 1
// test-hough.c         Section: 10.3
d36 1
a36 1
    exit( 0 );
@


1.3
log
@Checking in this version before adding additional functionality that
  will calculate the 'reverse' hough, to see what lines were found.
@
text
@a7 1
#include "Set.h"
d10 1
a10 1
void main(int argc, char *argv[]) {
d35 2
@


1.2
log
@This version seems to work, but is not real fast.
  There are still some debug stmts left, but I'm putting
  the file under rcs before working with it further.
@
text
@d6 1
a6 1
#include <iostream.h>
a8 1
#include "BitDI.h"
d26 2
a27 5
    IA_Image<IA_Point<int>,u_char>
	in( read_uchar_PGM(cin) );

    IA_Image<IA_Point<int>,int>
	out;
a28 1
    u_char inMin;
d30 2
a31 12
	 << "inf() = " << in.domain().inf() << ", "
	 << "sup() = " << in.domain().sup() << ", "
	 << "min() = " << (int) (inMin = min( in )) << ", "
	 << "max() = " << (int) max( in ) << endl;

    IA_Image<IA_Point<int>,IA_Bit>
	h_image( chi_gt( in, inMin ) );

    IA_Image<IA_Point<int>,u_char>
	hu( h_image );
    hu.write_PGM( "Hough.pgm" );
    cerr << "#1's = " << sum( hu ) << endl;
d33 1
a33 2
    double R = 0;
    out = Hough( h_image, ROWS, COLS, R );
d35 1
a35 2
    out.write_PGM( cout );
    cerr << endl << "R value returned: " << R << endl;
@


1.1
log
@Initial revision
@
text
@d1 3
a3 1
// test-hough.c
a11 13
IA_Set<IA_Point<int> >
find_lines( const IA_Image<IA_Point<int>,int> & hough_image,
	    unsigned int lines_threshold ) {
    IA_Image<IA_Point<int>,IA_Bit>
	bdi = chi_ge( hough_image, (int) lines_threshold );

    IA_Set<IA_Bit> one( IA_Bit( 1 ) );

    return
	bdi.restrict( one ).domain();
}


d14 4
a17 7
    // We accept up to four arguments:
    // 1st arg: EPSILON, default = 0.05
    // 2nd arg: ROWS,    default = 20
    // 3rd arg: COLS,    default = 20
    // 4th arg: LINES_THRESHOLD,   default = hough image max()
    unsigned int ROWS, COLS, LINES_THRESHOLD, i_arg;
    double EPSILON, d_arg;
d19 2
a20 2
    d_arg   = ( argc > 1 ? atof(argv[1]) : 0.0 );
    EPSILON = ( d_arg > 0.0 ? d_arg : 0.05 );
d23 1
a23 1
    ROWS  = ( i_arg > 0 ? i_arg : 20 );
d25 1
a25 2
    i_arg = ( argc > 3 ? atoi(argv[3]) : 0 );
    COLS  = ( i_arg > 0 ? i_arg : 20 );
d27 2
a28 2
    i_arg = ( argc > 4 ? atoi(argv[4]) : 0 );
    LINES_THRESHOLD = ( i_arg > 0 ? i_arg : 0 );
d30 2
a31 7
    cerr << "\nEPSILON = " << EPSILON
	 << ", ROWS = "    << ROWS
	 << ", COLS = "    << COLS;
    if (LINES_THRESHOLD >0) {
	cerr << ", LINES_THRESHOLD = " << LINES_THRESHOLD;
    }
    cerr << endl;
d33 6
d41 1
a41 1
	in( to_bit( read_uchar_PGM(cin) ) );
d43 4
a46 2
    IA_Image<IA_Point<int>,int>
	out;
d48 2
a49 13
    cerr << "\nCalculating Hough image ....";
    out = Hough( in, ROWS, COLS, EPSILON );
    out.write_PGM( "hough.pgm" );
    cerr << "done. (wrote file: hough.pgm)" << endl;

    if (LINES_THRESHOLD == 0) {
	LINES_THRESHOLD = max( out );
	cerr << "LINES_THRESHOLD = " << LINES_THRESHOLD << endl;
    }
    cerr << "Finding lines...";
    IA_Set<IA_Point<int> >
	lines = find_lines( out, LINES_THRESHOLD );
    cerr << "done." << endl;
d51 2
a52 1
    lines.output( cout );
@
