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


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

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

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

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


desc
@First time Simple Image Statistic is under control.
@


1.4
log
@Added algorithm name to header.  Made spelling and style changes.
@
text
@// sis.c                Section: 3.8
// Threshold Selection Using a Simple Image Statistic
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.
// Image algebra C++ program to determine the threshold
//      level for an image based on SIS
//

#include "sis.h"
#include "DDTempl.h"
//#include "UcharConv.h"  // This needs to be specialized
#include "IntConv.h"
#include "FloatConv.h"  // This requires abs(FDI), provided herein

static
IA_Image<IA_Point<int>,float>
abs( const IA_Image<IA_Point<int>,float> & fdi ) { return fabs( fdi ); }

template <class P, class T>
T
sis_threshold( const IA_Image<P,T> & a ) {

    unsigned int a_dimen = a.domain().dim();
    if (a_dimen != 2) {
	ia_throw( IA::INVALID_OPERATION, __FILE__, __LINE__ );
	return T(0); // Guess this is as bad as any value.
    }

    // Construct the s & t images used for templates.

    IA_Image<P,T>
	s_img( IA_Set<IA_Point<int> >( IA_Point<int>(0,-1) ) |
	       IA_Set<IA_Point<int> >( IA_Point<int>(0, 1) ),
	       T( 1 ) ),
	t_img( IA_Set<IA_Point<int> >( IA_Point<int>(-1,0) ) |
	       IA_Set<IA_Point<int> >( IA_Point<int>( 1,0) ),
	       T( 1 ) );

    s_img[ IA_Point<int>( 0,1) ] = T( -1 );  // Assign correct value.
    t_img[ IA_Point<int>(-1,0) ] = T( -1 );  // Assign correct value.

    // Construct the s & t templates
    IA_DDTemplate<IA_Image<P,T> >
	s( a_dimen, s_img ),
	t( a_dimen, t_img );

    // Calculate the images we want
    IA_Image<P,T>
	e1 = abs( linear_product(a,s) ),
	e2 = abs( linear_product(a,t) ),
	e = max(e1,e2);

    return
	sum( e * abs(a) ) / sum( e );
}
@


1.3
log
@Added support for UDI and FDI images.
@
text
@d2 1
d17 1
a17 1
abs( const IA_Image<IA_Point<int>,float> & fdi ) {
a18 5
    return fabs( fdi );
}



d23 6
a42 1
    unsigned int a_dimen = a.domain().dim();
a47 1
    T tau;
d53 2
a54 4
    tau = sum( e * abs(a) )
	  / sum( e );

    return tau;
@


1.2
log
@Modified to be iac++ 2.0 compliant.
@
text
@d12 8
a19 1
//#include "FloatConv.h"  // This requires abs(FDI)
@


1.1
log
@Initial revision
@
text
@d10 3
a12 2
#include "IntConvolutions.h"
//#include "UcharConvolutions.h"
d23 6
a28 6
	s_img( IA_IntPointSet( IA_IntPoint(0,-1) ) |
	       IA_IntPointSet( IA_IntPoint(0, 1) ),
	       1 ),
	t_img( IA_IntPointSet( IA_IntPoint(-1,0) ) |
	       IA_IntPointSet( IA_IntPoint( 1,0) ),
	       1 );
d30 2
a31 2
    s_img[ IA_IntPoint( 0,1) ] = -1;  // Assign correct value.
    t_img[ IA_IntPoint(-1,0) ] = -1;  // Assign correct value.
a44 2
//	my_abs_a = compose(my_abs,a);
//	my_abs_a = abs(a);
a45 1
//    tau = sum(e*my_abs_a)/sum(e);
d47 1
a47 1
	/ sum( e );
@
