Webtoonize is a Python script that transforms ordinary images into webtoon-like illustrations using image processing techniques. The script applies a series of image transformations to create a webtoon-like aesthetic.
- Color quantization to simplify color palette
- Edge preservation through bilateral filtering
- Adaptive edge detection and enhancement
- Simplified color representation
- Easy-to-use image conversion
- OpenCV (cv2)
- NumPy
pip install opencv-python numpyfrom webtoonizer import webtoonize_image
# Basic usage
webtoonize_image('input.png', 'webtoon_output.png')
# Customizable parameters
webtoonize_image('input.png', 'webtoon_output.png', k=16, num_bilateral=4)image_path: Path to input imageoutput_path: Path to save webtoonized imagek: Number of colors for quantization (default: 16)num_bilateral: Number of bilateral filtering passes (default: 4)
The script transforms images through these key steps:
- Apply bilateral filtering to smooth image while preserving edges
- Reduce color palette using k-means clustering
- Convert to grayscale and apply median blur
- Detect and enhance edges with adaptive thresholding
- Combine quantized image with edge map
- Adjust
kto control color complexity - Modify
num_bilateralto change edge smoothness - Experiment with different input images for unique results


