# Las operaciones de Erosion y Dilatar se realizn sobre el color blanco de la imagen binaria import numpy as np import cv2 cap = cv2.VideoCapture(0) kernel = np.ones((3,3),np.uint8) while(1): ret ,frame = cap.read() if ret == True: img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) ret,thresh5 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO_INV) th2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV,11,2) erosion = cv2.erode(th2,kernel,iterations = 1) dilation = cv2.dilate(th2,kernel,iterations = 1) opening = cv2.morphologyEx(th2, cv2.MORPH_OPEN, kernel) cv2.imshow('Adaptativo',th2) cv2.imshow('Erosion',erosion) cv2.imshow('Dilate',dilation) cv2.imshow('original',img) cv2.imshow('Opening',opening) k = cv2.waitKey(60) & 0xff if k == 27: break cv2.destroyAllWindows() cap.release()