Skip to content

Convert A Photo To Pencil Sketch Using Python In 12 Lines Of Code

Notifications You must be signed in to change notification settings

Kal-Sel/OpenCV---Image-to-pencil-sketch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

OpenCV-Image to pencil sketch

Convert A Photo To Pencil Sketch Using Python In 12 Lines Of Code

In order to obtain a pencil sketch (that is, a black-and-white drawing) of the camera frame, we will make use of two image blending techniques, known as dodging and burning. These terms refer to techniques employed during the printing process in traditional photography; photographers would manipulate the exposure time of a certain area of a darkroom print in order to lighten or darken it. Dodging lightens an image, whereas burning darkens it. OpenCV does not offer a native function to implement these techniques, but with a little insight and a few tricks, we will arrive at our own efficient implementation that can be used to produce a beautiful pencil sketch effect.

If you search on the Internet, you might stumble upon the following common procedure to achieve a pencil sketch from an RGB color image:

  1. Convert the color image to grayscale.

  2. Invert the grayscale image to get a negative.

  3. Apply a Gaussian blur to the negative from step 2.

  4. Blend the grayscale image from step 1 with the blurred negative from step 3 using a color dodge.

After using this procedure, we get an output like this:

alt text

About

Convert A Photo To Pencil Sketch Using Python In 12 Lines Of Code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published