Day 19 : Sketching using OpenCV

Hello guys
previously we learned about the basics of OpenCV.

Today we will draw a sketch using OpenCV.

Let's start
To draw a sketch from an image we need to read that image first
for that

img_rgb = cv2.imread(img)
cv2.imshow("Original Image ", img_rgb)



















Now we have to convert image to gray
for that just use  cv2.COLOR_BGR2GRAY

img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
cv2.imshow("Grayscale Image", img_gray)



















Now we have to reverse or inverse our gray image
each pixel have highest value of 255
so

img_gray_inv = 255 - img_gray
cv2.imshow("Invert Grayscale", img_gray_inv)



















Now we have to blur this image
for that, we can use the gaussian blur method

img_blur = cv2.GaussianBlur(img_gray_inv, ksize=(x, y),
                            sigmaX=0, sigmaY=0)

you can change this x and y values


cv2.imshow("Blur inverted Grayscale", img_blur)



















Now this dodgeV2 function will mask our gray image with img_blur

def dodgeV2(image, mask):
  return cv2.divide(image, 255-mask, scale=256)

img_blend = dodgeV2(img_gray, img_blur)
cv2.imshow("pencil sketch", img_blend)





















More information just read Read.md file
https://github.com/Mitesh2499/sketching-with-python



❤❤Quarantine python group link ❤❤

8805271377 WhatsApp

Follow here ❤

@mr._mephisto_ Instagram 

There will be no restrictions just feel free to learn. 

Share and take one more step to share knowledge to others. 

Believe in yourself 🤟 you are awesome. 

Be safe, Be happy😁
Take care of yourself and your family 
Of course watch movies and series🤟😉 

And follow the guidelines of government


Comments

Popular posts from this blog

News website using Flask and news API : Part 1

Day 16 : Pandas Basics

Web Design Challenge