function edgify ($image, $threshold
{
// from http://community.invisionpower.com/topic/150046-php-functions/
$height = imagesy$image);
$width = imagesx$image);
$new_image = imagecreatetruecolor$width, $height);
$white = imagecolorallocate$new_image, 255, 255, 255);
$black = imagecolorallocate$new_image, 0, 0, 0);
$image = convert2grayscale$image);
// add edges using sobel technique
for ($x=0; $x$width; $x++) {
for ($y=0; $y$height; $y++) {
$x2 = $x+1;
$y2 = $y+1;
if ($x2>=$width) $x2 = $x
if ($y2>=$height) $y2 = $y;
$p1 = imagecolorat$image$x$y2) & 0xFF;
$p2 = imagecolorat$image$x2$y2) & 0xFF;
$p3 = imagecolorat$image$x$y) & 0xFF;
$p4 = imagecolorat$image$x2$y) & 0xFF;
$h = abs$p1 - $p4);
$k = abs$p2 - $p3);
$g = $h + $k
if ($g > $threshold){
imagesetpixel$new_image, $x, $y, $black);
} else {
imagesetpixel$new_image, $x, $y, $white);
}
}
}
return $new_image
}