Canny Edge 的自适应参数 [英] Adaptive parameter for Canny Edge
问题描述
我正在使用一个使用 OpenCV 的项目来检测将放置在桌子上的卡片.我已经使用 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?
推荐答案
如果您的图像由 Distinct Background &前景,您可以按照本文中的说明自动获取阈值 http://www.academypublisher.com/proc/isip09/papers/isip09p109.pdf.
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.
- 为您的图像计算 Otsu 阈值 + 二进制阈值.
- 使用 Otsu 的阈值作为 Canny 算法的更高阈值.
代码:
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);
您也可以参考 这个话题.
这篇关于Canny Edge 的自适应参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!