Adaptive setting for Canny Edge

I am using a project using OpenCV to detect a card that will be in a ready state. I successfully discovered this with Canny Edge. However, for another image, the parameter must be manually configured. I want my project to work with each image without manually setting the parameter. What should I do?

+4
source share
2 answers

If your image consists of Distinct Background and Foreground, you can get a threshold for this automatically, as described below in this article http://www.academypublisher.com/proc/isip09/papers/isip09p109.pdf .

  • Calculate Otsu Threshold + Binary Threshold for your image.
  • Use the Otsu threshold as a higher threshold for the Canny 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 link to this stream.

+6
source

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

You can link to the following link for the article and implementation in OpenCV C ++.

+2
source

Source: https://habr.com/ru/post/1547880/


All Articles