栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

opencv python中的椭圆检测

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

opencv python中的椭圆检测

skimage的另一种选择是由

Xie, Yonghong, and Qiang Ji

“一种新的有效的椭圆检测方法。” 模式识别,2002年。会议记录。第16届国际会议。卷 2. IEEE,2002年。

他们的椭圆检测代码相对较慢,此示例大约需要70秒;相比网站声称“ 28秒”。

如果您有conda或pip:“名称”,请安装scikit-image并试一试…

他们的代码可以在这里找到,也可以在下面复制/粘贴:

import matplotlib.pyplot as pltfrom skimage import data, color, img_as_ubytefrom skimage.feature import cannyfrom skimage.transform import hough_ellipsefrom skimage.draw import ellipse_perimeter# Load picture, convert to grayscale and detect edgesimage_rgb = data.coffee()[0:220, 160:420]image_gray = color.rgb2gray(image_rgb)edges = canny(image_gray, sigma=2.0,   low_threshold=0.55, high_threshold=0.8)# Perform a Hough Transform# The accuracy corresponds to the bin size of a major axis.# The value is chosen in order to get a single high accumulator.# The threshold eliminates low accumulatorsresult = hough_ellipse(edges, accuracy=20, threshold=250, min_size=100, max_size=120)result.sort(order='accumulator')# Estimated parameters for the ellipsebest = list(result[-1])yc, xc, a, b = [int(round(x)) for x in best[1:5]]orientation = best[5]# Draw the ellipse on the original imagecy, cx = ellipse_perimeter(yc, xc, a, b, orientation)image_rgb[cy, cx] = (0, 0, 255)# Draw the edge (white) and the resulting ellipse (red)edges = color.gray2rgb(img_as_ubyte(edges))edges[cy, cx] = (250, 0, 0)fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True,          sharey=True,          subplot_kw={'adjustable':'box-forced'})ax1.set_title('Original picture')ax1.imshow(image_rgb)ax2.set_title('Edge (white) and result (red)')ax2.imshow(edges)plt.show()


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/669531.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号