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


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


desc
@sobel edge detection program
@


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

#include "sobel.h"

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


const int sobel_size = 9;
int sobel_array1[sobel_size] = { -1, -2, -1,  0,  0,  0,  1,  2,  1};
int sobel_array2[sobel_size] = { -1,  0,  1, -2,  0,  2, -1,  0,  1};

const IA_DDTemplate<IA_Image<IA_Point<int>, int> >
sobel1( 2,
	IA_Image<IA_Point<int>, int> (IA_boxy_pset( IA_Point<int>( -1, -1),
						    IA_Point<int>( 1, 1)),
				      sobel_array1,
				      sobel_size));

const IA_DDTemplate<IA_Image<IA_Point<int>, int> >
sobel2( 2,
	IA_Image<IA_Point<int>, int> (IA_boxy_pset( IA_Point<int>( -1, -1),
						    IA_Point<int>( 1, 1)),
				      sobel_array2,
				      sobel_size));


float fsobel_array1[sobel_size] = { -1.0, -2.0, -1.0,  0.0,  0.0,  0.0,  1.0,
				     2.0,  1.0};
float fsobel_array2[sobel_size] = { -1.0,  0.0,  1.0, -2.0,  0.0,  2.0, -1.0,
				     0.0,  1.0};

const IA_DDTemplate<IA_Image<IA_Point<int>, float> >
fsobel1( 2,
	 IA_Image<IA_Point<int>, float> (IA_boxy_pset( IA_Point<int>( -1, -1),
						       IA_Point<int>( 1, 1)),
					 fsobel_array1,
					 sobel_size));

const IA_DDTemplate<IA_Image<IA_Point<int>, float> >
fsobel2( 2,
	 IA_Image<IA_Point<int>, float> (IA_boxy_pset( IA_Point<int>( -1, -1),
						       IA_Point<int>( 1, 1)),
					 fsobel_array2,
					 sobel_size));




IA_Image <IA_Point<int>, float>
sobel( IA_Image <IA_Point<int>, int> image)
{
    IA_Image <IA_Point<int>, int>
	temp1 = linear_product( image, sobel1);

    IA_Image <IA_Point<int>, int>
	temp2 = linear_product( image, sobel2);
    
    return isqrt( temp1*temp1 + temp2*temp2);
}


IA_Image <IA_Point<int>, float>
sobel( IA_Image <IA_Point<int>, float> image)
{
    IA_Image <IA_Point<int>, float>
	temp1 = linear_product( image, fsobel1);
    IA_Image <IA_Point<int>, float>
	temp2 = linear_product( image, fsobel2);
    
    return sqrt (temp1*temp1 + temp2*temp2);
}


@
