美文网首页
opencv python版-lesson 13

opencv python版-lesson 13

作者: writ | 来源:发表于2019-10-15 21:05 被阅读0次

    模拟虚化

    import cv2
    import numpy as np
    import matplotlib.pyplot as mp
    
    img=cv2.imread('opencv.jpg',0)
    img =cv2.medianBlur(img,5)
    ret,th1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)
    th2=cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2)
    th3=cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2)
    titles=['Original Image','Global Thresholding','adative_mean','adativa_gaussian']
    images=[img,th1,th2,th3]
    
    for i in range(4):
        mp.subplot(2,2,i+1),mp.imshow(images[i],'gray')
        mp.title(titles[i])
        mp.xticks([]),mp.yticks([])
    
    mp.show()
    

    相关文章

      网友评论

          本文标题:opencv python版-lesson 13

          本文链接:https://www.haomeiwen.com/subject/meremctx.html