This is a Python script that converts an image into a cartoon-style image using OpenCV and NumPy. The script applies a bilateral filter to reduce the color palette, detects and emphasizes the edges using Canny edge detection, and then merges the edges with the filtered image to produce a cartoon-style image. The script also includes an optional argument to adjust the intensity of the edge lines.
- Python 3.x
- OpenCV
- NumPy
- Matplotlib (for displaying the image)
- Clone this repository or download the
cartoonize.py
file. - Install the required packages using pip:
pip install opencv-python numpy matplotlib
- Run the script with the following command:
python cartoonize.py path/to/input_image path/to/output_image [optional: edge_intensity]
Example: python Cartoon_Master.py
The edge_intensity
argument is optional and controls the intensity of the edge lines. The default value is 100.
This code is released under the MIT License. See the LICENSE
file for more information.
This script was inspired by the following resources:
- Cartooning an Image using OpenCV - Python by GeeksforGeeks
- How to Cartoonize an Image using OpenCV in Python by Analytics Vidhya