| ▲ | Jyaif 6 hours ago | ||||||||||||||||
It's important to note that the approach described focuses on giving fast results, not the best results. Simply trying every character and considering their entire bitmap, and keeping the character that reduces the distance to the target gives better results, at the cost of more CPU. This is a well known problem because early computers with monitors used to only be able to display characters. At some point we were able to define custom character bitmap, but not enough custom characters to cover the entire screen, so the problem became more complex. Which new character do you create to reproduce an image optimally? And separately we could choose the foreground/background color of individual characters, which opened up more possibilities. | |||||||||||||||||
| ▲ | alexharri 4 hours ago | parent | next [-] | ||||||||||||||||
Yeah, this is good to point out. The primary constraint I was working around was "this needs to run at a smooth 60FPS on mobile devices" which limits the type and amount of work one can do on each frame. I'd probably arrive at a very different solution if coming at this from a "you've got infinite compute resources, maximize quality" angle. | |||||||||||||||||
| ▲ | spuz 5 hours ago | parent | prev | next [-] | ||||||||||||||||
Thinking more about the "best results". Could this not be done by transforming the ascii glyphs into bitmaps, and then using some kind of matrix multiplication or dot production calculation to calculate the ascii character with the highest similarity to the underlying pixel grid? This would presumably lend itself to SIMD or GPU acceleration. I'm not that familiar with this type of image processing so I'm sure someone with more experience can clarify. | |||||||||||||||||
| ▲ | finghin 5 hours ago | parent | prev | next [-] | ||||||||||||||||
In practice isn’t a large HashMap best for lookup, based on compile-time or static constants describing the character-space? | |||||||||||||||||
| |||||||||||||||||
| ▲ | brap 5 hours ago | parent | prev | next [-] | ||||||||||||||||
You said “best results”, but I imagine that the theoretical “best” may not necessarily be the most aesthetically pleasing in practice. For example, limiting output to a small set of characters gives it a more uniform look which may be nicer. Then also there’s the “retro” effect of using certain characters over others. | |||||||||||||||||
| ▲ | Sharlin 6 hours ago | parent | prev [-] | ||||||||||||||||
And a (the?) solution is using an algorithm like k-means clustering to find the tileset of size k that can represent a given image the most faithfully. Of course that’s only for a single frame at a time. | |||||||||||||||||