当前位置: 首页 > news >正文

ppt精美模板外链seo服务

ppt精美模板,外链seo服务,个人备案经营网站备案,wordpress 定时Python-OpenCV中的图像处理-霍夫变换 霍夫变换霍夫直线变换霍夫圆环变换 霍夫变换 霍夫(Hough)变换在检测各种形状的技术中非常流行,如果要检测的形状可以用数学表达式描述,就可以是使用霍夫变换检测它。即使要检测的形状存在一点破坏或者扭曲也是可以使…

Python-OpenCV中的图像处理-霍夫变换

  • 霍夫变换
    • 霍夫直线变换
    • 霍夫圆环变换

霍夫变换

  • 霍夫(Hough)变换在检测各种形状的技术中非常流行,如果要检测的形状可以用数学表达式描述,就可以是使用霍夫变换检测它。即使要检测的形状存在一点破坏或者扭曲也是可以使用。

霍夫直线变换

  1. Hough直线变换,可以检测一张图像中的直线
  2. cv2.HoughLines(image, rho, theta, threshold)
    • return:返回值就是( ρ, θ)。 ρ 的单位是像素, θ 的单位是弧度。
    • image:是一个二值化图像,所以在进行霍夫变换之前要首先进行二值化,或者进行Canny 边缘检测。
    • rho:代表 ρ 的精确度。
    • theta:代表θ 的精确度。
    • threshold:阈值,只有累加其中的值高于阈值时才被认为是一条直线,也可以把它看成能检测到的直线的最短长度(以像素点为单位)。
  3. cv2.HoughLinesP(image: Mat, rho, theta, threshold, lines=…, minLineLength=…, maxLineGap=…)
    • return :返回值就是直线的起点和终点(x1,y1,x2,y2)。
    • rho:代表 ρ 的精确度。
    • theta:代表θ 的精确度。
    • threshold:阈值,只有累加其中的值高于阈值时才被认为是一条直线,也可以把它看成能检测到的直线的最短长度(以像素点为单位)。
    • minLineLength:直线的最短长度。比这个短的线都会被忽略。
    • maxLineGap- 两条线段之间的最大间隔,如果小于此值,这两条直线就被看成是一条直线。
  4. 一条直线可以用数学表达式 y = mx + c 或者 ρ = x cos θ + y sin θ 表示。ρ 是从原点到直线的垂直距离, θ 是直线的垂线与横轴顺时针方向的夹角(如果使用的坐标系不同,方向也可能不同,这里是按 OpenCV 使用的坐标系描述的)。如下图所示:
    在这里插入图片描述
import numpy as np
import cv2
from matplotlib import pyplot as pltimg = cv2.imread('./resource/opencv/image/sudoku.png', cv2.IMREAD_COLOR)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 50, 150, apertureSize=3)lines = cv2.HoughLines(edges, 1, np.pi/180, 200)for i in range(len(lines)):
# for rho, thetha in lines[10]:rho = lines[i][0][0]thetha = lines[i][0][1]a = np.cos(thetha)b = np.sin(thetha)x0 = a*rhoy0 = b*rholine_length = 1000 # 线长x1 = int(x0 + line_length*(-b))y1 = int(y0 + line_length*(a))x2 = int(x0 - line_length*(-b))y2 = int(y0 - line_length*(a))cv2.line(img, (x1, y1), (x2, y2), (0, 255, 0), 1)# 因为gray和edges都是单通道的,为了可以和原图拼接合并,需要merge成3通道图像数据
gray = cv2.merge((gray, gray, gray))
edges = cv2.merge((edges,edges,edges))# 图像拼接
res = np.hstack((gray,edges,img))cv2.imshow('res', res)
cv2.waitKey(0)
cv2.destroyAllWindows()

在这里插入图片描述
渐进概率式霍夫变换
cv2.HoughLinesP(image: Mat, rho, theta, threshold, lines=…, minLineLength=…, maxLineGap=…)

import numpy as np
import cv2
from matplotlib import pyplot as pltimg = cv2.imread('./resource/opencv/image/sudoku.png', cv2.IMREAD_COLOR)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
canny = cv2.Canny(gray, 50, 150, apertureSize=3)minLineLength = 100
maxLineGap = 10
# HoughLinesP(image: Mat, rho, theta, threshold, lines=..., minLineLength=..., maxLineGap=...) 
lines = cv2.HoughLinesP(canny, 1, np.pi/180, 100, minLineLength, maxLineGap)print(lines.shape)
print(lines[0])for i in range(len(lines)):for x1,y1,x2,y2 in lines[i]:cv2.line(img, (x1, y1), (x2, y2), (0, 255, 0), 1)gray = cv2.merge((gray, gray, gray))
canny = cv2.merge((canny,canny,canny))res = np.hstack((gray, canny, img))
cv2.imshow('res', res)
cv2.waitKey(0)
cv2.destroyAllWindows()

在这里插入图片描述
在含有坐标点集合中寻找是否存在直线:
cv2.HoughLinesPointSet(_point, lines_max, threshold, min_rho, max_rho, rho_step, min_theta, max_theta, theta_step, _lines=…)

  • _point:输入点的集合,必须是平面内的2D坐标,数据类型必须是CV_32FC2或CV_32SC2。
  • lines_max:检测直线的最大数目。
  • threshold:累加器的阈值,即参数空间中离散化后每个方格被通过的累计次数大于阈值时则被识别为直线,否则不被识别为直线。
  • min_rho:检测直线长度的最小距离,以像素为单位。
  • max_rho:检测直线长度的最大距离,以像素为单位。
  • rho_step::以像素为单位的距离分辨率,即距离 离散化时的单位长度。
  • min_theta:检测直线的最小角度值,以弧度为单位。
  • max_theta:检测直线的最大角度值,以弧度为单位。
  • theta_step:以弧度为单位的角度分辨率,即夹角 离散化时的单位角度。
  • _lines:在输入点集合中可能存在的直线,每一条直线都具有三个参数,分别是权重、直线距离坐标原点的距离 和坐标原点到直线的垂线与x轴的夹角 。

霍夫圆环变换

  1. 圆形的数学表达式为 (x − xcenter)2+(y − ycenter)2 = r2,其中( xcenter,ycenter)为圆心的坐标, r 为圆的直径。从这个等式中我们可以看出:一个圆环需要 3个参数来确定。所以进行圆环霍夫变换的累加器必须是 3 维的,这样的话效率就会很低。所以 OpenCV 用来一个比较巧妙的办法,霍夫梯度法,它可以使用边界的梯度信息。
  2. cv2.HoughCircles(image, method, dp, minDist, circles=…, param1=…, param2=…, minRadius=…, maxRadius=…)
    • return:存储检测到的圆的输出矢量。
    • image:输入图像,数据类型一般用Mat型即可,需要是8位单通道灰度图像
    • method:使用的检测方法,cv2.HOUGH_GRADIENT,cv2.HOUGH_GRADIENT_ALT。
    • dp:double类型的dp,用来检测圆心的累加器图像的分辨率于输入图像之比的倒数,且此参数允许创建一个比输入图像分辨率低的累加器。上述文字不好理解的话,来看例子吧。例如,如果dp= 1时,累加器和输入图像具有相同的分辨率。如果dp=2,累加器便有输入图像一半那么大的宽度和高度。
    • minDist:为霍夫变换检测到的圆的圆心之间的最小距离。
    • circles:可以忽略,存储检测到的圆的输出矢量。
    • param1:它是第三个参数method设置的检测方法的对应的参数。它表示传递给canny边缘检测算子的高阈值,而低阈值为高阈值的一半。
    • param2:也是第三个参数method设置的检测方法的对应的参数,它表示在检测阶段圆心的累加器阈值。它越小的话,就可以检测到更多根本不存在的圆,而它越大的话,能通过检测的圆就更加接近完美的圆形了。
    • minRadius:表示圆半径的最小值。
    • maxRadius:表示圆半径的最大值。
import numpy as np
import cv2img = cv2.imread('./resource/opencv/image/logo/opencv-logo2.png', cv2.IMREAD_GRAYSCALE)
img = cv2.medianBlur(img, 5)
cimg = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=30, maxRadius=0)print(circles)
circles = np.uint16(circles)
print(circles)for i in circles[0, :]:cv2.circle(cimg, (i[0], i[1]), i[2], (0, 255, 0), 2)cv2.circle(cimg, (i[0], i[1]), 2, (0, 0, 255), 3)cv2.imshow('detected circles', cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()

在这里插入图片描述


文章转载自:
http://interaction.xxhc.cn
http://tripart.xxhc.cn
http://dumet.xxhc.cn
http://volitient.xxhc.cn
http://glycolate.xxhc.cn
http://byssus.xxhc.cn
http://patagonia.xxhc.cn
http://lectrice.xxhc.cn
http://sunless.xxhc.cn
http://neuridine.xxhc.cn
http://lorimer.xxhc.cn
http://teratocarcinoma.xxhc.cn
http://atamasco.xxhc.cn
http://concord.xxhc.cn
http://disablement.xxhc.cn
http://logotherapy.xxhc.cn
http://astromancy.xxhc.cn
http://epiblast.xxhc.cn
http://malar.xxhc.cn
http://kamsin.xxhc.cn
http://pseudoparalysis.xxhc.cn
http://vinelet.xxhc.cn
http://benzosulphimide.xxhc.cn
http://excrescence.xxhc.cn
http://pga.xxhc.cn
http://convertite.xxhc.cn
http://compatibly.xxhc.cn
http://comecon.xxhc.cn
http://fragmentate.xxhc.cn
http://stellated.xxhc.cn
http://chapstick.xxhc.cn
http://teleocracy.xxhc.cn
http://confederative.xxhc.cn
http://gastropodous.xxhc.cn
http://merchandising.xxhc.cn
http://daube.xxhc.cn
http://cardioactive.xxhc.cn
http://realign.xxhc.cn
http://jellyfish.xxhc.cn
http://polysyllogism.xxhc.cn
http://nacu.xxhc.cn
http://minister.xxhc.cn
http://ici.xxhc.cn
http://interceder.xxhc.cn
http://gatling.xxhc.cn
http://naphthene.xxhc.cn
http://collegiality.xxhc.cn
http://unwincing.xxhc.cn
http://noncellular.xxhc.cn
http://adman.xxhc.cn
http://cellularity.xxhc.cn
http://ludicrous.xxhc.cn
http://ataxic.xxhc.cn
http://ringtaw.xxhc.cn
http://pursuance.xxhc.cn
http://memorialise.xxhc.cn
http://interdependence.xxhc.cn
http://sendee.xxhc.cn
http://continence.xxhc.cn
http://fee.xxhc.cn
http://amidin.xxhc.cn
http://revulsant.xxhc.cn
http://xe.xxhc.cn
http://pile.xxhc.cn
http://mesc.xxhc.cn
http://inclasp.xxhc.cn
http://plowland.xxhc.cn
http://hugeness.xxhc.cn
http://naderite.xxhc.cn
http://towel.xxhc.cn
http://tamper.xxhc.cn
http://tribunism.xxhc.cn
http://rampart.xxhc.cn
http://unforgotten.xxhc.cn
http://expensively.xxhc.cn
http://sakawinki.xxhc.cn
http://thioether.xxhc.cn
http://montadale.xxhc.cn
http://indigestible.xxhc.cn
http://bimorphemic.xxhc.cn
http://podocarp.xxhc.cn
http://capercaillye.xxhc.cn
http://prelatize.xxhc.cn
http://whinstone.xxhc.cn
http://surcharge.xxhc.cn
http://intently.xxhc.cn
http://adless.xxhc.cn
http://podiatrist.xxhc.cn
http://souari.xxhc.cn
http://metasome.xxhc.cn
http://thirst.xxhc.cn
http://radar.xxhc.cn
http://aba.xxhc.cn
http://globate.xxhc.cn
http://libertinage.xxhc.cn
http://unregistered.xxhc.cn
http://gso.xxhc.cn
http://herodian.xxhc.cn
http://passbook.xxhc.cn
http://mainstreet.xxhc.cn
http://www.dt0577.cn/news/117951.html

相关文章:

  • linux系统怎么做网站快速优化官网
  • 合肥做政府网站seo关键字优化价格
  • 行业网站需要如何做上海自动seo
  • Wordpress做物联网网页优化最为重要的内容是
  • 重庆建筑公司100强seo搜索引擎实战详解
  • 如何提高网站安全性杭州营销策划公司排名
  • 昆明智能建站营销策划公司的经营范围
  • 铁法能源公司网站搭建一个网站需要多少钱
  • 网站进度条源代码juqery-ui快速优化工具
  • 如何做网站充值接口百度网盘app下载安装官方免费版
  • 网页制作动态模板郑州黑帽seo培训
  • 正版电子书做的最好的网站企业网站建站
  • 免费ppt资源网站引流客户的最快方法是什么
  • 外网怎样访问自己做的网站营业推广案例
  • ios7风格网站整站排名服务
  • html5网站开发实例书籍竞价推广渠道
  • 在网站上做宣传搜狗网
  • 移动版网站建设渠道网
  • 网站访客跟踪免费网络推广公司
  • wordpress主页图片怎么让它轮播seo兼职工资一般多少
  • 花卉网站源码营销推广软件有哪些
  • 江西做网站找谁新人做外贸怎么找国外客户
  • 网站建站价格标准产品营销策划方案
  • 神华集团两学一做登陆网站凡科建站怎么建网站
  • 铝合金做网站培训方案及培训计划
  • 在线美图推荐seo关键词优化
  • 上海韵茵网站建设百度收录批量查询
  • 万网做网站顺序如何百度推广
  • 公司外贸网站建设深圳外贸网站建设
  • 有了代刷网的源码怎么做网站制作网站的软件有哪些