Difference between revisions of "Text Images"

From Publication Station
Line 39: Line 39:
=Sessions=
=Sessions=
==Day 1 - Tue 23Jan==
==Day 1 - Tue 23Jan==
Pad: https://pad.pzimediadesign.nl/p/Excelfie
===Excelfie===
===Excelfie===
http://luciadossin.net/excelfie.html  
http://luciadossin.net/excelfie.html  
Line 123: Line 125:
===Exercise: a text-based image===
===Exercise: a text-based image===
Create a piece of typewriter art or ASCII art.
Create a piece of typewriter art or ASCII art.


==Day 2 - Wed 24Jan ==  
==Day 2 - Wed 24Jan ==  

Revision as of 10:23, 23 January 2018

Text Images

Group: WDK17-MHP-El2

Dates: 22Jan-2Feb. Tuesday - Friday. 13:00-16:00.

Room: BL -1.3 (BL 0.3 on Wed)


Description

The following elective will be based on the project Excelfie by design Lucia Dossin, where selfie (images), captured by a digital camera are converted onto plain-text files (ASCII-art). In these text-based images, the sequence of pixels of the captured images is mapped onto corresponding text characters, in order to create text-based rendition of the original bit map image.

3excelfie-derivation1.png
Excelfie at Zinecamp 2017

Announcement text

What are digital (bit-map) images? In their simpler form nothing more but sequence of pixels, each with its color value, organized into lines and rows. Such form of representing image information is uncannily similar to how text is represented digitally: a line-by-line sequence of characters, each with its corresponding value (code point). Can this similarity be used to transform pixel-based images into similar looking images made solely by text? And what happens when we reverse the process and try to get the text-based images into pixels using Optical Character Recognition software?


Material

We will work towards the implementation of the Excelfie in the Publication Station, for which we'll use:

  • raspberry Pi
  • camera (webcam)
  • LCD screen (HDMI input)
  • speakers (from action)
  • typewriter

Pad: https://pad.pzimediadesign.nl/p/Excelfie

Raspberry Pi software

  • Ascii art: figlet cowsay jp2a hasciicam
  • imaging: imagemagick fbi
  • audio: espeak
  • editor: nano

Sessions

Day 1 - Tue 23Jan

Pad: https://pad.pzimediadesign.nl/p/Excelfie

Excelfie

http://luciadossin.net/excelfie.html

What is happeningin this work?

http://luciadossin.net/_/img/excelfie/excelfie-derivation1-zinecamp-day2-3-silvio-lorusso.jpg

Typewriter Art

TypewriterArt.jpg

Download PDF

Typewritermanual.jpg Newspaper.jpeg



ASCII encoding

USASCII code chart.png

{{#widget:Youtube|id=MijmeoH9LT4}}



ASCII Art

 _______________
< ASCII??ART??? >
 ---------------
        \   ^__^
         \  (xx)\_______
            (__)\       )\/\
             U  ||----w |
                ||     ||

ASCII art is text art created with ASCII, a protocol established by the American National Standards Institute (ANSI), which is America's representative to the International Organization for Standardization (IOS). ASCII art uses ASCII text characters to produce images. The emoticon, an element of text messaging and email, is an example of ASCII art at its most popular and functional. [1]

Ascii Art as an idea coalesced into existence bceause people

wanted more. They wanted more than just your standard Hercules display Atari or your Monochrome Commodore 64. To meet this demand, one singular artist, whose name is lost to the annals of history decided to take the plunge. Instead of text, he (or she) had the ingenuity to use the characters /, \, |, -, _ and whatever else came to mind to create words. An amazing idea. [2]


Plain-text

Plain-text files Binary files
Each byte (8bits sequence) represents one ASCII character there is no one-to-one mapping between bytes and characters
Do not include any formatting information: only text Can have all sorts of formatting, like a Word doc, PDF, or image
are read/written with plain-text editors; or less cat commands data can be interpreted by supporting programs, but will show up as garbled text in a text need specific applications, depending on the file, i.e. Word for .doc. PDF-viewer for PDF
Are less likely to become corrupted, a small error shows up as a typo A small error may make it unreadable
common file formats: ?? common file formats: ??

Exercise: a text-based image

Create a piece of typewriter art or ASCII art.

Day 2 - Wed 24Jan

UNIX

  • it was time-sharing system, allowing for mutiples users to login to the machine ssh username@machineIP
  • included the shell: a program which performs command line interpretation
    • whoaim
    • pwd print working directory - where am I?
    • date
    • users print the user names of users currently logged in to the current host
    • history commands' history
  • tree-structured file system
    • tree ~/ list contents of home (~ == /home/username ) in a tree-like format
    • ls ~ list files and directories in your user home ( ~ == /home/username )
    • ls . list files and directories in current directory ( . == current dir )
    • ls ../ list files and directories in parent directory ( . == current dir )
    • ls foo/ list files and directories in child foo/ directory
    • ls / list files and directories in root ( / == root )
  • every thing is a file
    • ls -R / > /dev/dsp file-system as sound

Others emerged from the development and use of the system and crystallized into the Unix Philosophy:

  • Write programs that do one thing and one thing well
    • ls lists files in a directory
    • cat outputs content of file
    • wc counts number of words in file
  • Write programs that work together
    • echo "hello UNIX world" | sed 's/o/0/g' | sed 's/e/3/g' | sed 's/l/1/g' | figlet
  • Write programs that handle text streams, because that is a universal interface
    • man -a intro | espeak Linux introduction to user commands.


Essential commands

For a PDF with Unix/Linux Command Reference - download the following link

System Info

date – Show the current date and time
cal – Show this month's calendar
uptime – Show current uptime
w – Display who is online
whoami – Who you are logged in as
finger user – Display information about user
uname -a – Show kernel information
cat /proc/cpuinfo – CPU information
cat /proc/meminfo – Memory information
df -h – Show disk usage
du – Show directory space usage
free – Show memory and swap usage

Keyboard Shortcuts

Enter – Run the command
Up Arrow – Show the previous command
Ctrl + R – Allows you to type a part of the command you're looking for and finds it

Ctrl + Z – Stops the current command, resume with fg in the foreground or bg in the background
Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line
Ctrl + L – Clear the screen

command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow
!! – Repeats the last command
command !$ – Repeats the last argument of the previous command
Esc + . (a period) – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command

Ctrl + A – Return to the start of the command you're typing
Ctrl + E – Go to the end of the command you're typing
Ctrl + U – Cut everything before the cursor to a special clipboard, erases the whole line
Ctrl + K – Cut everything after the cursor to a special clipboard
Ctrl + Y – Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
Ctrl + T – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)
Ctrl + W – Delete the word / argument left of the cursor in the current line

Ctrl + D – Log out of current session, similar to exit

Learn more about Commands/programs

apropos subject – List manual pages for subject
man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes

whereis app – Show possible locations of app
which app – Show which app will be run by default; it shows the full path

File Commands

ls – Directory listing
ls -l – List files in current directory using long format
ls -laC – List all files in current directory in long format and display in columns
ls -F – List files in current directory and indicate the file type
ls -al – Formatted listing with hidden files

cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory

rm name – Remove a file or directory called name
rm -r dir – Delete directory dir
rm -f file – Force remove file
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)

cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn't exist
cp file /home/dirname – Copy the filename called file to the /home/dirname directory

mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2

more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Output the first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines


SSH

ssh user@host – Connect to host as user
ssh -p port user@host – Connect to host on port port as user
ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login


meta characters

Meta Characters are characters that have special meaning within the terminal

  • ~ the tilde stands for the user's home. cd ~/ change directory to home
  • . dot stands for this directory. ls . list this directory
  • .. dot dot stands for the parent directory to this directory. cp myfile.jpg .. copy myfile.jpg to the parent directory
  • * asterisk is a wildcards which represents zero or more characters ls P*.jpg will list all the files, in the current directory, that begin with P and end with .jpg
  • \ backslash it is a literal character. It escape the meta value of the meta-characters and display them only as literal characters. echo Foo \* will output Foo * If \ wasn't there it would output all the files in that directory.


pipes, write to & append

A pipes (" | ") sends the output of one program to the input of another program.

echo "my sentence"| wc the echoed sentence "my sentence" is pipped into the program wc which counts the number of lines, words, and characters


> Writes the output of a command to a file, rather than to print on terminal.

df > df_output.txt redirect the content of man dfM to a file called df_output.txt

If the said file doesn't exit it will create it, if it already exists it will overwrite its contents/


>> appends the output of a command to a file, without overwriting the original file. echo 'also add this' >> df_output.txt will add 'also add this' to the contents of df_output.txt


Proto social network tools

wall - write a message to all users echo "how is the weather in your terminal?|wall"


write enables you to chat with another user. You can find who is logged in and to which terminal with the who command.

Once you got the name and tty of whom you want to chat with you can start writing to him/her write username tty


ASCII Art tools

  • figlet - display large characters made up of ordinary screen characters echo "say something big"|figlet
  • coway - cowsay/cowthink - configurable speaking/thinking cow echo "look,I am a cow"|figlet
  • jp2a - converts JPEG images to ASCII

jp2a image.jpg


Day 3 - Wed 25Jan: Bitmap

Software:

  • imagemagick: a command-line program for image manipulation. We will be using it mainly through the command convert which convert 1 image onto another.
  • fbi (frame-buffer image): displays the specified file(s) on the linux console using the framebuffer device


You probably have heard before that bitmap images are grids of pixels[3] , where

  • resolution: is the number of horizontal and vertical pixels. E.g. 1920x1080 is 1920 pixels wide and 1080 high
  • color depth: the number of bits used to indicate the color of a single pixel

{{#widget:Youtube|id=06OHflWNCOE}}

converting resolution

to 100px wide

convert myimage.jpg -resize 100x output.jpg 

to 100px long

convert myimage.jpg -resize 100x output.jpg 

to 100x100px (image will loose its proportion; hence the "!" so imagemagick is sure that you wanna do that:)

convert myimage.jpg -resize 100x100! output.jpg 

converting color (bit depth)

convert an image into monochrome (1 bit depth) image: 2color values (b/w)

convert myimage.jpg -colorspace gray -depth 1 out.png

(2 bit depth) image: 4 color values

convert myimage.jpg -colorspace gray -depth 2 out.png

(3 bit depth) image: 8 color values

convert myimage.jpg -colorspace gray -depth 3 out.png

(4 bit depth) image: 16 color values

convert myimage.jpg -colorspace gray -depth 4 out.png

(8 bit depth) image: 256 color values

convert myimage.jpg -colorspace gray -depth 4 out.png


How can we be certain about this? How do can we see the grid that forms a bitmap image?

  • magnify any digital screen
  • a Plain-text bitmap: where you can read each pixel: X PixMap (XPM)

X PixMap (XPM) is a plain-text bitmap image format, where each color is assigned a character, which is mapped onto the text space.

convert myimage.jpg out.xpm


What can be done with this?

  • draw by writing?
  • color separation?
  • ASCII art - by search and replacing characters


/* XPM */
static char *output[] = {
/* columns rows colors chars-per-pixel */
"50 73 2 1 ",
"  c black",
". c white",
/* pixels */
"                                                  ",
"                                                  ",
"                                                  ",
"                                                  ",
"               ................                   ",
"           ......   . .. . . .......              ",
"          .. .           .         ...            ",
"         . .   .. .            .     ..           ",
"        .. . .    .    .  .     .     .           ",
"        .   .      .    .   .    . .  ..          ",
"        .  .        .  .       .    . .           ",
"        ...          ..      .       ..           ",
"       ...              .. .         ...          ",
"        ..                            .           ",
"        .                             ..          ",
"        ..                            .           ",
"        .                             ..          ",
"       ...      .                     .           ",
"        .     .                       .           ",
"       ..                             .           ",
"       ..  .    .                   . .           ",
"        .    .                        .           ",
"       ..  .  .....                   .           ",
"        .    ..   ..                  .           ",
"        .   .       ..            .   .           ",
"       .  ..         .               ..           ",
"       .. .    .     .            .....           ",
"          .   ...     .          .    .           ",
"       .  .   ....   ..          .    ..          ",
"       . ..   ....              .      .          ",
"        . .          .          .    ....         ",
"       .  .          .          ..   ...          ",
"          .          .           .    ..          ",
"       ..  .        .            .     .          ",
"       .   .       ..            .    .           ",
"       .    ..   ..               ..  ..          ",
"       ..     ...                  ... .          ",
"      ..                               ..         ",
"      .                  .  .       .   .         ",
"     .  .  ..                           .         ",
"     .  . ....                     .    .         ",
"     .    ..  ...   .              ..  ..         ",
"     .. .  ..  .....   . ..   .   ...  .          ",
"      .    ... ..  ....          ....  .          ",
"       .    .....   ......     ...... .           ",
"       ..    . ..... .  ......... ... .           ",
"        ..   .........   .. .  ...... .           ",
"         .    ..   ....................           ",
"         .     ..   . ............... .           ",
"          .     .. ..   ............. .           ",
"           .      ..    .   .  .....  .           ",
"           ...  .  ...  .  .. ......  .           ",
"            ... .    .............    .           ",
"              ..   .       ..          .          ",
"               ...   ..                           ",
"                 ...     .    .       ..          ",
"                   ..            .    .           ",
"                     ..               .           ",
"                       ....          ..           ",
"                          .....  ....             ",
"                              .....               ",
"                                                  ",
"                                     .            ",
"                   ..   .            ...          ",
"        ...  .. ..  ... .. .. ...... ...          ",
"        ............................  ..          ",
"        ...... ................. ...  .           ",
"        ......  ... ... ..... .... .. .           ",
"        ..                                        ",
"        .                                         ",
"                                                  ",
"                                                  ",
"                                                  "
};



{{#widget:Youtube|id=UBX2QQHlQ_I}}


Day 4 - Friday 26Jan: Bitmap outside the screen

The challenge for today is how to do we get out bitmap/ascii-art/plain-text image out from the screen and materialize it into something.

  • a silk screen print ?
  • a sound composition
  • ?





Capturing image

  • fswebcam/xawtv: capture camera

fswebcam: no visual feedback

fswebcam --device  /dev/video0 --no-banner --save test.jpg

mpv: screen shot by typing "s"

mpv /dev/video0



Capturing camera input

Assembling it all

Pi cheat sheet

display image in Terminal 1 with

fbi capture.jpg -T 1

display video with oxmplayer

oxmplayer http://oooooooooo.io/images/2/21/RF-enblanco-1.mp4


picam; but Picam seems difficult to work with other software - should try webcam

raspistill -o test.jpg 

There is a python module for it: https://pzwiki.wdka.nl/mediadesign/PiCam


references

  1. ‘ASCII ART’. n.d. Accessed 2 January 2018. http://artscene.textfiles.com/information/ascii-newmedia.txt
  2. Necromancer. 1998. ‘History of the PC Ascii Scene’. March 1998. http://artscene.textfiles.com/history/essays/pcascii.txt
  3. Bourke, Paul. n.d. ‘A Beginners Guide to Bitmaps’. Accessed 2 January 2018. http://paulbourke.net/dataformats/bitmaps/.