VOOZH about

URL: https://www.geeksforgeeks.org/blogs/cartooning-an-image-using-opencv-python/

⇱ Cartooning an Image using OpenCV - Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Cartooning an Image using OpenCV - Python

Last Updated : 28 Nov, 2025

Cartooning an image turns a normal photo into a fun, animated-style picture. With OpenCV, we do this by smoothing the image to simplify colors and detecting edges to create outlines. Combining these steps makes the photo look like a cartoon.

Prerequisites: Opencv module

Approach

  • Read the input image.
  • Convert the image to grayscale for edge detection.
  • Apply a median blur to remove noise.
  • Use adaptive thresholding to detect edges.
  • Apply a bilateral filter to smooth the image while preserving edges.
  • Combine the smoothed image with edges to produce the cartoon effect.

Python Implementation

Output:

👁 Input_image
Original Image
👁 cartoon_image
Cartoon Output Image

Explanation:

  • cv2.cvtColor() converts the image to grayscale for edge detection.
  • cv2.medianBlur() removes noise for cleaner edges.
  • cv2.adaptiveThreshold() detects edges, giving a sketch-like effect.
  • cv2.bilateralFilter() smooths colors while keeping edges sharp.
  • cv2.bitwise_and() combines smoothed colors and edges for the cartoon effect.
Comment
Article Tags: