All Projects → korhner → Asciimg

korhner / Asciimg

Licence: mit
An ascii image generator written in Java.

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Asciimg

xibalba
A Mayan roguelike
Stars: ✭ 50 (-87.56%)
Mutual labels:  ascii-art
ascii chart
Nice-looking lightweight console ASCII line charts ╭┈╯. Port of kroitor/asciichart.
Stars: ✭ 24 (-94.03%)
Mutual labels:  ascii-art
Tart
Tart - draw ASCII art in the terminal with your mouse!
Stars: ✭ 296 (-26.37%)
Mutual labels:  ascii-art
asciisciit
ASCII Art, Video, and Plotting Toolbox
Stars: ✭ 71 (-82.34%)
Mutual labels:  ascii-art
hoard-of-bitfonts
turns out I like bitmap fonts
Stars: ✭ 811 (+101.74%)
Mutual labels:  ascii-art
lexicon-mono-seq
DOM Text Based Multiple Sequence Alignment Library
Stars: ✭ 15 (-96.27%)
Mutual labels:  ascii-art
chess
Chess (game)(♟) built in C# and ASCII art.
Stars: ✭ 20 (-95.02%)
Mutual labels:  ascii-art
Figlet Fonts
my collection of figlet / toilet ascii art fonts
Stars: ✭ 393 (-2.24%)
Mutual labels:  ascii-art
figlet4s
ASCII-art banners in Scala
Stars: ✭ 29 (-92.79%)
Mutual labels:  ascii-art
Csconsoleformat
.NET C# library for advanced formatting of console output [Apache]
Stars: ✭ 296 (-26.37%)
Mutual labels:  ascii-art
pi-asciicam
A live stream ASCII webcam server for Raspberry Pis using websockets, written in go.
Stars: ✭ 18 (-95.52%)
Mutual labels:  ascii-art
gifterm
View animated .GIF files in a text console. Linux/Mac/Windows
Stars: ✭ 14 (-96.52%)
Mutual labels:  ascii-art
hasciicam
(h)ascii for the masses! html refreshed ascii video cam
Stars: ✭ 63 (-84.33%)
Mutual labels:  ascii-art
ascii-image
Web Component that displays an image as ASCII art
Stars: ✭ 15 (-96.27%)
Mutual labels:  ascii-art
Imgtoascii
A JavaScript implementation of a image to Ascii code
Stars: ✭ 331 (-17.66%)
Mutual labels:  ascii-art
tdraw
Draw ASCII art in terminal
Stars: ✭ 121 (-69.9%)
Mutual labels:  ascii-art
fish logo
🐠 Fish shell colorful ASCII-art logo
Stars: ✭ 82 (-79.6%)
Mutual labels:  ascii-art
Boxes
Command line ASCII boxes unlimited!
Stars: ✭ 398 (-1%)
Mutual labels:  ascii-art
Grassy
Build layout through ASCII art in Sass (and more). No pre-built CSS. No additional markup.
Stars: ✭ 335 (-16.67%)
Mutual labels:  ascii-art
Jcolor
An easy syntax to format your strings with colored fonts and backgrounds.
Stars: ✭ 255 (-36.57%)
Mutual labels:  ascii-art

asciimg

Asciimg is an extensible Ascii art generator written in Java. For more info refer to this blog post: http://korhner.github.io/java/image-processing/ascii-art-generator-part-2/

Example usage

// initialize cache
AsciiImgCache cache = AsciiImgCache.create(new Font("Courier",Font.BOLD, 6));

// load image
BufferedImage portraitImage = ImageIO.read(new File("image.png"));

// initialize converters
AsciiToImageConverter imageConverter = 
    new AsciiToImageConverter(cache, new ColorSquareErrorFitStrategy());
AsciiToStringConverter stringConverter = 
    new AsciiToStringConverter(cache, new StructuralSimilarityFitStrategy());

// image output
ImageIO.write(imageConverter.convertImage(portraitImage), "png", 
    new File("ascii_art.png"));
// string converter, output to console
System.out.println(stringConverter.convertImage(portraitImage));

Example output

Here are some sample images generated with various parameters:

Original picture

16 pts font, MSE
16 pts font, SSIM
10 pts font with 3 characters, MSE
10 pts font with 3 characters, SSIM
6 pts font, MSE
6 pts font, SSIM

Architecture:

Architecture

AsciiImgCache

Before any ascii art rendering takes place, it is necessary to create an instance of this class. It takes a font and a list of characters to use as parameters and it creates a map of images for every character. There is also a default list of characters if you don't want to bother comming up with your own.

BestCharacterFitStrategy

This is the abstraction of the algorithm used for determining how similar a part of the source image with each character is. The implementation should compare two images and return a float error. Each character will be compared and the one that returns the lowest error will be selected. Currently there two implementations available: ColorSquareErrorFitStrategy and StructuralSimilarityFitStrategy.

ColorSquareErrorFitStrategy

Very simple to understand, it compares every pixel and calculates Mean squared error.

StructuralSimilarityFitStrategy

The structural similarity (SSIM) index algorithm claims to reproduce human perception and its aim is to improve on traditional methods like MSE. Uou can read more on Wikipedia if you want to know more. I experimented a bit with it and implemented a version that seemed to produce the best results for this case.

AsciiConverter

This is the hearth of the process and it contains all the logic for tiling source image and utilizing concrete implementations for calculating character best fit. However, it doesn't know how to create the concrete ascii art - it needs to be subclassed. There are two implementations currently: AsciiToImageConverter and AsciiToStringConverter - which as you probably guessed, produce image and string output.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].