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


1.1
date	94.09.29.18.57.53;	author jnw;	state Exp;
branches;
next	;


desc
@Kirsch edge detection program
@


1.1
log
@Initial revision
@
text
@// kirsch.c            Section: 6.8
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.
// Kirsch Edge Operator

#include <iostream.h>

#include "kirsch.h"

#include "DDTempl.h"
#include "AuxImage.h"
#include "IntConv.h"
#include "FloatConv.h"


const int kirsch_size = 13;
int kirsch_array[kirsch_size] = {  5,  5,  5,
				   -3, -3, -3, -3, -3};

float fkirsch_array[kirsch_size] = { 5.0,  5.0,  5.0,
				     -3.0, -3.0, -3.0, -3.0, -3.0};

IA_Point<int> f[] = { IA_Point<int>(  0,  1),
		      IA_Point<int>( -1,  1),
		      IA_Point<int>( -1,  0),
		      IA_Point<int>( -1, -1),
		      IA_Point<int>(  0, -1),
		      IA_Point<int>(  1, -1),
		      IA_Point<int>(  1,  0),
		      IA_Point<int>(  1,  1),
		  };


IA_Image <IA_Point<int>, int>
kirsch( IA_Image <IA_Point<int>, int> image)
{
    
    IA_Image <IA_Point<int>, int>
	kimage( IA_boxy_pset( IA_Point<int>( -1, -1),
			      IA_Point<int>( 1, 1)),
		0);
    
    IA_Image <IA_Point<int>, int>
	temp(image.domain(), 1);
    
    
    for (int i = 0; i < 8; i++) {

	cerr << "I = " << i << endl;
	
	// create image for kirsch-template number i
	for (int j = 0; j < 8; j++) {
	    kimage[f[(j + i) % 8]] = kirsch_array[j];

	    cerr << " kimage [" << f[(j+i)%8] << "] = "
		 << kirsch_array[j] << endl;
	}
	
	IA_DDTemplate<IA_Image<IA_Point<int>, int> >
	    ktemplate(2, kimage);
	
	temp = max( temp, abs( linear_product( image, ktemplate)));
    }
    
    return temp;
}



IA_Image <IA_Point<int>, float>
kirsch( IA_Image <IA_Point<int>, float> image)
{
    
    IA_Image <IA_Point<int>, float>
	kimage( IA_boxy_pset( IA_Point<int>( -1, -1),
			      IA_Point<int>( 1, 1)),
		0.0);
    
    IA_Image <IA_Point<int>, float>
	temp(image.domain(), 1.0);
    
    
    for (int i = 0; i < 8; i++) {
	
	// create image for kirsch-template number i
	for (int j = 0; j < 8; j++) {
	    kimage[f[(j + i) % 8]] = fkirsch_array[j];
	}
	
	IA_DDTemplate<IA_Image<IA_Point<int>, float> >
	    ktemplate(2, kimage);
	
	temp = max( temp, fabs( linear_product( image, ktemplate)));
    }
    
    return temp;
}

@
