Tango is a sad thought that is danced.think & dancemore quotes

# ascii: curious

The Outbreak Poems — artistic emissions in a pandemic

# ASCII Art—Proportional Spacing, Tone/Structure Mapping and Fixed Strings

## contents

asciifyimage-0.02.tgz

This is a Perl script and requires Imager. See README in the archive for instructions. I cannot provide installation support, but welcome questions and ideas about the method.

## examples

Part of the Pioneer plaque rendered with the sequence of human chromosome 1, using 8 weights of Gotham. (zoom)
DNA helix rendered with string 'dna'. (zoom)

After finding a typographic portrait of Christopher Hitchens, created out of Gill Sans letters by Miles Chic at Capilano University, I thought to resurrect software I wrote a long time ago that converts images into letters and expanding traditional ASCII art by using

• proportionally spaced fonts
• a variety of font weights in a single image
• both tone and structure of the image to select characters
• fixed strings to render an image in legible text

## ASCII Art

The representation of images by characters—ASCII art—has a long history. ASCII art extends the emoticon (or smiley) to represent a larger piece of work. Typically, the works use a fixed-space font (e.g. Courier), originally designed for display on a terminal. Despite the sophistication of computer graphics today, ASCII art continues to have a strong following with new work continually added to public online galleries.

Community contributions to ASCII Art Museum. ASCII art can vary from simple cartoon-like depictions to photorealistic interpretations. (source, zoom)

Photos and paintings can be ASCIIfied using a tone-based approach and automated methods exist to do this (Paul D. O’Grady and Scott T. Rickard (2008) Automatic ASCII Art Conversion of Binary Images Using Non-Negative Constraints).

Many artists generate new creations, exclusive to the medium. Typically this kind of ASCII art is based on the interpretation of structure rather than tone—this method has also been automated (Xuemiao Xu, Linling Zhang, Tien-Tsin Wong (2010) Structure-based ASCII Art).

## Proportional spaced and multi-font art

I have written code to generate ASCII art from images by using proportional spaced fonts.

Fixed width fonts (e.g. Pragmata) are popular. ASCII art can be extended to proportionally spaced fonts (e.g. Gotham). More than one weight (or font) can be used to add contrast.

Below is an example of how Pragmata and Gotham can be used to different effect to render an image. When a proportional spaced font is used, the ASCII shape can more fully fill the image.

Comparison of fixed and proportional spaced fonts in ASCII art. Employing multiple weights adds contrast. The grey background is added to emphasize the original image. (zoom)

Let's see how these methods work on a real image. Many ASCII art Mona Lisa versions exist. Below, I render the Mona Lisa with Pragmata, Gotham Book and 8 weights of Gotham.

## structural character selection

Two-tone shapes like the S in the figure above require selecting characters that match the structure of the image. (e.g. "|" matches vertical lines). For a given character and image position there are four distinct match possibilities—a combination of whether the character and image have a signal at a position. I show this in the figure below.

Finding the best character involves maximizing overlap (s1, s3) and minimizing penalty (s2, s4).

By maximizing scores derived from matches (s1, s3) and minimizing any penalties (s2, s4), a character is identified based on maximal coverage of the image region and minimum coverage of areas that are blank.

Ink artwork, or thresholded bitmaps in which there are only two tone values, are approximated using structural matching. Here I compare the method of O'Grady and Rickard with my naive structural matching. (zoom)

When proportional text is used, edges are better approximated, such as in the Homer Simpson example below which uses Gotham Book.

For this image, 17pt text matches the detail well. (zoom)

## tone-based character selection

Images that are not two-tone require that we match both structure and tone. Structure is approximated by the choice of character, while tone by choice of font weight. To select the best character based on tone, the character's average tone is compared to the average tone of the section of the image to which it is being compared.

Heavier weights are used to match dark areas of the image. (zoom)

It is possible to combine both structure and tone metrics in character selection. Below is an example of how an image with both tone and structure is interpreted as the tone and structure score weights are varied. The balance between these two metrics can be very hard to find—it greatly depends on the image. Tone-based mapping works well when font size is small and the image is viewed from larger distance—in this case, characters play the role of individual pixels with varying brightness. Structure-based mapping works with larger type and closer viewing distance.

A tone:structure ratio of 1:0.5 works well for the Star Trek logo. (zoom)

Continuous tone bitmaps are an idea application of multi-font ASCII art—images no longer need to be thresholded or dithered.

Applying both tone and structure character selection metrics to a greyscale image. (source, zoom, )

## fixed string ASCII art

ASCII art is generated by dividing the image into a grid and finding the letter (the choice of characters is often expanded to include punctuation) that best matches the grid section. Typically, for each grid the entire set of allowable characters is sampled. Instead, we can limit the choice of character by successively sampling from a fixed string.

Fixed string ASCII art limits the choice of characters available at each grid. Characters can be drawn from a short string (e.g. 'ilovegotham') or from a larger corpus (e.g. Wikipedia entry for Mona Lisa). The string can be contiguous within the image, or locally within the font. (zoom)

rendered with the fixed string "monalisa" using 8 weights of Gotham.

Fixed string ASCII art rendering of Mona Lisa. (zoom)
DNA helix rendered with string 'dna'. (zoom)
DNA helix rendered with sequence from human chromosome 1. (zoom)

## angled text ASCII art

Things get even more interesting when the text is angled.

By applying rotations to the input and output images, the image can be approximated by angled text. (zoom)

## multi-layer ASCII art

The image can be textured with multiple layers of ASCII art. In the example below, four layers of text are used, each with a different font size.

Part of the Pioneer plaque rendered with the sequence of human chromosome 1, using 4 layers of sizes (17pt, 33pt, 59pt and 93pt) and 8 weights of Gotham. (zoom)

Instead of varying size, the angle of the text can be changed among layers. This results in a pattern reminiscent of a halftone.

Part of the Pioneer plaque rendered with the sequence of human chromosome 1, using 4 layers with different text rotation (-45, -15, 15, 45 degrees) and 8 weights of Gotham. (zoom)

## recursive ASCII art

An image can be asciified several times, with each iteration the asciified output of the previous step used as input for the next. At each step, the font size should be reduced to s → √s.

ASCII, set in Gotham Ultra (zoom)
The above image asciified using 8 weights of 105pt Gotham and the fixed string 'ASCII'. (zoom)
The asciified example above, asciified again using 8 weights of 11pt Gotham and the fixed string 'ASCII'. (zoom)

# Points of Significance celebrates 50th column

Mon 24-08-2020

We are celebrating the publication of our 50th column!

To all our coauthors — thank you and see you in the next column!

Nature Methods Points of Significance: Celebrating 50 columns of clear explanations of statistics. (read)

# Uncertainty and the management of epidemics

Mon 24-08-2020

When modelling epidemics, some uncertainties matter more than others.

Public health policy is always hampered by uncertainty. During a novel outbreak, nearly everything will be uncertain: the mode of transmission, the duration and population variability of latency, infection and protective immunity and, critically, whether the outbreak will fade out or turn into a major epidemic.

The uncertainty may be structural (which model?), parametric (what is $R_0$?), and/or operational (how well do masks work?).

This month, we continue our exploration of epidemiological models and look at how uncertainty affects forecasts of disease dynamics and optimization of intervention strategies.

Nature Methods Points of Significance column: Uncertainty and the management of epidemics. (read)

We show how the impact of the uncertainty on any choice in strategy can be expressed using the Expected Value of Perfect Information (EVPI), which is the potential improvement in outcomes that could be obtained if the uncertainty is resolved before making a decision on the intervention strategy. In other words, by how much could we potentially increase effectiveness of our choice (e.g. lowering total disease burden) if we knew which model best reflects reality?

This column has an interactive supplemental component (download code) that allows you to explore the impact of uncertainty in $R_0$ and immunity duration on timing and size of epidemic waves and the total burden of the outbreak and calculate EVPI for various outbreak models and scenarios.

Nature Methods Points of Significance column: Uncertainty and the management of epidemics. (Interactive supplemental materials)

Bjørnstad, O.N., Shea, K., Krzywinski, M. & Altman, N. (2020) Points of significance: Uncertainty and the management of epidemics. Nature Methods 17.

Bjørnstad, O.N., Shea, K., Krzywinski, M. & Altman, N. (2020) Points of significance: Modeling infectious epidemics. Nature Methods 17:455–456.

Bjørnstad, O.N., Shea, K., Krzywinski, M. & Altman, N. (2020) Points of significance: The SEIRS model for infectious disease dynamics. Nature Methods 17:557–558.

# Cover of Nature Genetics August 2020

Mon 03-08-2020

Our design on the cover of Nature Genetics's August 2020 issue is “Dichotomy of Chromatin in Color” . Thanks to Dr. Andy Mungall for suggesting this terrific title.

Dichotomy of Chromatin in Color. Nature Genetics, August 2020 issue. (read more)

The cover design accompanies our report in the issue Gagliardi, A., Porter, V.L., Zong, Z. et al. (2020) Analysis of Ugandan cervical carcinomas identifies human papillomavirus clade–specific epigenome and transcriptome landscapes. Nature Genetics 52:800–810.

# Poster Design Guidelines

Wed 15-07-2020

Clear, concise, legible and compelling.

The PDF template is a poster about making posters. It provides design, typography and data visualiation tips with minimum fuss. Follow its advice until you have developed enough design sobriety and experience to know when to go your own way.

Poster Design Guidelines — Clear, concise, legible and compelling..