Converting image into sketch using python
Here in this post, we presented a very easy python code to convert any image into sketch.
First of all you need to install OpenCv Library:
pip install opencv-python
Python Code:
image=cv2.imread("E:/Drive/msc/anshucln/Images/420.jpg")
gray_image=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
inverted=255-gray_image
blurred=cv2.GaussianBlur(inverted,(21,21),0)
invertedblur=255-blurred
pencilsketch=cv2.divide(gray_image,invertedblur,scale=256.0)
cv2.imwrite("E:/Drive/msc/anshucln/Images/42111.jpg",pencilsketch)
Comments
Post a comment