ImgToAsci

ImgToAsci is a simple C++ program that converts an image file into ASCII art.

How to Use

Prerequisites

  • C++ compiler
  • OpenCV library

Usage

  1. Clone this repository:

    git clone https://github.com/jeffizmyname/ImgToAsci.git
  2. Navigate to the project directory:

    cd ImgToAsci
  3. Compile the program:

    g++ -o image_to_ascii image_to_ascii.cpp -std=c++11 `pkg-config opencv --cflags --libs`
  4. Run the program with the image file path as an argument:

    ./image_to_ascii image.jpg

Replace image.jpg with the path to your image file.

Output

The program will generate an output.txt file containing the ASCII representation of the input image.

Example

Input Image:

Input image example

Output ASCII Art:

..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSSS#S%%SSSSSS#SS%S%%#@##@@#SSSSSSSSSSSSSSS.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSSS#S%%SSSSSS#SS#@#S?*****S@#SSSSSSSSSSSSS.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSSS#S%%SSSSS#@#%?***********%@@###########.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSSS#S%%S%S@#%*****************#@SSSSSSSSSS.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSSS#S%%#@S******************%S%S@@########.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSSSSS#@%*****************%#S*:,..*@@######.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSSSS#@#?*****************S#*,.......:@@S####.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#SSS#@#?****************?#S;...........:@@####.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#S#@#?*****************#S:..............;@####.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%S#@#?*****************S#;.................?@###.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@?*****************%@*...................,@#SS.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#@%******************#S,.......,;*?%SSSS%S#%;*@##.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%%%%#@%***********S#@@#?**@%......:?#?*;,....;+..:*#@#S.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%%S#@%***********?@S@@@@%+@%.....;S?:,:.:##S%#S%#SSS+%@S.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%%%%%%%%%%%%%%%%%%%%%%#@S*************#@%#@@#*#S....,S%,:SSSS#?+*********%#@S.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%SSSSSSSSSSSSSSSSSSSS@#***************S@@@@#+##,...+@?*+#%+**+************?@#.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%%%%%%%%%%%%%%%%%#@?*****************?S%*+S@,...?S*#??***%S%S?SS#??#S***+#@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%SSSSSSSSSSSSS%S@S***********************%@;...?@%S***S%#*..:*,.,**.:#SSS#@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%SSSSSSSSSSSSS@#?***********************?@*...;@%***SS+?++*?%SSSSS%?+,:.,S@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%S#S%%%%%%%%S@S*************************@%....S#+*%?;;?S?+:,......,;*S#*.+@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%S#SSSSSSSS#@?*************************##.....@+..:?#*,...............,?#S@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%S#S%SS%%#@S**************************S@:....,@?*#?:....................,%@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%S#S%SSS@#?**************************?@+......,+:........................+@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%SSSS#@#?****************************@S..................................S@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS#%%S%#@@S%******************************S@,.................................;@@.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#SS#SSSS##@@S%?*********************************@*..................................S@#.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS#S%@##@#S?*************************************S@..................................+@##.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%#@@S%?*****************************************@*.................................,@@##.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS%S@#%*********************************************%@,.................................?@###.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS@#?***********************************************@S.................................:@@###.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS@#?*************************************************@*.................................%@####.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS#@%**************************************************@*................................+@@####.
..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS@@@@#S?*******************************************?@+...............................,@@#####.
..SS%#SSS%%SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS#####@@@#?****************************************?@;...............................%@######.
..SS%#SSS%%%%###SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS#@###@@#@@?****************************************@*..............................+@#######.
..SS%#SSS%%%%#######SSSSSSSSSSSSSSSSSSSSSSSSSSSSSS###SSSSS@#*****************************************#%.............................;@@#######.
..SS%#SSS%%%%#######S%SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS@#******************************************@%............................,#@########.
..SS%#SSS%%%%#######SS#SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS@#*******************************************@%............................S@#########.
..SS%#SSS%%%%#######SS#SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS@%********************************************@*...........................%@##########.
..SS%#SSS%%%%#######SS#%%SSSSSSSSSSSSSSSSSSSSSSSSSSSS#@?********************************************?@+..........................?@###########.
..SS%#SSS%%%%#######SS#%%#SSSSSSSSSSSSSSSSSSSSSSSSSS@@?*********************************************%@,........................,%@@@##########.
..SS%#SSS%%%%#######SS#%S@SSSSSSSSSSSSSSSSSSSSSSSSS@@*********************************S@%***********#S........................*@S+?@@#########.
..SS%#SSS%%%%#######SS#%S#SSSSSSSSSSSSSSSSSSSSSSSS@#*********************************%@S@**********?@;......................+#S****?@@S#######.
..SS%#SSS%%%%#######SS#%S#SSSSSSSSSSSSSSSSSSSSSSS@#*********************************S#:.%#*********#%.....................;S#?******%@########.
..SS%#SSS%%%%#######SS#%S#SSSSSSSSSSSSSSSSSSSSSS@S*********************************#%,..,@S*******%#,...................;S#?*********#@#######.
..SS%#SSS%%%%#######SS#%S#SSSSSSSSSSSSSSSSSSSSS@%********************************%@+.....;@?*****%@:..................;S#?***********?@@######.
..SS%#SSS%%%%#######SS#%S#SSS#S%SSSSSSSSSSSS%S@%********************************#S,.......+@?***SS,.................+#S?**************S@######.
..SS%#SSS%%%%#######SS#%S#SSS#S%SSSSSSSSSSS%S@S*******************************?@*..........:S##S;................,*@%*****************?@@#####.
..SS%#SSS%%%%#######SS#%S#SSS###%%%%%%%%%%%S@%*******************************%@;..............,................+S@@@#%?****************@@#####.
..SS%#SSS%%%%#######SS#%S#SSS####SSSSSSSSS#@%*******************************S@:.............................:?@@@##@@@@@#S?************S@#####.
..SS%#SSS%%%%#######SS#%S#SSS#####S%SSSS%#@?*******************************##,............................+S@@##@##@@@@@@#@@S**********%@@@@@@.
..SS%#SSS%%%%#######SS#%S#SSS######SSS%S@#********************************#S...........................;%@@SS#@#@##@@@@@@##@@@S********?@#####.
..SS%#SSS%%%%#######SS#%S#SSS#######SS#@%********************************#S.........................:?@@####S#@#@##@@@@@@##@##@@%******?@@####.
..SS%#SSS%%%%#######SS#%S#SSS#S####S#@S*********************************@%.......................;?#@@###@##S#@#@##@@@@@@#####S#@S******@@@@@@.
..SS%SS##@@@############@@@@@@@@@@@#%**********************************@?.....................;%@@@#@####@##S#@#@##@@@@@#########@#****?@#####.
..S#@@#S?*********************???*************************************@%..................,;?@@##@@@@####@##S#@#@##@@@############@#***%@#####.
..@#*****************************************************************##,...............;?#@@#@@##@@@@####@##S#@#@##@###############@#*?@@#####.
..#@S***************************************************************?@+............:?S@@@##@#@@##@@@@####@##S#@#@@##################@@@@######.
..SS@@S*************************************************************%@:........:*S@@@#####@@#@@##@@@@####@##S#@#@@#################@@#@#######.
..####@@#%?**********************************************************%#S?+;;*S@@@#########@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..######@@@@S?*******************************************************??S@@@@@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..#####@@@@#@@@#?*********************************************??%S#@@@@@####@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..#####@@@@@#@@@@S************************************??%S##@@@@@@@#########@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..#####@@@@@####@@?***************************?%%SS#@@@@@##S@##@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..S####@@@@@@@@@@@%**********************?S#@@@@@##@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..###############@%******************?S@@@@########@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..##############@@*****************?#@@@@@@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..##############@S****************#@@S#@@@@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..#############@@***************%@@#S#S##@@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..############@@?**************#@@#######@@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..##########S#@S*************S@@##########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..##########S@@?***********%@@@###########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..###########@#**********S@@##@###########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..@@@@@@@@@@@@S+******?S@@#@@#@###########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..#########S#@S+****%#@@#S@@@#@###########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..###########@S+*%S@@#@###@@@#@###########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.
..SSSSSSSSSSS#@@@@@@@#@###@@@#@###########@@#@#####@########@@#@##@#@#######@#####@#######@@#@@##@@@@####@##S#@#@@#################@@@@#######.

To-Do

  • diffrent ascii tables