Skip to content

deadshot8086/ascii-art-generator

Repository files navigation

ASCII Art Generator

  • convert image to ascii image
  • convert video to ascii video(MJPG codec)

Internal Working

Video is processed frame-by-frame, each frame is processed as an image using PIL, first it is resized to fit in time and quality, then each pixel is replaced with ascii character of same color, choice of ASCII character is based on Luminosity of pixel which is calculated by given formula. Finally video is written to output.avi in MJPG compression

Luminosity = 0.2126 * R + 0.7152 * G + 0.0722 * B

REQUIREMENTS

  • using pipenv
pipenv install

Demo Video

demo.mp4

Usage/Examples

Image to ASCII (TYPE-0)

python3 image_to_ascii.py car.png 0
Original ASCII

Image to ASCII (TYPE-1)

python3 image_to_ascii.py img.jpg 1
Original ASCII

Video to ASCII

python3 video_to_ascii.py video.mp4
Original ASCII

Learnings

  • Learned storage of image as matrix of pixels
  • Learned to use PIL, OpenCV for image processing
  • Learned to process video frame-by-frame as an image with PIL, OpenCV

Reference

Releases

No releases published

Packages

No packages published

Languages