Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concrete poetry #9

Open
enkiv2 opened this issue Apr 17, 2017 · 0 comments
Open

Concrete poetry #9

enkiv2 opened this issue Apr 17, 2017 · 0 comments

Comments

@enkiv2
Copy link

enkiv2 commented Apr 17, 2017

This program takes a word list & an input image, and produces an ascii art version of that image using only words from the list. It behaves similarly to libaa if you pass in a 'word list' consisting of printable ascii (although it adds a space before each word).

How this is actually implemented is a little more interesting. I render each word of text twice (once with regular color and once inverted), and I use those word masks to mask out pieces of the source image, then counting the average value of the remaining pixels. I score words based on how close they get to covering all the filled-in pixels in the section & not covering any of the non-filled-in ones (or getting approximately the same shading ratio in the normal case).

Given this source image and the first 100 lines of this word list, I produced this output, and the inverted image produces this.

Source: https://github.com/enkiv2/misc/blob/master/napogenmo2017/asciiImage.py

Please note, if you're planning to run this, that it expects a newish version of pillow, built with the freetype extension. The PIL/Pillow that ships with debian & ubuntu won't work, and to install from pip on those platforms you will need the dev packages for libfreetype & libjpeg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants