Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Last active February 23, 2017 11:38
Show Gist options
  • Save cosmo0920/acc3f9d104a6eccf15ab94d324dc8259 to your computer and use it in GitHub Desktop.
Save cosmo0920/acc3f9d104a6eccf15ab94d324dc8259 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)
gray = cv2.cvtColor(dilate_diff_img, cv2.COLOR_RGB2GRAY)
cv2.imwrite(filename_base + '-linedraw-gray' + ext, 255 - gray)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment