Adaptive parameter for Canny Edge

北慕城南 提交于 2019-11-30 20:43:57
Balaji R

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.

You can use Helmholtz principle to adaptively find the lower and higher thresholds of the Canny edge detector.

You can refer the following link for the paper and the implementation in OpenCV C++.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!