Adaptive parameter for Canny Edge

前端 未结 2 830
猫巷女王i
猫巷女王i 2021-01-05 15:51

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 param

相关标签:
2条回答
  • 2021-01-05 16:24

    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++.

    0 讨论(0)
  • 2021-01-05 16:36

    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.

    0 讨论(0)
提交回复
热议问题