1.主要用于移除白色噪声

2.第一对是侵蚀和膨胀

(九)形态转变(九)形态转变

 import cv2
 import numpy as np
    
 cap=cv2.imread('apple1.jpg')
 hsv=cv2.cvtColor(cap,cv2.COLOR_BGR2HSV)
       
 lower_red = np.array([120,43,48])
 upper_red = np.array([180,255,255])
 mask = cv2.inRange(hsv,lower_red,upper_red)
                                                          
 res = cv2.bitwise_and(cap,cap,mask=mask)
 
 kernel = np.ones((5,5),np.uint8)
 erosion = cv2.erode(mask,kernel,iterations=1)
 dilation = cv2.dilate(mask,kernel,iterations=1)
 
 cv2.imshow('erosion',erosion)
 cv2.imshow('dilation',dilation)
 
 cv2.waitKey(0)
 cv2.destroyAllWindows()

3.第二对是openning&closing

(九)形态转变(九)形态转变

opening = cv2.morphologyEx(mask,cv2.MORPH_OPEN,kernel)
closing = cv2.morphologyEx(mask,cv2.MORPH_CLOSE,kernel)

 

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2021-10-31
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-01-17
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案