Kai
Kitagawa-Jones

imageToUnicode

A C / Python library that extends the idea behind ptmv, and it aims to display more complex images using unicode characters. I am eventually planning to improve ptmv using this library. A Python interface is planned to achieve this.

The main difference between the graphics used in ptmv and imageToUnicode is that while ptmv only uses the Unicode character , imageToUnicode uses the following 19 characters:

▁ ▂ ▃ ▄ ▅ ▆ ▇

▏ ▎ ▌ ▍ ▋ ▊ ▉

▝ ▘ ▗ ▖ ▚

Using these characters, imageToUnicode can find the best match for a particular cluster of pixels, improving the accuracy of the final output.

Because the final goal of this project is to improve ptmv, performance is an important factor, as ptmv is also used to play videos. This is the main reason that the main algorithm is written in C. As well as being much faster than Python, C also provides direct control over memory, greatly reducing the number of wasteful operations performed.

It is possible to choose the level of detail wanted in the final output. This is done by restricting the number of characters allowed to be used from 19 to some specified number. The lowest level of detail uses a single character , thus outputting the same image as the current implementation of ptmv.

Here is a comparison between detail levels:

detail = 0 (1 character used), same as ptmv
detail = 3 (6 character used)
detail = 6 (19 character used)

As shown, at detail = 6, the image is extremely sharp, despite the entire image being made up of characters. Although the detail level can be lowered, with the optimizations currently implemented, imageToUnicode can process images at fps suitable for ptmv.

Finally, here is what the image shown above (detail = 6) looks like without any colors: