This is a simple project that builds pencil sketch like images from photographs.
OpenCV stands for Open Source stands for Computer Vision, it is developed by Intel and Willow Garage, It is Officially launched in 1999 and later will Garage in 2000. OpenCV binds with Python to solve real-world problems. It supports languages like Python, Java, and MATLAB
The Opencv applications are as follows:
- Object detection
- Face Recognition
- Identify the objects
- Detecting Human activities
- Stitching the images to produce the highest resolution
- Recognize the scenery
- Recognizing images stored in the Database
- Remove Red Eye
- Follow the eye movement and many other real-time applications
pip install opencv-python
import cv2
img = cv2.imread("img_name.jpg")
imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
Makes brighter region into lighter and lighter into brighter in order to find edges of the image very easily
imgInvert = cv2.bitwise_not(imgGray)
Reduces noise of images and blurs to smoothen image with the specified Gaussian kernel
imgSmoothing = cv2.GaussianBlur(imgInvert, (21, 21), sigmaX=0, sigmaY=0 )
Remains the highlights of boldest edges
def divideByInversion(x, y):
return cv2.divide(x, 255 - y, scale = 256)
finalImage = divideByInversion(imgGray, imgSmoothing)
cv2.imwrite("finalimage.jpg", finalImage)
cv2.imshow("Sketch", finalImage)
cv2.waitKey()
cv2.destroyAllWindows()