## TImg

Texas Instrument’s TI-84 Plus is a graphing calculator with a variety of features. It has built-in support for both fractions and complex numbers, can differentiate and integrate given functions and supports programming capabilities. The latter allows to directly manipulate the calculator’s monochrome display’s 5985 pixels (the screen has dimensions `95x63`). TImg is a Python program (source code is listed below and can also be downloaded) which takes in an image and outputs TI-BASIC source code which, when run on the graphing calculator, will produce the given image — in potentially lower quality.

PIL — the Python Imaging Library — is used to read in the image and further for processing. The supplied image may be rotated and resized to better fit the TI-84’s screen and any color or even grayscale information is reduced to an actual bitmap — every pixel only has two distinct values.
Direct pixel manipulation on the TI-84 is done via the Graph screen. To get remove any pixels the system draws on its own, the first three commands are `ClrDraw`, `GridOff` and `AxesOff` which should result in a completely blank screen — assuming that no functions are currently being drawn. All subsequent commands are in charge of drawing the previously computed bitmap. To turn certain pixels on, `Pxl-On(Y,X` is used where `Y` and `X` are the pixel’s coordinates.

Since the TI-84 Plus only has 24 kilobytes of available RAM, the source code for a program which would turn on every single pixel individually does not fit. Luckily, though, a program which only individually turns on half of the screen’s pixels fits. To ensure that TImg’s output fits on the hardware it is designed to be used with, an image’s bitmap is inverted when the required code would otherwise exceed 3500 lines — a value slightly above the required code to draw half of the pixels.

By default, the resulting code draws pixels starting at the screen’s top-left corner and ending at its bottom-right. A command line flag `--shuffle` can be set which changes this behavior to let pixels pseudo-randomly appear on the screen (pseudo-randomness is calculated in the Python script; the TI-BASIC source code is completely deterministic).
And — of course — one can feed the program an image of the calculator the BASIC code runs on; self-referential TIception.

``# Python 2.7 code; Jonathan Frech; 5th, 6th of October 2017``

## Rainbowify

To digitally represent colors, one most often uses the RGB color system. By combining three fundamental light colors in certain ways, one can define a variety of different wavelengths of light. The human eye has three distinct photoreceptors for the aforementioned three colors, nearly all screens use pixels consisting of three parts in those colors and most image formats store the image data in the RGB color system.

However, there are other color systems than RGB with other strengths. Cycling through the colors of the rainbow, for example, is a lot easier using the HSL (or HSV) color model, as it is simply controlled by the hue.

Rainbowify uses the HSL color model to rainbowify a given image. To do so, the image is first converted into a grayscale image (averaging all three color channels). A pixel’s brightness is then interpreted as its hue with its saturation and lightness set to the maximum. As a final touch, the hue gets offset by a pixel-position dependent amount to create the overall appearance of a rainbow.

``# Jonathan Frech; 13th of August, 22nd of September 2017``

## Asciify

Most images nowadays are represented using pixels. They are square, often relatively small and numerous, come in $(2^8)^3$ different colors and thereby do a good job being the fundamental building block of images. But one can imagine more coarse-grained and differently shaped pixels.
An interesting fact is, that in most monotype fonts two characters placed right next to each other (for example ‘\$\$’) occupy roughly a square area. So simple ASCII characters can indeed be used to approximately describe any ordinary image.
Asciify does exactly this; it takes in an image and some optional parameters and maps the pixels’ intensity onto a character set. Both the large and small default character sets are taken from a post by Paul Bourke.

In conjunction with `asciify.py`, I wrote `index.py`, which asciifies a bunch of images and results in their html form; it also creates an index. All images asciified for this post can be viewed through this index.

Converting an image to its asciified form works best when there is a lot of contrast in the image. Because of this, some pre-processing of the image may be required for best results (all images shown where only cropped or rotated). The built-in color functionality also only knows of $8$ colors, so bright and different colors look the best, as they interestingly differentiate from one another. The asciified image’s size also plays a role, the larger it is, the better the characters blend into one and appear to be one image.

Asciify is operated on a command prompt; `python asciify.py img.png`. To parse arguments, the built-in python module `argparse` is used. The images are opened and read using the Python Imaging Library module `PIL`, which needs to be installed for this program to work.
Optional arguments include `--size N`, where the maximum size can be specified, `--invert` and `--smallcharset`, which can sometimes increase the asciified image’s visual appeal and `--html`, which will output an html file to be viewed in a browser. To see the program’s full potential, simply run `python asciify.py --help`.
Source code for both `asciify.py` and `index.py` can be downloaded, the first is also listed below.

The two examples above use the color mode, though certain images also work in default black and white mode, such as this spider I photographed.

Then again, the colored text also has its charm, especially when the source image has bright colors and a lot of contrast.

``````# Python 2.7 Code
# Jonathan Frech 3rd, 4th of March 2017
#      rewritten 12th of April 2017
#         edited 13th of April, 13th, 14th, 15th of July 2017``````