Skip to content

Latest commit

 

History

History
42 lines (23 loc) · 1.97 KB

File metadata and controls

42 lines (23 loc) · 1.97 KB

Image to pencil Sketch using Python CV2 library

(Note:- If you feel that this task has improved your abilities, don't forget to click the star icon in the upper right.)

Problem Statement:-

  • We need to read the image in RBG format and then convert it to a grayscale image. This will turn an image into a classic black and white photo. Then the next thing to do is invert the grayscale image also called negative image, this will be our inverted grayscale image. Inversion can be used to enhance details.
  • Then we can finally create the pencil sketch by mixing the grayscale image with the inverted blurry image.
  • This can be done by dividing the grayscale image by the inverted blurry image. Since images are just arrays, we can easily do this programmatically using the divide function from the cv2 library in Python.

Reading the image in RGB format and converting it to a grayscale image using CV2 library from python, matplotlib, style cvtcolor, bitwise_not, Gaussian_Blur and divide and converting the image.

image

  • Imported original Image

image

  • Grayscale image by using cvtcolor

image

  • Inverted image by using bitwise

image

  • Smoothen image by using Gaussian_Blur

image

  • Final output skechted Image

Steps:

  1. Convert the color image to grayscale.

  2. Invert the grayscale image to get a negative (invert image).

  3. Apply a GaussianBlur() to the negative from previous step.

  4. Finally, by using divide get the sketch image from the smoothen Image.