Skip to content

Latest commit

 

History

History
173 lines (137 loc) · 8.75 KB

README.md

File metadata and controls

173 lines (137 loc) · 8.75 KB

Cartoonify

As you might know, sketching or creating a cartoon doesn’t always need to be done manually. Nowadays, many apps can turn your photos into cartoons. But what if I tell you, that you can create your own effect with few lines of code? Yes, Open CV as you know (or even if you don’t) is a very powerful tool with immense possibilities. It can be used to recognize objects, detect, and produce high-resolution images. In this project, we will show you how to give a cartoon-effect to an image in Python by utilizing OpenCV.


DOCS UI

Preview

Bilateral Filter

Filtering is perhaps the most fundamental operation of image processing and computer vision. Bilateral Filter helps in smoothing and reducing all the noise from our image and also preserve the edges at the same time unlike gaussian blur. The weight is based on the Euclidean distance of pixels and also on radiometric differences such as color intensity, range etc. This is our image:

Image after Bilateral Filter

Pencil Sketch Filter

Pencil Sketch converts our image into an image which appears to be sketched by pencil. So in order to apply Pencil sketch, we first use grayscale and gaussian Blur on our image and for the final sketched image, we divide the original grayscale image with the blurred grayscale image. Dividing the image gives us a ratio of change between each pixel of two images. The stronger the blurry effects, the more the value of each pixel changes with respect to its origin and hence, it gives us sharper pencil sketch. Below is a pictorial illustration. Here is the original picture:

Here is the picture after pencil sketch

Pencil Edge Filter

Pencil Edges filter creates a new image that contains only significant edges and white background. After grayscale and gaussian blur, we apply Laplacian filter to detect the edges. Here is the original picture:

Here is the picture after pencil edge

Detail Enhancement Filter

Enhancing image details without introducing artifacts has been attracting much attention in image processing community. Detail Enhancement filter gives a cartoon effect by sharpening the image, soothing the colours and enhancing the edges. First we convert the image into a grayscale image and then instead of using gaussian blur, median blur is applied. Adaptive threshold is then applied to detect the edges of the image. Finally, we use the result of adaptive threshold as a mask and then merge the result of detail enhancement based on the value of the mask to create a sharp effect with a well defined edge.

The result:

Image after Detail Enhancement Filter

Discord Bot

This Project has been deployed as a bot through Discord. The bot has be coded with Python and the bot runs on Repl.it server, Repl.it is an online code editor and has its own cloud storage for storing your Repositories which is really very helpful.

Command's for the Bot :

  • The commands for the bot precede with $ sign and commands can be tagged with the @username of the person in the server.
  • $ filter1 Returns the Pencil Sketch of the profile picture of the user.
  • $ filter2 Returns the B/W Detail Enhanced profile picture of the user.
  • $ filter1 @username Returns the Pencil Sketch of the profile picture of the tagged person.
  • $ filter2 @username Returns the B/W Detail Enhanced profile picture of the tagged person.

Preview


Instructions to Run

  • Pre-requisites:
    • Python to understand the working of Filters.
    • Discord Bot Commands.
  • Directions to Install:
    • Download the ZIP file of this repository to your local system.
    • Create a repository in repl.it
    • Insert the bot commands which are present in main.py file.
    • Setup the flask app to keep the bot awake.
  • Directions to Execute:
    • Run the Repository on repl.it and setup Up Time Robot, To keep the bot awake when you are away.
    • Add the bot to your discord server.
    • Now you can execute your commands.

Contributors

Anushka Garg

Ankita Kokkera

Ankita

Rakesh J

Rakesh

Rusali

Rusali

License

License

Made with ❤️ by DS Community SRM