Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Last active February 23, 2017 11:38
Show Gist options
  • Save cosmo0920/5e27eba96459051341f31766dc51a55f to your computer and use it in GitHub Desktop.
Save cosmo0920/5e27eba96459051341f31766dc51a55f to your computer and use it in GitHub Desktop.
import cv2, matplotlib
import numpy as np
import matplotlib.pyplot as plt
import os
filename='yuudachi.png'
filename_base, ext = os.path.splitext(filename)
img = cv2.imread(filename, 1)
kernel = np.ones((3,3),np.uint8)
dilate_img=cv2.dilate(img,kernel,iterations=1)
dilate_diff_img=cv2.absdiff(img, dilate_img)
cv2.imwrite(filename_base + '-linedraw' + ext, 255 - dilate_diff_img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment