Code Monkey home page Code Monkey logo

cartoonify's Introduction

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 Saha

Rusali

License

License

Made with ❤️ by DS Community SRM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.