Emgu学习笔记(四)---Canny、线检测、圆检测
来源:互联网 发布:ios开发书籍推荐知乎 编辑:程序博客网 时间:2024/05/18 01:23
Canny边缘检测:
用法和opencv中的一致,
Image<Gray,Byte> Image<Gray,Byte>.Canny(double thresh,double threshLinging)
thresh、threshLinging为第一滞后阈值和第二滞后阈值。
private void button1_Click(object sender, EventArgs e) { Image<Bgr, Byte> image1 = new Image<Bgr, Byte>(Properties.Resources._2); Image<Gray, Byte> grayImage = image1.Convert<Gray, Byte>(); Image<Gray, Byte> cannyGray = grayImage.Canny(100, 200); pictureBox1.Image = cannyGray.ToBitmap(); }
线检测:
1.先调用HoughLinesBinary检测直线,返回一个LineSegment2D[]的数组
LineSegment2D[][] Image<Gray,Byte>.HoughLinesBinary(doublerhoResolution,double thetaResolution,intthreshold,double minLineWidth,doublegapBetweenLines)
rhoResolution:累计像素的距离分辨率
thetaResolution:累计弧度的角度分辨率
minLineWidth:最小的线长度
gapBetweenLines:线段连接之间的距离
2.Draw,把线段画出来:
public void Draw(Cross2DF cross, TColor color, int thickness);
public void Draw(Ellipse ellipse, TColor color, int thickness = 1, LineType lineType = LineType.EightConnected, int shift = 0);
public void Draw(Point[] contours, TColor color, int thickness = 1, LineType lineType = LineType.EightConnected, Point offset = default(Point));
void Image<Bgr,Byte>.Draw(LineSegment2D line,Bgr color,int thicknes,[LineType lineType.EightConnected],[int shift=0])
//线检测 private void button2_Click(object sender, EventArgs e) { Image<Gray, Byte> cannyGray = new Image<Gray, Byte>(new Bitmap(pictureBox1.Image)); //调用HoughLinesBinary检测直线,返回一个LineSegment2D[]的数组 LineSegment2D[] lines = cannyGray.HoughLinesBinary(1, Math.PI / 45.0, 20, 30,10)[0]; //画线 Image<Bgr, Byte> imageLines = new Image<Bgr, Byte>(cannyGray.Width, cannyGray.Height); foreach(LineSegment2D line in lines) { //在imageLines上将直线画出 imageLines.Draw(line, new Bgr(Color.DeepSkyBlue), 2); } //显示结果 pictureBox2.Image = imageLines.ToBitmap(); }
圆检测:
CircleF[][] HoughCircles(TColor cannyThreshold, TColor accumulatorThreshold, double dp, double minDist, int minRadius = 0, int maxRadius = 0)
TColor cannyThreshold:传递到Canny边缘检测器的两个阈值中较高的阈值
TColor accumlator:中心检测阶段的累加器阈值。它越小,就越能检测到假圆。
double dp:检测圆中心的累计分别率
double minDist:检测圆中心之间的最小距离。
//圆检测 private void button3_Click(object sender, EventArgs e) { Image<Bgr, Byte> image1 = new Image<Bgr, Byte>(Properties.Resources._7); Image<Gray, Byte> gray1 = image1.Convert<Gray, Byte>(); //调用HoughCircles (Canny included)检测圆形 CircleF[] circles = gray1.HoughCircles(new Gray(180), new Gray(120), 2.0, gray1.Width / 8, 0, 0)[0]; //画图 Image<Bgr, Byte> imageCircles = image1.CopyBlank(); foreach(CircleF circle in circles) { imageCircles.Draw(circle, new Bgr(Color.Yellow), 5); } pictureBox3.Image = imageCircles.ToBitmap(); } }
效果图:
- Emgu学习笔记(四)---Canny、线检测、圆检测
- Canny 边缘检测 (Emgu.CV)
- openCV学习笔记(2):Canny边缘检测算法应用
- OpenCV2学习笔记(七):使用Canny算子检测轮廓
- OpenCV(学习笔记5)-Canny边缘检测
- opencv学习笔记(二十三)Canny边缘检测cvCanny()
- OpenCV学习笔记(12)canny 边缘检测小程序
- OpenCV学习笔记03--Canny边缘检测
- 【opencv学习笔记】2、Canny边缘检测
- opencv学习笔记--Canny边缘检测
- OpenCV学习笔记14-Canny边缘检测
- Opencv学习笔记(四):运用Canny算子边缘检测及Opencv中拖动条事件处理
- Opencv2系列学习笔记9(使用Canny算子检测轮廓)
- Opencv2系列学习笔记9(使用Canny算子检测轮廓)
- OpenCV学习笔记(3)—— canny算子边缘检测
- 图像局部特征学习(笔记1之Canny边缘检测算子)
- OpenCV学习笔记(三):Canny边缘检测和滚动条制作
- OpenCV 3学习笔记(三) 对图像进行Canny边缘检测
- 第七届 山东省ACM The Binding of Isaac(搜索OR暴力。。)
- Spring Boot读取自定义properties文件
- 配置服务器 —— 安装Mysql
- jsp实验1.基本使用
- 代码范例-进制转换[数组]
- Emgu学习笔记(四)---Canny、线检测、圆检测
- 【BZOJ】1085 [SCOI2005]骑士精神 IDA*
- linux下修改主机名
- 技术积累20170415(1)
- 最优化学习笔记(二十)——全局搜索算法
- 浅谈iOS尺寸单位pt、ppi与px
- js运动-运动缓冲
- 第一天学闭包
- 5. Training versus testing