Image conversion into text

With this project, i convert an image into text

This image:

become this:

the scale is based on the density of black of a letter
ex: @#O%+=|i:. -> the last one is a space (@ = black, space = white)

This is the result of the function convert cst to b/w:

This is very elegant. I love it!

I have a couple of suggestions:

  1. In converting the costume to black and white, you use black pixels and adjust their transparency instead of actually using grayscale (R=G=B). This doesn't really matter if you're using the resulting costume only to compute the text version, I suppose, but it's wrong if you actually want to use a b&w costume. I'm guessing you do it that way because you want the pixels outside the actual costume but inside its bounding box to be transparent. That's a clever hack, but it's not so good if there's a white region inside the costume; you'd want that white, not transparent. And against a non-white background the pixels will be visibly transparent rather than gray. I don't have a brilliant way to fix this; maybe stamp the costume on the stage and FILL its exterior with two different colors and if a post-fill pixel agrees with the fill color both times, it's in the exterior and should be made transparent. Either that or send a sprite from the costume's rotation center to the edge of the screen, then come back in until you see a non-white pixel.

  2. I'm skeptical about your ink-density scales, especially scale 1. You have capital Q as lighter than capital O, which is a subset of it. Similarly, you have + lighter than -, which also can't be true. You, or someone, should make a project that systematically counts the number of black pixels in every character of the font, or at least every ASCII character, and use that information to improve the scales.

Thank you !

scale #1 come from here (1st link i click on google: personnaly, i don't like the result... maybe, if you draw a 10000 x 10000 picture on the wall with caracters, it will be better than # 3, but when we draw a small image (here: 53 lines, 96 caracters per lines), i think we need smaller set of caracters for the density like scale #3)(better contrast)

Personnally, i think the best one is #3 but i don't try so much sets of caracters...

you can make you proper experience just write your own sequence in the block, don't forget to finish the sequence with one space(or two or three: make your own experience) for completely white.

the b/w costume is bunch of black pixels (rgb=0,0,0). The alpha of each pixels (transparency) is the avarage of the 3 rgb channels of theses pixels. The result: a bunch of black pixel with a transparentcy (0-255).

After that, i keep the alpha or each pixels (0-255) and i convert it (the remap function: )

In an image in snap format, a transparent pixel the rgba is 0,0,0,0, i threat this like white in this project.

Oh, I love this! ASCII dithering is soooo cool!

Thank you Jens, can you help me to improve the cst to b/w fonction. It takes 5-6 seconds to convert a costume, it's a bit long...

It's very cool! I love it :heart_eyes:

brings back the good old days! awesome!

Hi guys !

  1. I improve the list of characters: better high to low density
  2. When you draw a costune with your own characters, the program auto-evaluate the density of each characters and auto-sort it by density

You can try with your username if you want !

ex: "@loucheman" --> i add a space at the end for you... (for white)



This is the result when you evaluate:
The 2nd column is the density (NumberOfBlackPixels / TotalOfPixels)

Awesome! Thanks for taking my suggestions.

It's all bh! Very funny sir!

I like it!

Someone have an idea to improve this: (i count the black pixels)

pixels of costume pentrails = 172800 records

(item(1)=0 and item(2)=0 and item(3)=0) 6 secs for 2 characters

is better than

(item(1)+item(2)+item(3))=0 9 secs for 2 characters

Any better idea ?

if the picture you're examining comes from the WRITE block writing in black on white, then R=G=B for all pixels and you can just look at one of them.

almost the same time : 5.5 secs

now i evaluate the max larger character of the set, ans i draw a rectangle of this size around each character before evaluating the density

now: 2.5 secs for 2 characters

and i save the evaluation of density in the local database, so a same string is evaluated only 1 time on your computer...

I saw a video from Jens on youtube about image with dices. So i added it to my project !


Patrick, that's so cool; please split it into a new topic maybe titled "Art made from dices".

This is a wonderful project and I'm sorry for not replying earlier because I got distracted by other things both in RL and Snap!