编程语言
首页 > 编程语言> > opencv图像膨胀python代码

opencv图像膨胀python代码

作者:互联网

import numpy as np
import cv2
I=cv2.imread("/home/xiaomingming/profile/xmm.jpg",cv2.IMREAD_GRAYSCALE)
cv2.imshow("I",I)
r=1
MAX_R=20
cv2.namedWindow("dilate",1)
def nothing(*arg):
    pass
cv2.createTrackbar("r","dilate",r,MAX_R,nothing)
while True:
    r=cv2.getTrackbarPos('r','dilate')
    s=cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(2*r+1,2*r+1))
    d=cv2.dilate(I,s,iterations=30)
    cv2.imshow("dilate",d)
    ch=cv2.waitKey(5)
    if ch==27:
        break
cv2.destroyAllWindows()

标签:ch,dilate,python,imshow,cv2,opencv,图像,nothing,import
来源: https://blog.csdn.net/weixin_41463944/article/details/101166834