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()
上一篇:《python+opencv3.3视频教学 基础入门》膨胀与腐蚀 笔记


下一篇:macOS SwiftUI 基础之如何设置App登录即可启动(教程含源码)