import cv2
import matplotlib.pyplot as plt
"""
### To read the image:
"""
image = cv2.imread('../input/horseimage/horse.jpeg')
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.axis('off')
plt.show()
"""
### Creating a new image by converting the original image to grayscale
"""
gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
plt.imshow(cv2.cvtColor(gray_img, cv2.COLOR_BGR2RGB))
plt.axis('off')
plt.show()
"""
### Inverting the new grayscale image
"""
inv_img = 255 - gray_img
plt.imshow(cv2.cvtColor(inv_img, cv2.COLOR_BGR2RGB))
plt.axis('off')
plt.show()
"""
### blurring the image by using the Gaussian Function in OpenCV
"""
blurred = cv2.GaussianBlur(inv_img, (21,21), 0)
"""
### The final step is to invert the blurred image, then we can easily convert the image into a pencil sketch
"""
inv_blur = 255 - blurred
pencil_sketch = cv2.divide(gray_img, inv_blur, scale=256.0)
plt.imshow(cv2.cvtColor(pencil_sketch, cv2.COLOR_BGR2RGB))
plt.axis('off')
plt.show()
"""
**Our pencil sketch is ready!
This can be replicated for any image**

"""
"""
***Thank You!***
"""