PDA

View Full Version : image to ascii conversions


Mike Chambers
June 3rd, 2008, 11:24 PM
just stumbled upon an old file produced by a program i wrote about 3 years ago that converted images to ASCII... it didn't do the greatest job. i should have tweaked with the code more, but this is supposed to be a picture of me that it converted from a BMP file.

it, um, really seems to like Q's and G's... i could probably have gotten it to show more variety if i had it mess with the image's contrast before conversion.

Trixter, it used more or less the same technique that your 8088 corruption video encoder uses.. it compared each block of pixels to those in all the ASCII characters and it tried to pick the closest one... except, again, it REALLY liked Q's and G's lol.

http://rubbermallet.org/king_ascii.jpg

Trixter
June 3rd, 2008, 11:48 PM
Trixter, it used more or less the same technique that your 8088 corruption video encoder uses.. it compared each block of pixels to those in all the ASCII characters and it tried to pick the closest one... except, again, it REALLY liked Q's and G's lol.


That's only how my first encoder worked, not the final one. The full details are here: http://www.archive.org/details/8088CorruptionExplained

Not bad for a first attempt :-) One thing that I can recommend that helped me get a better conversion (mandatory when your resolution is 40x25) is to have the actual font table handy to compare against. Even if you don't want to hit ASCII >127, it helps to know exactly what you're trying to match.

Mike Chambers
June 4th, 2008, 12:32 AM
That's only how my first encoder worked, not the final one. The full details are here: http://www.archive.org/details/8088CorruptionExplained

Not bad for a first attempt :-) One thing that I can recommend that helped me get a better conversion (mandatory when your resolution is 40x25) is to have the actual font table handy to compare against. Even if you don't want to hit ASCII >127, it helps to know exactly what you're trying to match.

yup, that's what i did actually. in the case of that JPG, i took a screenshot of the text file output my prog made loaded up into wordpad with the "system" font. what i did first was get give my program a file that had all the chars from that font in it, so that it could look at those first.

i have seen that video you posted there in the past. the "half-toning" looks fantastic! well, i'd rather watch a blu-ray on the 1080p but as far as CGA goes yeah that's fantastic!:eek:

ASCII codes 176, 177, 178, and 219 always came in handy back in the day when i was making ANSI art for my BBS in the very early 90's. i miss those days... dialing up to a local board, and playing legend of the red dragon for hours at a time... chatting with somebody who logged onto my system... modifying my QB BBS code to handle ZMODEM when everybody started complaining that XMODEM sucked lol.

it's just not the same with today's internet. it seems so big.

ahm
June 4th, 2008, 10:27 AM
http://en.wikipedia.org/wiki/AAlib

Mike Chambers
June 4th, 2008, 05:40 PM
http://en.wikipedia.org/wiki/AAlib

i've used AAlib before, it is amazing. i forget what the program is called, but i had one in debian that would render video live from a capture card to text in real-time. it was pretty amazing to see.

i'm not sure how they got it to run so fast. i only used an old 750 AMD mhz machine for it, and the framerate was a full 30 FPS, and the CPU wasn't even close to being maxed out.

Trixter
June 4th, 2008, 08:42 PM
i'm not sure how they got it to run so fast. i only used an old 750 AMD mhz machine for it, and the framerate was a full 30 FPS, and the CPU wasn't even close to being maxed out.

AALib is one 256-entry lookup table. That's it.

It's only slightly more than that, but that's about it. Download the source and see for yourself.