It is currently Tue Jul 23, 2024 8:25 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 19 posts ] 
Author Message
 Post subject: ascii
PostPosted: Thu Dec 19, 2013 7:38 pm  (#1) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
Bonjour,

Here's a first test for a new script.
The letters are centered on colorful squares.
I'll see later if ansi codes can operate.
.xcf file is in the archive.


Attachments:
test1_qwerty.jpg
test1_qwerty.jpg [ 270.34 KiB | Viewed 4011 times ]
lettres.zip [1.2 MiB]
Downloaded 179 times
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: ascii
PostPosted: Thu Dec 19, 2013 7:40 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14728
Location: USA
Hey that looks cool Sam. :)
Nifty idea.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: ascii
PostPosted: Thu Dec 19, 2013 7:43 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12535
Definitely cool samj. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 5:05 am  (#4) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2446
That looks interesting.
This might help lyle and his quest for some ANSI graphics
Image
A font to use with Gmic. The numerals and lower case characters replaced by some of the bolder ansi extended characters.
Not my credit for the font, it comes from here. https://github.com/jcs/ansiterm/tree/master/font
Just a little re-arranging in fontforge. Remember to unzip the attachment. :)


Attachments:
dos437a.zip [20.46 KiB]
Downloaded 136 times

_________________
Image
Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 8:05 am  (#5) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
Bonjour,

Thank you all :tyspin
@ Rich2005 : I'll try this font in the day :)

*****

An example with small colorful letters over a black background.
GMIC "Dynamic range increase" is used for small letters.


Attachments:
test2_qwerty.png
test2_qwerty.png [ 180.89 KiB | Viewed 3909 times ]
Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 8:11 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12535
Thanks Rich; will check these fonts out w.r.t. ansi renders when I get a chance. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 10:03 am  (#7) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
@Rich2005
Here's a test using Gimp 2.6 for this font (does not work in Gimp 2.8 :( )
The characters used are : w12346789abcdmefghilnkzv5j
:tyspin


Attachments:
test_font-dos437_gimp2.6.png
test_font-dos437_gimp2.6.png [ 87.56 KiB | Viewed 3887 times ]
Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 11:52 am  (#8) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
Bonjour,

Here is a non-optimized version of the script that works with Gimp 2.8 and Gimp 2.6 Windows.
THIS SCRIPT IS VERY, VERY, VERY SLOW :otb :otb :otb
If you are impatient, do not use this script :thanku
This is the only version I'll do for Gimp 2.6

Access on the RGB image by :
Filters > Render > QWERTY Gimp 2.6 ...


Gimp 2.8 : I will continue my tests for UTF-8 characters, and check the compatibility with Linux.


Attachments:
textes_001_gimp2_6.zip [11.34 KiB]
Downloaded 132 times
Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 12:36 pm  (#9) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2446
No, that font is not going to work at all, is it. Forget that one.

The whole point of either ascii or ansi graphics is that large areas of the graphic are composed of the same character. I go back to student days (1970) and punched cards, line printers, fan-fold paper.
That particular image is very difficult.

So I am back to a mosaic application, metapixel (linux) and this time a limited tile set (only 4000-something this time) and a bit of editing on the original to remove some of the background.

Image

IMHO a faithfull rendition of ascii is going to be a problem. But still looking forward to the next Gmic

_________________
Image


Top
 Post subject: Re: ascii
PostPosted: Fri Dec 20, 2013 12:47 pm  (#10) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
@Rich2005

The font is not a problem.
Gimp 2.8 Windows is not able to properly render characters.

*****

Edit : The font works fine with Gimp 2.8 Linux (picture attached) :)


Attachments:
test_gimp28_linux.png
test_gimp28_linux.png [ 24.24 KiB | Viewed 3860 times ]
Top
 Post subject: Re: ascii
PostPosted: Sun Dec 22, 2013 9:27 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jun 24, 2010
Posts: 504
Location: Western Vic Australia
Hi Sam , I do not understand your script but I think I know what you are trying to achieve. I think you are trying to generate a alphanumeric character based on colour and overlay the character over the image.
I tried to do something similar and perhaps it will give you some other ideas.
I copied an image of Lena and did a blur/pixellate at 20 px , Then did an elsamuko-Obama-Hope filter which gave me 5 black and white thresholded images in the xcf which I used as selections to fill with previously made .pat (pattern) files The Paterns were made to space chars at 20 px. (unfortunately my @ signs were not very accurate, hence the striping) I show you the ascii image and the ascii image with Lena .

As an aside, Rich2005 is quite correct that the ascii prints were usually done on line printers and many a banner and portrait was made, you have probably seen the ascii images on Google. One of the methods to achieve darker print was to overstrike by isuing repeated "print/ nospace" commands to the printer. Unfortunately, sometimes the paper used to shred. The ink was wet and the hammers would "pound" through the paper and cause the print train to crash with paper debris between the type slugs. I know because I worked on the 1403 printers

I tried to alter the obama-hope filter script to give more images but got hopelessly lost.

Image
Image

_________________
Image


Top
 Post subject: Re: ascii
PostPosted: Sun Dec 22, 2013 9:50 am  (#12) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
@Wbool63

Thank you for the reply and the tutorial :)

This is not the result I want.

What do the script I propose :
It decomposes image into rectangles with unique color.
It places characters centered on this rectangle.
The characters are not random.
It uses UTF8 characters.
The realization is not so simple ...


Top
 Post subject: Re: ascii
PostPosted: Sun Dec 22, 2013 10:33 am  (#13) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
Bonjour,

Here is an example (Made from script-fu "ASCII UTF-8") of what I want.
Any suggestion faster than my new script running Gimp would be appreciated.


Attachments:
3car-2.png
3car-2.png [ 286.39 KiB | Viewed 2277 times ]
Top
 Post subject: Re: ascii
PostPosted: Sun Dec 22, 2013 3:35 pm  (#14) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
samj wrote:
Any suggestion faster than my new script running Gimp would be appreciated.

One way to speed up your script is to disable UNDO for the new image -- you are currently using 'gimp-undo-push-group-*'. The only thing that performing undo would accomplish on a new image is take you back to an empty image. This is not worthwhile (you'll notice that all of the images created under "File->Create" menu have empty undo histories).

When you use gimp-undo-push, every operation you perform that modifies the image requires an additional step to save that operation in the UNDO history. By disabling UNDO, these additional steps are avoided. How much speed is gained by this depends upon what your script is doing.

I have been looking at your script and think you might also benefit by using lists and vectors to hold all of your car_### variables. Script-fu does not using any fancy symbol lookups for local variables (the theory being that you will typically only have a few) and so when you have hundreds of local variables (such as car_0 through car_188), it might have to traverse the entire list of variable assignments every time it needs to find or change a variable's value. (Script-fu does optimize lookups for global variables, since there can be expected to be thousands of those.)

By using lists for your car_### strings, you can use 'map' and 'apply' which will simplify some of your code (though maybe not improve its speed much). You can then convert the lists to vectors and use 'vector-ref' which I suspect would be faster than your current approach which requires linear searches of local variable bindings.

Here is some of the re-working of your code that I have done. It should give you an idea of what I mean (of course, the 'define' statements would be replaced with 'let' statements). I haven't reached the part of your code that actually places the characters, but it looks as though converting 'car_set' and the 'hauteur' and 'largeur' lists from lists to vectors would address what you are doing. If you decide to take this approach, be aware that I have used a string comprising the space character (" ") instead of the empty string ("") in 'car_set'; though I treat the space as an empty string when computing its width and height.

I normally wouldn't post such incomplete code but I probably won't be able to do anything further with it until after the holiday.
(define car_set
  (case rendu
    ((1) (map (lambda (ch) (string (integer->char ch)))
           (string->list (string-append
             "w12346789abcdmefghilnkzv5jw12346789abcdmefghilnkzv5jw12346789ab"
             "cdmefghilnkzv5jw12346789abcdmefghilnkzv5jw12346789abcdmefghilnk"
             "zv5jw12346789abcdmefghilnkzv5jw12346789abcdmefghilnkzv5jw123467" ))))
    ((2) (map (lambda (ch) (string (integer->char ch)))
           '(#x21 #x22 #x23 #x24 #x25 #x26 #x27 #x28 #x29 #x2a #x2b #x2c #x2d
             #x2e #x2f #x30 #x31 #x32 #x33 #x34 #x35 #x36 #x37 #x38 #x39 #x3a
             #x3b #x3c #x3d #x3e #x3f #x40 #x41 #x42 #x43 #x44 #x45 #x46 #x47
             #x48 #x49 #x4a #x4b #x4c #x4d #x4e #x4f #x50 #x51 #x52 #x53 #x54
             #x55 #x56 #x57 #x58 #x59 #x5a #x5b #x5c #x5d #x5e #x5f #x60 #x61
             #x62 #x63 #x64 #x65 #x66 #x67 #x68 #x69 #x6a #x6b #x6c #x6d #x6e
             #x6f #x70 #x71 #x72 #x73 #x74 #x75 #x76 #x77 #x78 #x79 #x7a #x7b
             #x7c #x7d #x7e #x387 #x20AC #xB2 #xDB #xF4 #xCE #xCA #xB0 #x2248
             #xF7 #x2321 #x2320 #x2265 #x2264 #xB1 #x2261 #x2252 #x3B5 #x3C6
             #x221E #x3B4 #x3A9 #x3B8 #x3D5 #x3C4 #x3BC #x3C3 #x3A3 #x3C0
             #x3B3 #x3B2 #x3B1 #xBB #xAB #xA1 #xBC #xBD #xAC #xD4 #xBF #xBA
             #xAAA #xD1 #xF1 #xFA #xF3 #xED #xE1 #xAE #xC2 #xA5 #xA3 #xA2
             #xDC #xD6 #xFF #xF9 #xFB #xF2 #xF6 #x25B6 #xC6 #xE6 #xC9 #xC5
             #xC4 #xEC #xEE #xEF #xE8 #xEB #xEA  #xE7 #xE5 #xE0 #xE4 #xE2
             #xE9 #xFC #xC7 #x387 #x221A #x3A9r #x3F4 #x387 #x76 #x77 #x78
             #x79 #x7a #x7b #x7c #x7d #x7e #x21 )))
    ((3) (map (lambda (ch) (string (integer->char ch)))
           '(#x21 #x22 #x23 #x24 #x25 #x26 #x27 #x28 #x29 #x2a #x2b #x2c #x2d
             #x2e #x2f #x30 #x31 #x32 #x33 #x34 #x35 #x36 #x37 #x38 #x39 #x3a
             #x3b #x3c #x3d #x3e #x3f #x40 #x41 #x42 #x43 #x44 #x45 #x46 #x47
             #x48 #x49 #x4a #x4b #x4c #x4d #x4e #x4f #x50 #x51 #x52 #x53 #x54
             #x55 #x56 #x57 #x58 #x59 #x5a #x5b #x5c #x5d #x5e #x5f #x60 #x61
             #x62 #x63 #x64 #x65 #x66 #x67 #x68 #x69 #x6a #x6b #x6c #x6d #x6e
             #x6f #x70 #x71 #x72 #x73 #x74 #x75 #x76 #x77 #x78 #x79 #x7a #x7b
             #x7c #x7d #x7e #xc2a1 #xc2a2 #xc2a3 #xc2a4 #xc2a5 #xc2a6 #xc2a7
             #xc2a8 #xc2a9 #xc2aa #xc2ab #xc2ac #xc2ad #xc2ae #xc2af #xc2b0
             #xc2b1 #xc2b2 #xc2b3 #xc2b4 #xc2b5 #xc2b6 #xc2b7 #xc2b8 #xc2b9
             #xc2ba #xc2bb #xc2bc #xc2bd #xc2be #xc2bf #xc380 #xc381 #xc382
             #xc383 #xc384 #xc385 #xc386 #xc387 #xc388 #xc389 #xc38a #xc38b
             #xc38c #xc38d #xc38e #xc38f #xc390 #xc391 #xc392 #xc393 #xc394
             #xc395 #xc396 #xc397 #xc398 #xc399 #xc39a #xc39b #xc39c #xc39d
             #xc39e #xc39f #xc3a0 #xc3a1 #xc3a2 #xc3a3 #xc3a4 #xc3a5 #xc3a6
             #xc3a7 #xc3a8 #xc3a9 #xc3aa #xc3ab #xc3ac #xc3ad #xc3ae #xc3af
             #xc3b0 #xc3b1 #xc3b2 #xc3b3 #xc3b4 #xc3b5 #xc3b6 #xc3b7 #xc3b8
             #xc3b9 #xc3ba #xc3bb #xc3bc #xc3bd #xc3be #xc3bf )))
    ((4) (reverse (map string (string->list (string-append
           " $ : ; < = > ? [ \\ ] ^_ `{ | } ~ a b c d e f g h i j k l m n o"
           " p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 @ A B C D E F G H I J"
           " K L M N O P Q R S T U V W X Y Z : ; < = > ? [ \\ ] ^_ `{ | } ~ $ ")))))
    ((5) (map string (string->list (string-append
           " $ : ; < = > ? [ \\ ] ^_ `{ | } ~ a b c d e f g h i j k l m n o"
           " p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 @ A B C D E F G H I J K"
           " L M N O P Q R S T U V W X Y Z : ; < = > ? [ \\ ] ^_ `{ | } ~ $ " ))))))

(define sizes (map (lambda (c)
                     (gimp-text-get-extents-fontname (if (string=? c " ") "" c)
                                                     Taille_Police
                                                     PIXELS
                                                     Police ))
                   car_set ))
(define largeurs (map car sizes))
(define hauteurs (map cadr sizes))
(define max_largeur_dans_car_set (apply max largeurs))
(define max_hauteur_dans_car_set (apply max hauteurs))

(define sizes (map (lambda (c)
                     (gimp-text-get-extents-fontname c
                                                     Taille_Police
                                                     PIXELS
                                                     Police ))
                   (map string (string->list La_Phrase)) ))
(define largeurs_dans_la_phrase (map car sizes))
(define hauteurs_dans_la_phrase (map cadr sizes))
(define max_largeur_dans_la_phrase (apply max largeurs_dans_la_phrase))
(define max_hauteur_dans_la_phrase (apply max hauteurs-dans-la-phrase))

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: ascii
PostPosted: Sun Dec 22, 2013 5:01 pm  (#15) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
Bonjour,

@Saulgoode

Thank you for the reply and suggestions :tyspin :)

*****

UNDO

In my new script I deleted it and added this line (gimp-image-undo-disable xxxxx) . This greatly improves things :)

*****

lists to vectors

I will follow this advice and create things that look like this for UTF-8 :

(xxxxxx #(
(list #xE8, #xEF, #xEE , #xEC, #xC4, #xC5, #xC9, #xE6, #xC6, #x25B6 )
(list #xF6, #xF2, #xFB, #xF9, #xFF, #xD6, #xDC, #xA2, #xA3, #xA5 )
(list #xC2, #xAE, #xE1, #xED, #xF3, #xFA, #xF1, #xD1, #xAA, #xBA)
))


I'll see if it is faster, the work is not huge (I write a lot of scripts with OO.o spreadsheets and functions "text").

I'll make databases with 256 characters to avoid intermediate conversions (1 color = 1 character)

*****

Again thank you for the advice , I will make a new version of the script viewtopic.php?f=9&t=9341


Top
 Post subject: Re: ascii
PostPosted: Sun Dec 22, 2013 9:10 pm  (#16) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
@Saulgoode

Variables : Here, the principle that I will choose :

(define MyChars '(#x0021 #x0022 #x0023 #x0024 #x0025 #x0026 #x0027))
(define W_MyChars '(27 28 29 30 23 20 26)) ; determination using a loop
(define H_MyChars '(30 32 33 30 31 32 33)) ; determination using a loop

The characteristics of the character number 3 are :
(list-ref MyChars 2) ; UTF-8
(list-ref W_MyChars 2) ; width
(list-ref H_MyChars 2) ; height

:tyspin


Top
 Post subject: Re: ascii
PostPosted: Mon Dec 23, 2013 1:13 pm  (#17) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14728
Location: USA
Excellent script Sam! :)
Thanks.

Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: ascii
PostPosted: Mon Dec 23, 2013 3:36 pm  (#18) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
samj wrote:
The characteristics of the character number 3 are :
(list-ref MyChars 2) ; UTF-8
(list-ref W_MyChars 2) ; width
(list-ref H_MyChars 2) ; height

Instead of using list-ref, I'd suggest converting your lists to vectors and using vector-ref.

Elements in a vector are stored in sequential memory location so performing a (vector-ref my-vec 100), as an example, can be accomplished by calculating the offset as 100 times the size of an element. Whereas performing (list-ref my-lis 100) requires that the interpreter "fetch" each of the first 99 elements in order to get to the 100th.

Lists are convenient when you know you have to access all of the elements -- for example if you are getting the character sizes of each character or finding the maximum value of their widths -- but when you need to randomly access the elements then you should use a vector.

From a speed standpoint, converting from a list to vector only takes about as long as two or three 'list-ref' calls, so it is well worth converting your lists.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: ascii
PostPosted: Mon Dec 23, 2013 6:44 pm  (#19) 
Offline
GimpChat Member

Joined: May 09, 2012
Posts: 914
Bonjour,

:tyspin Rod , :tyspin Saulgoode

Here is a new version of the script-fu that uses lists of characters (256 characters per list).
The script is in the archive message : viewtopic.php?f=9&t=9341&p=121326#p121326
It is always very slow (iterations are causing the problem).
Renderings are different from version 1.
Access to an RGB image by : Filters > Render > QWERTY 256 ...
Each character is positioned in size to the center of the rectangle color.

Merry Christmas

Edit 20131224 : New Version


Attachments:
textes_002.png
textes_002.png [ 255.04 KiB | Viewed 2202 times ]
composition.png
composition.png [ 327.15 KiB | Viewed 2202 times ]
Top
Post new topic Reply to topic  [ 19 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Best recommendation for terminal art ("ascii art") from image?

4



* Login  



Powered by phpBB3 © phpBB Group