Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adaptive parameter for Canny Edge

I'm using a project using OpenCV for detecting a card that will be place on a atable. I have successfully detect it using Canny Edge. However, for different image the parameter must be tuned manually. I wish for my project to be worked with every image without manually tune the parameter. What Should I do?

like image 455
IllSc Avatar asked Jul 10 '14 09:07

IllSc


People also ask

What are the input parameters for Canny algorithm?

The effect of the Canny operator is determined by three parameters --- the width of the Gaussian kernel used in the smoothing phase, and the upper and lower thresholds used by the tracker.

How many parameter or placeholder does Canny edge method requires?

The Canny edge detector requires the user to input three parameters. The first is sigma, the standard deviation of the Gaussian filter specified in pixels. The second parameter low is the low threshold which is specified as a fraction of a computed high threshold.

What are the 3 basic objective of Canny edge detection?

Find the intensity gradients of the image. Apply non-maximum suppression to get rid of spurious response to edge detection. Apply double threshold to determine potential edges.


1 Answers

If your image consist of Distinct Background & Foreground, You can get the threshold for that automatically as follows explained in this paper http://www.academypublisher.com/proc/isip09/papers/isip09p109.pdf.

  1. Compute Otsu's threshold + Binary threshold for your image.
  2. Use the Otsu's threshold value as higher threshold for Canny's algorithm.

CODE:

Mat mCanny_Gray,mThres_Gray;
Mat mSrc_Gray=imread("Test.bmp",0);

double CannyAccThresh = threshold(mSrc_Gray,mThres_Gray,0,255,CV_THRESH_BINARY|CV_THRESH_OTSU);

double CannyThresh = 0.1 * CannyAccThresh;

Canny(mSrc_Gray,mCanny_Gray,CannyThresh,CannyAccThresh);
imshow("mCanny_Gray",mCanny_Gray);

You can also refer this thread.

like image 195
Balaji R Avatar answered Sep 30 '22 18:09

Balaji R