import cv2
import numpy as np
img = cv2.imread('input.png', 0)
# The first parameter is the original image, kernel is the matrix with
# which image is convolved and third parameter is the number
# of iterations and will determine how much you want to erode the image.
kernel = np.ones((5,5), np.uint8)
img_erosion = cv2.erode(img, kernel, iterations=1)
cv2.imshow('Input', img)
cv2.imshow('Erosion', img_erosion)
cv2.waitKey(0)