Message Boards Message Boards

20
|
10135 Views
|
7 Replies
|
45 Total Likes
View groups...
Share
Share this post:

Having Fun with AsciiCam in Wolfram Language!

Posted 11 years ago
Inspired on this site I tried to create a Wolfram Language version of an asciicam.

It's cool to see how compact is the code!
 char=CharacterRange[" ","~"]~Join~Map[Style[#,Bold]&,CharacterRange[" ","~"]];
 w=N@Mean@Flatten@ImageData@Binarize@Rasterize@#->#&/@char;
 w[[All,1]]=#~Rescale~{Min[#],Max[#]}&@w[[All,1]];
 findChar=Nearest[w];
 
 asciiIt[image_]:=Module[{img},
     img=ImageAdjust@ColorConvert[image,"Grayscale"];
     img=ImageData@ImageResize[img,80];
     img=Map[First@findChar[#,1]&,img,{-1}];
    Grid[img,Spacings->{0.1,-0.2},ItemSize->{0.4,0.4}]
]

Dynamic[asciiIt@CurrentImage[]]
So we get:

POSTED BY: Rodrigo Murta
7 Replies
Rodrigo, that's really cool! Thanks for sharing emoticon
I added color, first with ColorNegate@image and then using ImageSubtract:
  char=CharacterRange[" ","~"]~Join~Map[Style[#,Bold]&,CharacterRange[" ","~"]];
  w=N@Mean@Flatten@ImageData@Binarize@Rasterize@#->#&/@char;
  w[[All,1]]=#~Rescale~{Min[#],Max[#]}&@w[[All,1]];
  findChar=Nearest[w];
  
  asciiIt[image_]:=Module[{img},
      img=ImageAdjust@ColorConvert[ColorNegate@image,"Grayscale"];
      img=ImageData@ImageResize[img,50];
      img=Map[First@findChar[#,1]&,img,{-1}];
    Grid[img,Spacings->{0.2,-0.2},ItemSize->{0.4,0.4}]
]

width=ImageDimensions[Rasterize[asciiIt@CurrentImage[]]][[1]];
Dynamic[ImageSubtract[ImageResize[CurrentImage[], width], Rasterize[asciiIt@CurrentImage[]]]]


Spacings->{0.2,-0.2} gives you the right AspectRatio.
POSTED BY: Bernat Espigulé
@Bernard very cool!.. Using green scale in your code we have a beautiful Matrix effect:
ImageSubtract[ImageResize[ImageMultiply[CurrentImage[], Green], 450],Rasterize[asciiIt@CurrentImage[]]]
POSTED BY: Rodrigo Murta
Nice! ;-)
POSTED BY: Bernat Espigulé
Recreating Neo in Wolfram Language, cool!.. @Bernart, do you have a user in StackExchange? I posted you gif image there, in the chat room.
POSTED BY: Rodrigo Murta
@Rodrigo here is my user Geonat. Let's increase my low-level reputation with this new look. ;-)
POSTED BY: Bernat Espigulé
And fun this is! - thanks for sharing. Did I get this correctly - you showing a page of paper where you wrote WL to the camera?
POSTED BY: Vitaliy Kaurov
Hi @Vitaliy! Cool that you liked It.
Yes, I wrote WL in a page of paper.
POSTED BY: Rodrigo Murta
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract