Skip to content

Keerthi421/Image-to-Cartoon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cartoonify Image Project

This project transforms ordinary photos into cartoon-like images using Python, OpenCV, and scikit-learn. You can use it to create vibrant, artistic “cartoon” versions of any clear portrait or well-lit photo.

Features

Detects edges and highlights sketch-like outlines, just like in hand-drawn cartoons. Reduces colors for a bold “posterized” look with color quantization. Smooths and stylizes the result using bilateral filtering. All core processing is cleanly separated in modular functions for easy customization.

Requirements

You need: Python 3.x The following libraries: numpy opencv-python matplotlib scikit-learn

Install all dependencies by running:

text

pip install numpy opencv-python matplotlib scikit-learn

Usage

Add an input image Place your photo in the project folder (e.g., use photo.png or photo.jpg).

Run the code Open your Python script or notebook and use the main function:

text cartoonify_image('photo.png') You will see three panels: the original image, extracted cartoon edges, and the cartoonified result.

Customize parameters

You can change the following for different cartoon effects: k — Number of color clusters line_size — Thickness of edge outlines blur_value — Blurring for edge detection bf_d, bf_sigmaColor, bf_sigmaSpace — Bilateral filter smoothing

Example usage:

text cartoonify_image( 'photo.png', k=8, # Number of color clusters for boldness line_size=5, # Edge thickness blur_value=5, # Edge blur bf_d=9, # Bilateral filter diameter bf_sigmaColor=250,# Bilateral filter color sigma bf_sigmaSpace=250 # Bilateral filter spatial sigma )

Customization

Try different values of k to control how simplified the colors are. Adjust line_size and blur_value for different cartoon “outline” effects. Tune the bilateral filter for smoother or sharper results.

Troubleshooting If the image is not found, check the filename (including the file extension and capitalization).

If output isn't cartoonified or looks strange, experiment with parameters or use a higher-quality, well-lit image.

Ensure all packages are installed in the same Python environment you are running your script from.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published