12/09/2012

Canny Edge - OpenCV Sample Code(example source)

// Origin Image
IplImage *pImage = cvLoadImage(“-”);

// Gray Image
IplImage *pGray = cvCreateImage( cvGetSize(pImage), IPL_DEPTH_8U, 1 );

// RGB to Gray
cvCvtColor(pImage, pGray, CV_RGB2GRAY);

// Edge Image
IplImage *pEdge = cvCreateImage( cvGetSize(pImage), IPL_DEPTH_8U, 1 );

// Canny Function
//Th1 is maximum value to Start tracking edge point
//If pixel point value is bigger than Th1, Edge connecting is started.

//Th2 is minimum value to stop tracking edge point
//If pixel point value is smaller than Th2, Edge connecting is ended.

cvCanny( pGray, pEdge, th1, th2 );

th1 = 10, th2=100

th1=200, th2=100