https://github.com/pn-projects/toonify
A MATLAB app that allows users to upload an image, convert it to a cartoon style, and save the result.
https://github.com/pn-projects/toonify
Last synced: 5 months ago
JSON representation
A MATLAB app that allows users to upload an image, convert it to a cartoon style, and save the result.
- Host: GitHub
- URL: https://github.com/pn-projects/toonify
- Owner: PN-Projects
- License: gpl-3.0
- Created: 2024-10-20T16:55:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-24T12:41:23.000Z (over 1 year ago)
- Last Synced: 2025-01-06T20:53:30.136Z (over 1 year ago)
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐จ Image to Cartoon Converter (Basic Image Processing)
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]
---
## โจ Features
- ๐งน **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
---
## ๐งฉ Algorithm Pipeline
Implementation strictly follows the algorithm proposed in the referenced paper:
1. **Input**: Original RGB image
2. **Noise Removal** โ Median Filter (removes salt & pepper noise)
3. **Edge Detection** โ Convert to grayscale + Canny Edge Detector
4. **Edge Enhancement** โ Morphological Dilation (thickens lines)
5. **Image Smoothing** โ Averaging Filter (reduces details for flat colors)
6. **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
---
## ๐ธ Example Results
Below are the **six outputs** youโll get when running the code:
| Original | Canny Edges | Thickened Edges |
|----------|-------------|-----------------|
|  |  |  |
| Smoothed | Quantized | Final Cartoon |
|----------|-----------|---------------|
|  |  |  |
---
## โ๏ธ Installation & Usage
### Requirements
- Python 3.8+
- [OpenCV](https://pypi.org/project/opencv-python/)
- NumPy
- Matplotlib
Install dependencies:
```bash
pip install opencv-python numpy matplotlib
### Run Script
```bash
python cartoonizer.py
```
Edit the `image_path` variable in `cartoonizer.py` with your image, e.g.:
```python
image_path = "your_photo.jpg"
```
The output will be saved as:
```
your_photo_cartoon.png
```
---
## ๐ Project Structure
```
โโโ 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
```
## ๐ Reference
* 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](https://doi.org/10.1109/CISES58720.2023.10183524)
---
## Future Updagrades (coming soon)
A React.js based frontend with proper Anime-like Cartoon generation based on AnimeGAN and other pretrained models