import cv2
import numpy as np
img = cv2.imread('./image/dog.png')
# 注意调整kernel以保留小图形
kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(19,19))
dst = cv2.morphologyEx(img,cv2.MORPH_TOPHAT, kernel, iterations=1)
cv2.imshow('img',np.hstack((img,dst)))
cv2.waitKey(0)
cv2.destroyAllWindows()