Logo elodees  elodees

A caring AI for a better world













Only alphabetic characters accented or not as well as the space are accepted

Logo IA




Sketch an image





No account yet ?

Sign up to access all content


5











Convert image to Sketch Like Image Issue


CodePen



download

license : MITlicenseMIT  Copyright (c) 2016 dandavis


GitHub











Tested in Anaconda and Python 3.7

#Import libraries
import cv2
import matplotlib.pyplot as plt
import imageio
 
#Load Image
img = cv2.imread('pexels-elias-de-carvalho-1375849.jpg')
 
#Display Image
plt.imshow(cv2.cvtColor(img.astype('uint8'), cv2.COLOR_BGR2RGB))
plt.axis('off')
plt.show()
 
def dodgeV2(image, mask):
    return cv2.divide(image, 255-mask, scale=256)
 
def blend(front,back):
    result=front * 255 / (255 - back)  
    result[result > 255] = 255 
    result[back == 255] = 255 
    return result
 
def render(img_rgb):
    img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
 
    #Applying gaussian blur to grayscale image
    img_blur = cv2.GaussianBlur(img_gray, (21,21), 0, 0)
 
    #Invert the blur image
    inverted_img = 255 - img_blur
 
    #Apply the dodgeV2 function
    img_blend = dodgeV2(img_gray, inverted_img)
 
    #Blend the image
    img_final = 1-blend(img_blend, img_gray)
 
    return img_final
 
final_image = render(img)
 
#Display output

plt.imshow(final_image, 'gray')
plt.axis('off')
plt.show()
 
imageio.imwrite('Sketching-of-Image.jpg', final_image)
 


Photo-Sketching - GitHub



Free image provided by pexel.com
Free image provided by pexel.com


Free image provided by pexel.com
Free image provided by pexel.com












Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !

Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License