00001 #ifndef CANNYEDGE_H 00002 #define CANNYEDGE_H 00003 00004 #include "Util/Types.H" // for byte 00005 00006 #define BOOSTBLURFACTOR 90.0 00007 #define FREE_ARG char* 00008 #define PI 3.14 00009 00010 template <class T> class Image; 00011 00012 /******************************************************************************* 00013 * PROCEDURE: cannyEdge 00014 * PURPOSE: Simple wrapper for Mike's canny edge detection implementation 00015 * NAME: Rand Voorhies 00016 * DATE: 6/21/06 00017 *******************************************************************************/ 00018 int cannyEdge(Image<byte> &inputImage, float sigma, float tlow, float thigh, Image<byte> &outputImage); 00019 00020 /******************************************************************************* 00021 * PROCEDURE: canny 00022 * PURPOSE: To perform canny edge detection. 00023 * NAME: Mike Heath 00024 * DATE: 2/15/96 00025 //Pradeep: returns the centroid of the "white" pixels 00026 *******************************************************************************/ 00027 int canny(unsigned char *image, int rows, int cols, float sigma,float tlow, float thigh, unsigned char **edge, char *fname); 00028 00029 /******************************************************************************* 00030 * Procedure: radian_direction 00031 * Purpose: To compute a direction of the gradient image from component dx and 00032 * dy images. Because not all derriviatives are computed in the same way, this 00033 * code allows for dx or dy to have been calculated in different ways. 00034 * 00035 * FOR X: xdirtag = -1 for [-1 0 1] 00036 * xdirtag = 1 for [ 1 0 -1] 00037 * 00038 * FOR Y: ydirtag = -1 for [-1 0 1]' 00039 * ydirtag = 1 for [ 1 0 -1]' 00040 * 00041 * The resulting angle is in radians measured counterclockwise from the 00042 * xdirection. The angle points "up the gradient". 00043 *******************************************************************************/ 00044 void radian_direction(short int *delta_x, short int *delta_y, int rows, int cols, float **dir_radians, int xdirtag, int ydirtag); 00045 00046 /******************************************************************************* 00047 * FUNCTION: angle_radians 00048 * PURPOSE: This procedure computes the angle of a vector with components x and 00049 * y. It returns this angle in radians with the answer being in the range 00050 * 0 <= angle <2*PI. 00051 *******************************************************************************/ 00052 double angle_radians(double x, double y); 00053 00054 /******************************************************************************* 00055 * PROCEDURE: magnitude_x_y 00056 * PURPOSE: Compute the magnitude of the gradient. This is the square root of 00057 * the sum of the squared derivative values. 00058 * NAME: Mike Heath 00059 * DATE: 2/15/96 00060 *******************************************************************************/ 00061 void magnitude_x_y(short int *delta_x, short int *delta_y, int rows, int cols,short int **magnitude); 00062 00063 /******************************************************************************* 00064 * PROCEDURE: derrivative_x_y 00065 * PURPOSE: Compute the first derivative of the image in both the x any y 00066 * directions. The differential filters that are used are: 00067 * 00068 * -1 00069 * dx = -1 0 +1 and dy = 0 00070 * +1 00071 * 00072 * NAME: Mike Heath 00073 * DATE: 2/15/96 00074 *******************************************************************************/ 00075 void derrivative_x_y(short int *smoothedim, int rows, int cols,short int **delta_x, short int **delta_y); 00076 00077 /******************************************************************************* 00078 * PROCEDURE: gaussian_smooth 00079 * PURPOSE: Blur an image with a gaussian filter. 00080 * NAME: Mike Heath 00081 * DATE: 2/15/96 00082 *******************************************************************************/ 00083 void gaussian_smooth(unsigned char *image, int rows, int cols, float sigma, short int **smoothedim); 00084 00085 /******************************************************************************* 00086 * PROCEDURE: make_gaussian_kernel 00087 * PURPOSE: Create a one dimensional gaussian kernel. 00088 * NAME: Mike Heath 00089 * DATE: 2/15/96 00090 *******************************************************************************/ 00091 void make_gaussian_kernel(float sigma, float **kernel, int *windowsize); 00092 00093 #endif