Skip to content

ASCIIFY can be used to convert images and videos to ASCII Art. I have made this project as a part of the IITR ACM- Open Summer Project, 2022.

Notifications You must be signed in to change notification settings

ansh25saini/ASCIIFY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASCIIFY : ASCII Art Generator

This project is made as a part of the IITR ACM- Open Summer Project, 2022. It can be used to convert images and videos to ASCII Art.

welcome_gif

📌 Table of Contents

📓 Description / Internal Working

This project aims at converting images ( .jpg / .png) and videos (.mp4 / .avi) to ASCII encoded strings that look same as the original input.

ASCII(American Standard Code for Information Interchange) is a common encoding format used for representing strings and text data in computers. Media files (images / videos) can also be represented in the same format using different characters.

To convert an image to ASCII art, opencv and python pillow library have been used in the project. The input image is stored as a matrix having values on the basis of color intensity of the corresponding pixels. The image matrix is converted to grayscale values and height and width of the input image is calculated. Using the dimensions of the image, number of characters in the width of the output image and scale factor, the number of characters in the height of the output image are calculated. Using this and dimensions of the font used, the dimensions of the output image are calculated and a new image is formed using pillow library. Finally the characters are mapped onto the image, and excessive borders are removed to get the final output. The mapping of the characters are done on the basis of the average intensity of the cell (pixel) and inserting the character from the character list having similar intensity.

To convert a video to ASCII art, each frame is processed as an individual image (as described in the process above) and all the frames are then appended to produce the final output.

🚀 Features

  • Convert an image to ASCII art in text format (.txt).
  • Convert an image to ASCII art in image format (.jpg / .png).
  • Image outputs can either be in grayscale or colour format. Seperate programs for both have been included in the project.
  • Convert a video to ASCII art in coloured format (.avi / .mp4).
  • Image and video outputs can either be in black background or white background (dependent on the user input).
  • All the outputs (text / images / videos) can either be made using standard set of characters or complex list of characters.
  • Add more features...

💻 Tech Stack / Dependencies

Python OpenCV NumPy Visual Studio Code Git

Python : The complete project is written in python programming language.

OpenCV : OpenCV has been used for image pre-processing.

Numpy : To work with matrices.

Pillow : Python library for creating font object, making new images and editing them.

Visual Studio Code : Editor used in the project

📦 Getting Started/ Setup

  1. Clone this repository.
  git clone https://github.com/ansh25saini/ASCIIFY.git
  1. Make and activate the virtual environment env
  python -m venv env
  env/Scripts/activate
  1. Instal requirements.txt
  pip install -r requirements.txt
  1. Finally to run the file (suppose coloured_image.py)- "python file_path"
  python ascii_images/coloured_image.py
  1. In order to see user input commands, use - "python file_path -h"
  python ascii_images/coloured_image.py -h
  1. In order to provide user input (like input/output file, mode of character list or type of background), use - "python file_path -mode complex"
  python ascii_images/coloured_image.py --mode complex --background black

🚀 Additional Task

Apart from converting images into ASCII format of text, grayscale or coloured images, this project also asciify videos into coloured format videos of .avi / .mp4 type.

A seperate ascii_videos/coloured_video.py file has been added into the project. To know about how videos are converted to ASCII art, refer to description section of this readme file.

The output videos will be in coloured video format with either black or white background depending on the user input. The user can also put the choice for the type of character list: standard or complex.

The following are the results for the given input video (the results are orginally in video format but here they are converted to gifs for the sake of simplicity; the orginal videos are present in data/ascii_videos/ directory of the project)

  • Input video used in the project; here (in readme file) it is in .gif format-

Input Video

  • Output Video- coloured_video_white_standard : white background with standard character list.

coloured_video_white_standard

  • Output Video- coloured_video_white_complex : white background with complex character list.

coloured_video_white_complex

  • Output Video- coloured_video_black_standard : black background with standard character list.

coloured_video_black_standard

  • Output Video- coloured_video_black_complex : black background with complex character list.

coloured_video_black_complex

📖 User Guide

1. Image to ASCII art in image format ( .jpg / .png)

Either standard or complex type of character list, black or white background, and grayscale or coloured format outputs can be made. All the outputs are shown below:

  • Input image used in the project (in .jpg format)-

Input

  • Output Image: image_white_standard (in .jpg format)

image_white_standard

  • Output Image: image_white_complex (in .jpg format)

image_white_complex

  • Output Image: image_black_standard (in .jpg format)

image_black_standard

  • Output Image: image_black_complex (in .jpg format)

image_black_complex

  • Output Image: coloured_image_white_standard (in .jpg format)

coloured_image_white_standard

  • Output Image: coloured_image_white_complex (in .jpg format)

coloured_image_white_complex

  • Output Image: coloured_image_black_standard (in .jpg format)

coloured_image_black_standard

  • Output Image: coloured_image_black_complex (in .jpg format)

coloured_image_black_complex

2. Image to ASCII art in text format (.txt)

Either standard or complex type of character list can be used. Output files are present in data/ascii_images folder of the project directory.

3. Video to ASCII art in coloured format (.avi / .mp4)

Refer to Additional Task section of this readme file.

💡 Challenges faced and learnings

  • Got familiar with OpenCV and Pillow library for working with media files.
  • Learnt about how digital images are stored in a computer.
  • Faced a major challenge in mapping the characters onto the image.
  • Learnt about how videos are processed frame-by-frame.

📚 Resources

🐛 Bug Reporting

Feel free to open an issue on GitHub if you find bugs.

⭐ Feature Request

  • Feel free to open an issue on GitHub to add any additional features you feel could enhance this project.
  • You can also discuss and provide suggestions to me on LinkedIn.

if (youEnjoyed) {
     starThisRepository();
}

About

ASCIIFY can be used to convert images and videos to ASCII Art. I have made this project as a part of the IITR ACM- Open Summer Project, 2022.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages