Coders Packet

Simple image cartoonifier using Python & OpenCV

By Mohammed Farhan Baluch

Using OpenCV & Python, any image can be converted to a good quality cartoony image in just 5 simple conversions.

You don't require expensive rendering tools or years of experience to produce the simple cartoon effect.

>> Follow these steps to use this Code packet without any errors.

(1) download the zip file. I've also put an example image you can use.

(2) install cv2 & NumPy library through pip, if not already installed

(3) In cv2.imread i.e. line 16 of the .py file, change the directory of the image to the image you want to cartoonify

(4) Done, run the code. 

Also, you can work around with the values of adaptivethreshold & bilateralfilter values to change the extent of application of this effect on your image.


>> We'll use the bilateral filter and bitwise operator to locate the image's edges and turn it into a cartoon in this transformation.

In the second conversion, we'll use an edge-preserving filter to blur the image while also applying a threshold to the edges.

Download Complete Code


No comments yet