Binary Image Library
Data Structures | Macros | Functions
C:/Users/Malcolm/Documents/temp/binaryimagelibrary/canny.c File Reference
#include <stdlib.h>
#include <string.h>
#include <math.h>

Data Structures

struct  CANNY
 

Macros

#define ffabs(x)   ( (x) >= 0 ? (x) : -(x) )
 
#define GAUSSIAN_CUT_OFF   0.005f
 
#define MAGNITUDE_SCALE   100.0f
 
#define MAGNITUDE_LIMIT   1000.0f
 
#define MAGNITUDE_MAX   ((int) (MAGNITUDE_SCALE * MAGNITUDE_LIMIT))
 

Functions

unsigned char * canny (unsigned char *grey, int width, int height)
 
unsigned char * cannyparam (unsigned char *grey, int width, int height, float lowThreshold, float highthreshold, float gaussiankernelradius, int gaussiankernelwidth, int contrastnormalised)
 

Detailed Description

The code detects edges in greyscale images. The method was developed by John F Canny and is generally considered to be the best edge detection method currently available.

C version. Based on Java code by Tom Gibara

Function Documentation

unsigned char * canny ( unsigned char *  grey,
int  width,
int  height 
)

Canny edge detection with default parameters

Parameters
grey- the greyscale image
width- image width
height- image height
Returns
Binary image with edges as set pixels.
maggie.jpg
Margaret Thatcher (1925-2013) greyscale photograph
maggiecanny.gif
Mrs Thatcher edge detected
unsigned char * cannyparam ( unsigned char *  grey,
int  width,
int  height,
float  lowthreshold,
float  highthreshold,
float  gaussiankernelradius,
int  gaussiankernelwidth,
int  contrastnormalised 
)

Canny edge detection with parameters passed in by user.

Parameters
grey- the greyscale image
width- image width
height- image height
lowthreshold- default 2.5
highthreshold- default 7.5
gaussiankernelradius- radius of edge detection Gaussian, in standard deviations (default 2.0)
gaussiankernelwidth- width of Gaussian kernel, in pixels (default 16)
contrastnormalised- flag to normalise image before edge detection (defualt 0)
Returns
: Binary image with set pixels as edges.