Turn your photos into cartoon-style images 🎭 using simple image processing techniques — no deep learning required, no dataset needed!
We follow the algorithm described in:
Shruti Kumari Shrivastava, Ruchi Gajjar
Image Processing based Image to Cartoon Generation: Reducing complexity of large computation arising from Deep Learning
IEEE, 2023 International Conference on Computational Intelligence and Sustainable Engineering Solutions (CISES).
[DOI: 10.1109/CISES58720.2023.10183524]
- 🧹 Noise removal with Median filter
- ✂️ Edge detection & enhancement with Canny + Dilation
- 🎨 Color simplification with Quantization
- 🖼️ Outputs a cartoon-like image with bold edges and flat colors
- ⚡ Lightweight: runs with OpenCV + NumPy, no GPU or training needed
Implementation strictly follows the algorithm proposed in the referenced paper:
- Input: Original RGB image
- Noise Removal → Median Filter (removes salt & pepper noise)
- Edge Detection → Convert to grayscale + Canny Edge Detector
- Edge Enhancement → Morphological Dilation (thickens lines)
- Image Smoothing → Averaging Filter (reduces details for flat colors)
- Color Quantization →
NewValue = floor(p / (a-b)) * (a+b)
(with constants a and b controlling number of color bins)
7. Combine edges with quantized image → Final cartoon image
Below are the six outputs you’ll get when running the code:
| Original | Canny Edges | Thickened Edges |
|---|---|---|
![]() |
![]() |
![]() |
| Smoothed | Quantized | Final Cartoon |
|---|---|---|
![]() |
![]() |
![]() |
- Python 3.8+
- OpenCV
- NumPy
- Matplotlib
Install dependencies:
pip install opencv-python numpy matplotlib
### Run Script
```bash
python cartoonizer.pyEdit the image_path variable in cartoonizer.py with your image, e.g.:
image_path = "your_photo.jpg"The output will be saved as:
your_photo_cartoon.png
├── cartoonizer.py # Main Python script
├── README.md # Project documentation
├── images/ # Place before/after examples here
│ ├── original.jpg
│ ├── canny.jpg
│ ├── thickened.jpg
│ ├── smoothed.jpg
│ ├── quantized.jpg
│ └── cartoon.jpg
- Shruti Kumari Shrivastava, Ruchi Gajjar, Image Processing based Image to Cartoon Generation: Reducing complexity of large computation arising from Deep Learning, 2023 IEEE CISES. DOI: 10.1109/CISES58720.2023.10183524
A React.js based frontend with proper Anime-like Cartoon generation based on AnimeGAN and other pretrained models





