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


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

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

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

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

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


desc
@Initial version for the Hueckel algorithm suite.
@


1.5
log
@Added standard header.
Realized that e arrays do not need to be arrays, so removed these.
Added delete[] to catch a memory leak.
@
text
@// hueckel.c            Section: 6.15, Hueckel Edge Operator
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.
// Hueckel Edge Operator

#include "hueckel.h"
#include "DDTempl.h"
#include "FloatConv.h"
#include "hueckel-basis.h"



//==========================================================
// Hueckel algorithm
//==========================================================


IA_Image<IA_Point<int>,float>
hueckel2D( const IA_Image<IA_Point<int>,float> aImage,
           double radius,
           double theta[],        // Array of angles, in radians
           unsigned theta_m )     // count of number of angles
{
    // Declare working images we will need
    IA_Image<IA_Point<int>,float>
	a[8],  e0, e1, e2,  u,  *lambda;

    lambda = new IA_Image<IA_Point<int>,float>[theta_m];


    unsigned int i, j;

    // Since were are only doing the simple part of the Hueckel
    //   algorithm here, then we only need to calculate
    //   a[1..7], we do NOT need to calculate a[0]

    for( i=1; i<8; i++) {
	a[i] =
	    linear_product(
		aImage,
		IA_DDTemplate< IA_Image<IA_Point<int>,float> >(
		    2, HueckelImage2D( i, radius ) )
		);
    }


    double cosj, sinj;
    for( j=0; j<theta_m; j++) {
	cosj = cos(theta[j]);
	sinj = sin(theta[j]);

	e0 = a[2]*cosj + a[3]*sinj;
	e1 = a[4]*cosj + a[5]*sinj;
	e2 = a[1]
	    + a[6]*( cosj*cosj - sinj*sinj ) + 2*a[7]*sinj*cosj;

	// Use pseudo_div() in case divisor has zero values.
	u = pseudo_div( e0, fabs( e0 ) )
	    *sqrt( sqr( e1 ) + sqr( e2 ) );

	lambda[j] = e0 + u;
    }


    // Now for the final stuff
    IA_Image<IA_Point<int>,float>
	Lambda( fabs( lambda[0] ) ),
	k, e;

    for( j=1; j<theta_m; j++) {
	Lambda = max( Lambda, fabs( lambda[j] ) );
    }

    k = pseudo_div( Lambda,
		    sqrt( 6.0*sqr(a[1]) +
			  2.0*(sqr(a[2])+sqr(a[3])+sqr(a[4])+sqr(a[5])) +
			  3.0*(sqr(a[6])+sqr(a[7]))
			  )
		    );

    delete[] lambda;  // delete this memory after we are done with it.

    return k;
}



IA_Image<IA_Point<int>,u_char>
hueckel2D( const IA_Image<IA_Point<int>,float> aImage,
           double radius,
           double theta[],        // Array of angles, in radians
           unsigned theta_m,      // count of number of angles
           float threshold ) {

    IA_Image<IA_Point<int>,float>
	e = chi_gt( hueckel2D( aImage, radius, theta, theta_m ),
		    threshold );

    return to_uchar( e );
}
@


1.4
log
@Modified include stmts to be iac++ 2.0 compliant.
Modified code to use the fabs() version, rather than the
  compose() & sign() version.
@
text
@d1 1
a1 1
// hueckel.c            Section: 6.15
d26 1
a26 1
	a[8],  *e0, *e1, *e2,  *u,  *lambda;
a27 4
    e0     = new IA_Image<IA_Point<int>,float>[theta_m];
    e1     = new IA_Image<IA_Point<int>,float>[theta_m];
    e2     = new IA_Image<IA_Point<int>,float>[theta_m];
    u      = new IA_Image<IA_Point<int>,float>[theta_m];
d52 3
a54 3
	e0[j] = a[2]*cosj + a[3]*sinj;
	e1[j] = a[4]*cosj + a[5]*sinj;
	e2[j] = a[1]
d58 2
a59 2
	u[j] = pseudo_div( e0[j], fabs( e0[j] ) )
	    *sqrt( sqr( e1[j] ) + sqr( e2[j] ) );
d61 1
a61 1
	lambda[j] = e0[j] + u[j];
d80 3
@


1.3
log
@This version uses compostion with the sign() function rather
  than using the fabs() function.  It is seems to be slightly faster.
@
text
@a5 1
#include <math.h>
d8 1
a8 1
#include "FloatConvolutions.h"
a10 6
float
sign(const float & f) {
    if (f > 0) return  1;
    if (f < 0) return -1;
    return 0;
}
d62 1
a62 2
//	u[j] = pseudo_div( e0[j], fabs( e0[j] ) )
	u[j] = compose( sign, e0[j] )
@


1.2
log
@Corrected usage of chi_ge(,0) to pseudo_div(im,|im|).
@
text
@d12 6
d19 1
d69 2
a70 1
	u[j] = pseudo_div( e0[j], fabs( e0[j] ) )
@


1.1
log
@Initial revision
@
text
@d61 2
a62 1
	u[j] = IA_Image<IA_Point<int>,float>( chi_ge( e0[j], 0 ) )
@
