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


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

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


desc
@Initial attempt at the semi-threshold algorithm.
This program requires 2 arguments which define the interval
  the image should be semi-thresholded over.
@


1.2
log
@Added algorithm name to header, made spelling and sytle changes.
@
text
@// semi-threshold.c     Section: 3.3  Semithresholding
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.

// This application thresholds on an interval of values, and yields
//      a result over the same domain, but with all pixels whose
//      pixel value is not in the interval, set to zero.

#include "Set.h"
#include "UcharDI.h"

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

    if ( argc != 3 ) {
	cerr << "Usage:\t"
	     << argv[0] << " start end < inImage > outImage"
	     << endl;
	return -1;
    }


    IA_Image<IA_Point<int>,u_char> image( read_uchar_PGM( cin ) );
    u_char  mn = min( image ), mx = max( image );
    if ( ! image.domain().empty() ) {
	cerr << "cin image min: "  << int( mn )
	     << ", max: " << int( mx ) << endl;
    }

    u_char
	start = atoi( argv[1] ),
	end   = atoi( argv[2] );

    if (start > end) {
	u_char t = end;
	end = start;
	start = t;
    }
    u_char * interval = new u_char[end - start + 1];
    for( u_char u=start; u<=end; u++ ) {
	interval[ u-start ] = u;
    }
    IA_Set<u_char>
	threshold_set( interval,
		       (unsigned int)(end - start + 1) );
    delete[] interval;

    cerr << " Thresholding over interval [" << int( start ) 
	 << "," << int( end ) << "]" << endl;
    image *=
	IA_Image<IA_Point<int>,u_char>(
	    chi_contains( image, threshold_set ) );

    image.write_PGM( cout );

    return 0;
}
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
// semi-threshold.c     Section: 3.3
d12 1
a12 1
void main( int argc, char * argv[] ) {
d18 1
a18 1
	return ;
d23 1
a23 1
    u_char  mn( min( image ) ), mx( max( image ) );
d30 2
a31 2
	start( atoi( argv[1] ) ),
	end(   atoi( argv[2] ) );
d35 2
a36 1
	end = start; start = t;
d54 2
@
