예제 #1
0
파일: main.c 프로젝트: dobairoland/ZyEHW
static inline u8 edge_operator(u8 k0, u8 k1, u8 k2, u8 k3, u8 k4, u8 k5,
                u8 k6, u8 k7, u8 k8)
{
        /* Sobel edge detector */

        const long p = k2 + 2*k5 + k8 - k0 - 2*k3 - k6;
        const long q = k6 + 2*k7 + k8 - k0 - 2*k1 - k2;

        (void) k4;

        return 128 + 1.0/8*absolute_val(p) + 1.0/8*absolute_val(q);
}
// Function returns the square root of a number.
float square_root (float x)
{
	const float epsilon = .00001;
	float 		guess 	= 1.0;
	
	while ( absolute_val ( ( square (guess) ) / x - 1.0 ) >= epsilon )
		guess = ( x / guess + guess ) / 2.0;
	
	return guess;
}