Lainzine Vol. 1
Lainzine Vol. 1
Issue 1
Published 20 April 2015
Contents
Editors' Notes
For Lainzine #1
Noise
Gopher Protocol
Recommended Reading
Art of the Glitch
Introduction to Cryptography
Word Search
Where Do I Start?
FreeBSD Guide for Newbs and Dummies
Youtube Proxy
Structure-based ASCII Art
1
1
2
2
6
7
12
15
16
18
20
23
Colophon
Created by the good people of Lainchan from
all around the world.
https://lainchan.org
Released in good faith and for free to the public
domain.
0, $0, 0
Staff
Editors
Typesetters
In
Waking
All
Known
Unconscious
Reality
Atrophies
Linger
And
It
Nihilates
Editors' Notes
For Lainzine #1
junk
Kalyx
Tilde
Noise
Gopher Protocol
Parts needed
Piezo disk,
scraps of wire,
audio jack socket,
something to amplify and listen with,
soldering iron and solder (optional),
something to secure the mic in place (optional).
Instructions
Sound doesnt only travel through the air. A
contact microphone picks up the sounds from
inside of solid objects. You can shout as loud as
you want, the contact mic cant hear you. But if
you stick it to a wooden board and scrape a nail
across it you can hear the sound of the wood
grain resonating, crushing the piezo crystals
and generating a small electric field.
Doesnt work? Make sure your contact mic
is connected to an amplifier of some sort, PC
speakers will work if theyre turned all the way
up. Disconnect the wires and try them the other
way round, then try the first way again.
The Protocol
The simplicity of the gopher protocol is evident
from the mere fifteen pages of RFC 1436 the
Network Working Groups 1993 document on
implementing gopher servers and clients. For
comparison, FTPs RFC 765 is 68 pages, and
HTTP/1.1 is represented by the 176-page 2616.
A reader with even a cursory understanding of
TCP/IP can learn the core of gopher over a cup
of coffee.
Learning the complete internals is better
suited to the RFC and is left as an exercise to
the reader, but well go ahead and write a couple of one-line scripts that handle the majority
of the available interactions. All that you need
to know is that the default port is 70.
Script 1: Ask a gopher server to list its
contents
First, the client opens a connection to the server, for the example: sdf.org on port 70 Then, the
client sends CLRF to the server to request a directory listing. CLRF refers to Carriage Return
Line Feed, but on most systems will be handled
by the simple newline character: \n. To do this,
use the netcat utility which is a command line
program for establishing raw network connections. This very powerful tool can be used for
exploring remote hosts and even listening as a
server itself.
Personal GOPHERSPACE\t\tnull.host\t1
telnet://sdf.org\t\tnull.host\t1
i\t\tnull.host\t1
1SDF Member PHLOGOSPHERE (151 directories)\t/phlogs/\tsdf.org\t70
1SDF Member GOPHERSPACE (2334 directories)\t/maps/\tsdf.org\t70
1SDF Frequently Asked Questions (FAQ)\t/sdf/faq/\tsdf.org\t70
1SDF Accredited University Courses\t/sdf/classes/\tsdf.org\t70
1Software and Documentation for various computers\t/computers\tsdf.org\t70
7GopherSpace SEARCH Engine\t/v2/vs\tgopher.floodgap.com\t70
1Floodgaps GOPHERSPACE\t/\tgopher.floodgap.com\t70
1NetBSD Distribution Mirror\t/NetBSD/\tsdf.org\t70
i______________________________________________________________________\t\tnull.host\t1
i
1CHAT
1DIALUP
1EMAIL
1GAMES
1GOPHER
1MDNS
\t/sdf/faq/MISC\tsdf.org\t70
1MOTD
1MYSQL
1TEACH
1UNIX
1USENET
1VHOST
1WEB
i______________________________________________________________________\t\tnull.host\t1
i
The Servers
2 http://gopher.floodgap.com/overbite/
3 gopher://gopher.floodgap.com/
4
ent-server communications, read and implement specifications, and can have a complete
product within a fairly short time. For writing
the server in C, you may find Beejs Guide to
Network Programming a very helpful reference.
The Charms
As Ive repeatedly emphasized, the protocol is very simplistic. Perhaps it comes off as
anachronistic in a web 2.0 world of social media, e-commerce, and spookily addictive flash
games.4 Unfortunately, I think its easy to write
gopher off as something impractical, and only
of interest to those enthusiastic about minimal Linux installs. I would argue though
that its contraints give it a characteristic wholly
lacking in the modern web: predictability. I enjoy shopping online, posting on imageboards,
and interacting with dynamic graphs, but when
I simply want to access information, all those
individual choices regarding styling and formatting mean that I cant rely on any consistent experience.
Scripting, scraping, and parsing are basic
operations to perform on data sources, but
are severely limited by the design choices of
web designers. Even if a particular website has
a thought out design that allows elements to
sanely referenced, it is still a unique entity to
learn and then trust not to change and break
whatever you had been doing with it.
With the gopher, you know what are getting: plain text. Its a beautiful format that
worked before PHP and ASP.NET and Javascript
and w3schools and works just as nicely today. If
the strength of the world wide web is its freedom and support for myriad behaviors, gophers
is in restricting itself to perform its few tasks efficiently, structurally, and uniformly.
4 http://dagobah.net/flash/Flandre_Game.
swf
5
Recommended Reading
Seeking an Understanding
Introduction
The analytics of the art world and art itself has
always been a grey area. How can one critique
something non-objective? When considering
new mediums, who is to say who else is an expert? The field of digital art is something relatively new and is one that has many interesting
facets and faces. Delving further into one of
these sides, the oddly beautiful realm of glitch
art is one of these parts of the art world that is
difficult to critique. When the purpose of the art
form is to destroy something, can one judge its
beauty? Does it exist as art at all? To understand
these questions, one must look at the roots of
the art style. It will be questioned if it can exist
as a style at all, given the methods and practices
employed are accurate under the term, glitch.
7
An Existential Crisis
Rosa Menkman does in fact, associate the definition in a similar way that has been laid out
previously, as she states here: The glitch has no
solid form or state through time; it is often perceived as an unexpected and abnormal mode
of operandi, a break from (one of) the many
flows (of expectations) within a technological
system. (Menkman, 2009) Though she scopes
it to a tighter view of a technological system,
11
References
Funda S. T. (2012). Glint: Audiovisual glitches. Leonardo, 45(3), 296-297. doi:10.1162/LEON_a_00383
Gross, S. (2013). Glitch, please: Datamoshing as
a medium-specific application of digital material.
175-184. doi:10.1145/2513506.2513525
Krapp, P., & Ebooks Corporation. (2011). Noise
channels: Glitch and error in digital culture. Minneapolis: University of Minnesota Press.
Menkmen, R. (2009) Glitch studies manifesto Retrieved from http://rosa-menkman.blogspot.nl/
Terence D. (2006). Controller: Artists crack the
game code. Winnipeg: Arts Manitoba Publications Inc.
Introduction to Cryptography
by peeping_Tom
Cryptography is the practice of secret writing
where information is hidden from adversaries.
First used by the military, it is now used in every
facet of our lives, from simple web browsing to
paying bills, talking to your friends, and much
more. With examples, I will show you the basics
of cryptography and how all encryption is crackable. Cryptography is a wide topic that takes
much mathematical ingenuity, so I sliced it into
two parts. In this first part, we will explore the
origins of cryptography and some simple ciphers
you might use with your buddies online or off.
This article is mostly theoretical but I encourage
you to put your newly acquired knowledge to
practice by coding working examples.
Encryption is based on the idea that cracking takes time, and that the more time it takes
to crack, the better. Think of bike locks. We
know they do not offer perfect security, but
we rely on the idea that it will take bad people
more time to break them than it will take for
someone on the street to stop them. Cryptography follows a similar mindset.
The simplest cipher (method of encryption
or decryption) is the substitution cipher. As its
name implies, this cipher substitutes letters.
The most famous substitution cipher is the Caesar cipher in which all the letters are replaced
by their neighbors in the alphabet a few places
over to the right or left. Imagine if A became B,
B became C, C became D, and so on until we got
to Z, which became A. This is a basic example of
the Caesar cipher.
Another interesting substitution cipher is
the Pigpen cipher. Used primarily by Freemasons, this cipher substitutes letters for shapes
and dots.
Every substitution cipher works on the
same simple idea, substitution of letters for
some other symbols. The way anyone would go
12
about cracking this cipher is through a checking process: look for common words in the
message's language, then substitute in reverse.
For instance, you would look for repeated sets
of 3 letters, expect them to be the, then carry
out the necessary substition on the rest of the
ciphertext, i.e., the encrypted text.
Extend this process to letters, rather than
for words, and you get something called frequency analysis. This method cracks any substitution cipher if you know the language of the
plaintext (original message). To crack any substitution cipher you start with the fingerprint
of the plaintext's language, and then look at a
frequency analysis of symbols in the ciphertext
to see the rules for substitution.
The fingerprint is simply a frequency of
occurrence of some letters in a language. For
This property is unique to the English language, however all languages have a common
letter use property. To evade this, people built
the polyalphabetic cipher.
The polyalphabetic cipher works on the
same idea as Caesar cipher, making multiple
shift ciphers of the same plaintext. First, a codeword is established between the parties. The
codeword denotes the shift ciphers, for example the codeword snake means that there are
5 shift ciphers each with their own designated
shift. The first cipher substitutes the first A to
occur with S, B with T, the second A with
N, B with O, and so on. Now that we have
5 shift ciphers with different letter shifts, how
do we apply them to the plaintext? We repeat
the ciphers in order. The first cipher on the
first/sixth/eleventh/ letter, second cipher on
13
ZDXWWW
HTSVTV
YHJYEQ
CKHVEX
QXAUIP
CRWVHI
EXFIPJ
EJKAWO
RRYYEG
TDLCQT
VXYVCS
PXZQIJ
FRNTQW
KICASQ
FECIFE
EXNCGA
HZBSIZ
WOGAAZ
JIUWYH
AJVWRT
IOUQTP
WSNZIP
GGQVRF
IRZDYS
OUVVON
COVWMJ
ACAKRD
ZSGXGH
PXPKIY
FHZCIB
RBYJFZ
GCNEVR
UZOJHL
OZKIIB
YTYCTI
URMZHI
EWLGGR
AIRCWI
LMBLYB
DWHPER
VIQGBK
BAZSTN
JZTLBC
BZXQDQ
UCVXTW
SBDCDC
UBSRUJ
IJCWHF
JKMFXI
YLGDYJ
DGGIAK
YKPQMK
PCGVJX
HGAAPR
GTTSSE
RERYWE
lainchan as our codeword, we can do frequency analysis on every 8th letter in WEBFCSLYZVMYCPN and find out all 8 shift ciphers that way,
or in English, we can find the codeword. If we
don't know the length of the codeword, and we
saw flat distribution of frequency analysis, then
we would try frequency analysis of every (1+KN)
th letter, where K ranges from 0 to . Since we
don't know N (length of the codeword), we will
assume it's 1 letter long, then we will assume its
2 letters long, and so on. We do this until we
get the original, readable plaintext. This process
can be automated with computers, which easily
make it take less time. Longer codewords result
in stronger ciphers since the cracker has to assume all possible codewords shorter than the
real codeword.
This is only possible because the codeword
is repeating, but what if it wasn't repeating?
What if we had a codeword as long as the plaintext itself? This is called a one-time pad. The
codeword lainzine can be seen as a list of numbers by which the shift is occurring in each shift
cipher (L = 11, A = 0, I = 8, and so on). Also
note that having a random number sequence
for codeword is much more secure than having
a word.
A multiple-shift cipher with random shifts
on each letter that is as long as the ciphertext is
unbreakable by frequency analysis because the
shifts don't repeat. The only way to break this
one-time pad is brute force.
Bruteforce, in layman's terms, is trying out
every possible combination. Since we know that
14
Word Search
Y T P S Y C H E T J C D U K D E A T H
Z A Y R O R M A E R D D U A B N M S H
S N U V V O L I V I A S A A Q J I O D
V A P Y Y Y H S B N G F I O F S Z R I
D B D R T H V V A N B H N S A U U A I
J I C I I C D X K V S I E N F O K T R
N H T R L S T U I O A L I B I I I S I
V C J O A C J W T L Z H Z E O C A T E
U A I F E P Z I A E C V R S K S R H I
O T Q J R B H R C A C E U M V N I G M
Z H O X C S U N M S Y R M R H O S I A
S R B B O K E X B A B R J I P C U N S
P H G Y A I E N L D E I L O C B P K A
H S L W T S O X R S R K H C H U Z J M
Y O I N U F Y I N O I T R O T S I D N
S R E E T G E F J Z A E E J I V A N B
N S D X Y W K K K C A L B N I N E M M
H U S K J M M A M V V Y R O M E M E Z
E V E F M K K W I R E D L M T M O E G
15
Where Do I Start?
A primer to offensive security
by Hash_Value
Every computer forum you find is flooded with
questions about hacking. When lainchan makes
it big, we are going to get these questions a lot
on /cyb/, so point them to this guide when they
ask!
Hacking has a lot of definitions depending
on who you ask, but let's go straight to offensive security (which I know is what you all want
anyway). First, you will need a basic but strong
foundation in programming, networking and
operating systems.
To get a strong foundation in programming/
scripting/coding you need to practice! I don't
mean following along with easy college intro to
programming course either. You need to build
something useful. It doesn't have to be complex,
just useful. Just run a web search every time you
have a problem. Start off with some simple syntax and then go use that to solve problems and
get better and go bigger. A lot of the time, you
just need to know simple scripting languages
such as python and ruby. If you plan on building
something big, use C or C++. Personally, I always
recommend this project based approach. That
16
First the age old question: Should I download a hacking specific distro? The truth of the
matter is, you don't really need too. You can
download all the tools into any distro of Linux
from the web, so the only real reason you would
want to download a pentesting distro is the fact
all the tools are the there and you don't have
to waste time finding all the dependencies for
metasploit. So my advice for you is this: Download a pentester, but don't install it as your main
distro. Yes there are some distros that can serve
both purposes, but I wouldn't recommend using them that way.
Alright, you got your weapons and the
skill to wield them, now all you need is a dojo.
"But why can't I attack Shitbook or [insert other
mainstream site here]? I'm glad you asked! It's
because that would be illegal, and you would
get caught. I recommend visualizing everything,
because it's cheaper, if you fauurrk something
up you can revert back to a snapshot, and it's
cheaper. Now, many recommend VMware. It
costs a lot of money, and I won't lie, VMware is
really well made. However, Virtual Box does the
same thing at a price you can't beat, free (as in
both free beer and freedom).
Well, this was just a starters guide, rough
and dirty. I do full time college and work, so opportunities to shitpost on the web are few and
far between. I wanted to do a starters guide on
BeEF (browser exploitation framework) as well,
but it was going to take longer than I first suspected. Ill try for that next time, but no promises. If you want to talk to me, feel free to give
me something to research; I love to learn new
things. Chances are Im lurking in #lainchan on
freenode.
Q: Kali Linux?
A: Only liveboot, dont install it.
Q: Do I have to learn to code?
A: Tools can only go so far Anon.
Q: How do i hack Facebook?
A: Look into SET.
Q: What are the tools i need to hack X?
A:
Portscanning: nmap
Password cracking: hydra
Web app: Burbsuite is popular, but I like
w3af
General use: Metasploit is an all-in-one tool
which is pretty much perfect for everything
Social engineering: payphone/SET
Q: Where can I get hands-on experience?
A: Places to practice hacking:
https://www.hackthissite.org
https://www.hackthis.co.uk
https://pentesterlab.com
https://hack.me
https://community.rapid7.com/docs/DOC1875
Networking help and tutorials:
https://www.netacad.com/web/about-us/
cisco-packet-tracer
https://www.youtube.com/user/danscourses
Very good resources and general use education:
http://pastebin.com/cRYvK4jb
https://udacity.com
https://www.youtube.com/user/thenewboston
FAQ
Exploit development:
Q: Im just a poor boy who has to steal wifi.
http://www.myne-us.com/2010/08/fromA: Get Reaver or, if you're using Windows, Cain.
0x90-to-0x4c454554-journey-into.html
4
17
and Dummies
18
Youtube Proxy1
The following script runs on vanilla Node.js and requires an executable of youtube-dl. If it's not
located in the same directory as the script, change the line
var job = spawn('./youtube-dl', args);
to something like
var job = spawn('~/path/to/youtube-dl', args);
Usage examples
Download a video in MP4 from YouTube:
http://example.com:8567/https://www.youtube.com/watch?v=XXXXXXX
Currently, the headers it sets are designed for downloading. You can change them so that it
plays in your browser, but I mainly wanted it for downloading videos on my phone and Firefox on
Android wouldn't download it without them.
Also, be aware that it needs a downloads directory that is not created automatically.
var spawn = require('child_process').spawn,
fs
= require('fs'),
http
= require('http'),
mime
= require('mime');
= req.url.match(/\/(.*)\.(.*?)/),
format = m[2],
url
= m[1];
if (!/^.*\.[a-z0-9]{3,5}$/.test(req.url)) {
format = 'mp4';
url
= req.url.match(/\/(.*)/)[1];
}
var file
mimeType = mime.lookup(file),
args
21
function()
{ res.end(); });
22
Figure 1: Structure-based ASCII art generated by our method (the input is banquet of Figure 18). Characters were chosen from the set of
95 printable ASCII characters.
1 Introduction
Abstract
[email protected]
[email protected]
e-mail: [email protected]
e-mail:
23
(a)
(b)
(a)
(c)
(b)
(c)
2 Related Work
structure-based one, as the high text resolution is required for producing sufficient tone variety. On the other hand, structure-based
ASCII art utilizes the shape of characters to approximate the image
structure (Figure 2(c)), without mechanically following the pixel
values. To the extreme, smileys, such as :) and :(, are the simplest examples of structure-based ASCII art.
Existing computational methods can only handle tone-based ASCII
art, as its generation can be regarded as a dithering problem with
characters [Ulichney ]. OGrady and Rickard [2008] improved
such dithering process by reducing the mismatches bewteen character pixels and the reference image pixels. Nevertheless, high
text resolution is still required for a clear depiction. Note that
ASCII art gradually loses its stylishness (and approaches to standard halftone images) as its text resolution increases. In addition, as
the text screens of mobile devices are limited, the character-saving
structure-based ASCII art is more stylish and practical for commercial usage such as text-based advertisement. However, satisfactory
structure-based ASCII art is mostly created by hand. The major
challenge is the inability to depict the unlimited image content with
the limited character shapes and the restrictive placement of characters over the character grid.
To increase the chance of matching appropriate characters, artists
tolerate the misalignment between the characters and the reference
image structure (Figure 3(b)), and even intelligently deform the reference image (Figure 3(c)). In fact, shape matching in ASCII art application is a general pattern recognition problem. In real-world applications, such as optical character recognition (OCR) and ASCII
art, we need a metric to tolerate misalignment and also account for
the differences in transformation (translation, orientation and scaling). For instance, in recognizing the characters o and o during
the OCR, both scaling and translation count; while in recognizing
characters 6 and 9, the orientation counts. Unfortunately, existing shape similarity metrics are either alignment-sensitive [Wang
et al. 2004] or transformation-invariant [Mori et al. 2005; Belongie
et al. 2002; Arkin et al. 1991], and hence not applicable.
In this paper, we propose a novel method to generate structurebased ASCII art to capture the major structure of the reference image. Inspired by the two matching strategies employed by ASCII
artists, our method matches characters based on a novel alignmentinsensitive shape similarity metric and allows a constrained deformation of the reference image to increase the chance of character
matching. The proposed similarity metric tolerates the misalignment while it accounts for the differences in transformation. Given
an input and a target text resolution, we formulate the ASCII art
generation as an optimization by minimizing the shape dissimilarity and deformation. We demonstrate its effectiveness by several
convincing examples and a user study. Figure 1 shows the result
automatically obtained by our method.
3 Overview
An overview of our structure-based ASCII art generation is shown
in Figure 4. The basic input is a vector graphics containing only
polylines. A raster image can be converted to vector via vectorization. As the limited shapes and restrictive placement of text
characters may not be able to represent unlimited image content,
ASCII artists slightly deform the input to increase the chance of
character matching. So we mimic such deformation during optimization by iteratively adjusting the vertex positions of the input
polylines. Given the vector-based line art, we rasterize it and divide
the raster image into grid cells. Each cell is then best-matched with
a character based on the proposed alignment-insensitive shape similarity metric (Section 4). This completes one iteration of optimization, and the objective value, which composes of the deformation of
the vectorized picture (Section 5) and the dissimilarity between the
24
Vectorized polylines
Input
Deformed image
Result
Optimization
Figure 4: The overview of our framework.
(a)
O O 69
1
2
(b)
(a)
(c)
(b)
.
.
.
The key to best-match the content in a grid cell with a character is the shape similarity metric. It should tolerate misalignment
and, simultaneously, account for the differences in transformation
such as, position, orientation and scaling. Existing shape similarity metrics can be roughly classified into two extreme categories,
alignment-sensitive metrics and transformation-invariant metrics.
Misalignment Tolerance Misalignment is, in essence, a smallscale transformation. To tolerate misalignment, a histogram of a
log-polar diagram [Mori et al. 2005] is used as the basic building
25
Query
block of our shape descriptor (Figure 6(a)). This log-polar histogram measures the shape feature in a local neighborhood, covered
by a log-polar window. Its bins uniformly partition the local neighborhood in log-polar space. For each bin, the grayness of the shape
is accumulated and used as one component in the histogram. As
the bins are uniform in log-polar space, the histogram is more sensitive to the positions of nearby points than to those farther away.
Moreover, since only the sum of pixels within the same bin is relevant, it is inherently insensitive to small shape perturbations, which
leads to its misalignment tolerance nature. In other words, the degree of misalignment tolerance is implicitly defined in the log-polar
diagram. During the pixel summation, black pixel has a grayness
of 1 while the white one
is 0. The bin value h(k) of the k-th bin is
I(q), where q is the position
computed as h(k) =
(qp)bin(k)
of the current pixel; (q p) is the relative position to the center
of the log-polar window, p; I(q) returns the grayness at position q.
The lower sub-image in Figure 6(a) visualizes the feature vector h
with respect to p (the blue dot).
SSIM
RMSE
(after blurring)
(2)
(3)
(4)
P
A
1
P
r
B
A
Unlike the original transformationinvariance scheme in [Mori et al. 2005], we propose a novel sampling layout of log-polar diagrams in order to account for the transformation difference. The log-polar histogram can natively account
for orientation. The bin values change as the content rotates. To account for scaling, all log-polar histograms share the same scale. To
account for translation (or position), N points are regularly sampled
over the image in a grid layout (Figure 6(b)). Both the reference
image in a cell and the character image are sampled with the same
sampling pattern. For each sample point, a log-polar histogram is
measured. The feature vectors (histograms) of the sample points are
then concatenated to describe the shape, as shown in Figure 6(c).
The shape similarity between two shapes, S and S , is measured by
comparing their feature vectors in a point-by-point basis, given by
1
||hi hi ||,
M
Shape context
(1)
Transformation Awareness
DAISS (S, S ) =
Our metric
(b) Accessibility
(1)
iN
5 Optimization
Local Deformation Constraint The first term measures the local deformation of a line segment, in terms of orientation and scaling.
Consider the original line segment AB as deformed to A B in
Figure 8(a). As we allow global translation during the deformation,
the local deformation of line segment AB is measured in a relative
sense, as follows,
(2)
Vr (AB) = max
3 max{r, r }
min{r, r }
[0, ] is the angle between the original and the deformed line
segments. r and r denote the lengths of the original and deformed
26
(a) Iteration 0
E = 695.76
(b) Iteration 60
E = 425.33
Figure 10: Intermediate results during optimization. The input is Figure 18(s3).
(a)
(b)
where Ddeform = 1 when there is no deformation. Figure 9(c) visualizes Ddeform of the deformed image (Figure 9(b)) by color-coding
each line segment with lighter value indicating higher deformation,
and vice versa. As the objective function is computed on the basis of a character cell, the deformation value of a character cell j,
j
, is computed. All line segments intersecting the current
Ddeform
cell j are identified, as denoted by the set {Lj }. li is the length of
the i-th line segment Li (partial or whole) in {Lj } occupied by cell
j. Then, the deformation value of cell j is then computed as the
weighted average of deformation values of involved line segments,
(c)
Figure 9: The green and black lines indicate the original and deformed polylines respectively. The input is Figure 18(s3). (a) With
the local deformation constraint alone, the drift of circular windows
cannot be avoided. (b) With local and accessibility constraints, the
drift can be avoided. (c) Visualization of the deformation value of
each line segment in (b). For visualization purpose, the deformation
values are non-linearly mapped.
j
Ddeform
=
li
i{Lj }
i{Lj }
li
(5)
Objective Function
line segments. Parameters 1 , 2 , and 3 are the weights, and empirically set to values of 8/, 2/ min{Tw , Th }, and 0.5, respectively, in all the experiments. When there is no local deformation,
Dlocal = 1.
Accessibility Constraint The local deformation constraint alone
can only prevent the over-deformation in the local scale. It cannot avoid the over-deformation in a global scale, as demonstrated
in Figure 9(a). Three circular windows drift away from their original locations and destroy the layout, even though each of them is
not over-deformed in a local sense. To constrain the deformation
in a global scale, we propose a 2D accessibility constraint, inspired
by the surface exposure [Hsu and Wong 1995] and 3D accessibility [Miller 1994]. This maintains the relative orientation and position between the current line segment and its surrounding line segments.
E=
nl
wi Dlocal (P Pi ),
where m is the total number of character cells, and K is the number of non-empty cells, and is used as the normalization factor.
j
DAISS
is the dissimilarity between the j-th cells content and its
j
best-matched character, as defined in Equation 1. The term Ddeform
is the deformation value of the j-th cell. When there is no deformaj
j
= 1; hence E is purely dependent on DAISS
. Note
tion, Ddeform
that the energy values of different text resolutions are directly comparable, as our energy function is normalized. The lower row of
Figure 12 demonstrates such comparability by showing our results
in three text resolutions along with their energies. The middle one
(2821) with the smallest energy corresponds to the most pleasant result, while the visually poor result on the left has a relatively
larger energy.
We employ a simulated annealing strategy during the discrete optimization. In each iteration, we randomly select one vertex, and
randomly displace its position with a distance of at most d. Here,
d is the length of the longer side of the character image. Then,
all affected grid cells due to this displacement are identified and
best-matched with the character set again. If the recomputed E
is reduced, the displacement is accepted. Otherwise, a transition
probability Pr = exp(/t) is used to make the decision, where
is the energy difference between two iterations; t = 0.2ta c0.997
is the temperature; c is the iteration index; ta is the initial average
matching error of all grid cells. If Pr is smaller than a random number in [0, 1], this displacement is accepted; otherwise, it is rejected.
The optimization is terminated whenever E is not reduced for co
consecutive iterations, where co = 5000 in our implementation.
(3)
i=1
(6)
j=1
Daccess (AB) =
m
1 j
j
DAISS Ddeform
,
K
(4)
27
Input
(b) SSIM
Figure 11: Comparison of ASCII art using different shape similarity metrics.
Rw = 18
Rw = 28
Rw = 35
Input
Rw = 18 E =1319.54
Rw = 28 E = 1274.24
Rw = 35 E = 1282.90
Figure 12: Our method vs. the method of OGrady and Rickard. Rw is the width of the text resolution and E is the optimized energy.
Figure 10 shows the intermediate results along with their energies.
As the energy reduces, the visual quality of ASCII art improves accordingly. An animated sequence for better visualization of such
optimization is included in the auxiliary material.
To validate its importance, we compare the ASCII art results (Figure 11) generated by substituting the character matching metric in
our framework with different shape similarity metrics, including
shape context, SSIM, RMSE after blurring and our metric. Hence,
the same deformation mechanism is employed in generating all results. The result of shape context (Figure 11(a)) is most unrecognizable due to the structure discontinuity caused by the neglect of
position. SSIM and RMSE preserve better structure as they place
a high priority on position. Their alignment-sensitive nature, however, leads to the loss of fine details. Among all results, our metric
generates the best approximation to the input, with the best preservation of structure and fine details. The comparison demonstrates
the importance of transformation awareness and misalignment tolerance in preserving structure continuity and fine details.
28
138X36 ASCII
15mins
ASCII
4mins
6mins
Fig. 11
(a) Input
(b) by artist
(c) by our method
Figure 13: Comparison of ASCII art between an artists and our method.
all three text resolutions (from 1813 to 3528). All fine details
are lost in their results.
Methods
Similarity
To conduct a user study, artists were invited to manually design ASCII art pieces for 3 test images. They were free to
choose the desired text resolution for their pieces, but the character set was restricted to ASCII code. We then use our method and
the method by OGrady and Rickard to generate ASCII art results
with the same text resolutions. Then, we invited 30 participants for
the user study. The source image and three ASCII art results were
shown side-by-side to the participants. Figure 13 shows our result
as well as the artist piece from one of the 3 test sets. The complete
set of comparison can be found in the auxiliary material. Each participant graded the ASCII art using 2 scores out of a 9-point scale
([1-9] with 9 being the best). The first score was to grade the similarity of the ASCII art pieces with respect to the input. The second
was to grade the clarity of content presented in the ASCII art without referring to the input. Therefore, there were 18 data samples
for analysis from each of the 30 participants. Altogether 540 data
samples can be used for analysis.
User Study
Clarity
26X16
5 hrs
8mins
8mins
Fig. 13
52X34
ASCII
7mins
2 hrs
Fig. 14
66X61
ASCII
12mins
Fig. 15
Fig. 16
9mins
9mins
9mins
Artists
6.86
7.36
Our method
O'Grady and Rickard 4.42
Artists
7.18
Our method
7.09
O'Grady and Rickard 4.15
1.32
1.13
1.82
1.25
1.30
1.80
6.60
7.11
7.58
7.14
4.06
4.77
6.94
6.84
7.42
7.34
3.80
4.50
second, third, and fourth columns show the corresponding text resolution, the character set used, and the running time for generating
our ASCII art. The running time increases as the complexity of the
input and the number of the characters increase.
Besides the fact that traditional ASCII art only works
on a fixed-width font, modern ASCII art also deals with proportional fonts, e.g. Japanese Shift-JIS. Our current method does not
handle proportional placement of characters or multiple font sizes
in a single ASCII art piece. Another limitation is that we currently
do not consider the temporal consistency when we generate the animation of ASCII art. To achieve this, one could first establish the
correspondence between the shapes of the adjacent frames. Then
one could constrain the deformation along the temporal dimension
to achieve temporal consistency. Since our system only accepts
vector input, real photographs or other raster images must first be
converted into outline images. This could be done either by nave
edge detection or a sophisticated line art generation method such
as [Kang et al. 2007], followed by vectorization. This also means
that our results would be affected by the quality of the vectorization. A poorly vectorized input containing messy edges would be
faithfully represented by our system. One more limitation stems
from the extremely limited variety of characters. Most font sets do
not contain characters representing a rich variety of slopes of lines.
This makes pictures such as radial patterns very hard to be faithfully
represented.
Limitations
7 Conclusion
29
H SU , S.-C., AND W ONG , T.-T. 1995. Simulating dust accumulation. IEEE Comput. Graph. Appl. 15, 1, 1822.
balancing shape and transformations, comparing it to existing metrics. This metric should also benefit other practical applications
requiring pattern recognition. Besides, a constrained deformation
model is designed to mimic how the artists deform the input image.
The rich variety of results shown demonstrates the effectiveness of
our method. Although we have shown an application of animated
ASCII art, its temporal consistency is not guaranteed. In the future,
it is worth investigating the possibility of generating animations of
ASCII art with high temporal consistency. An extension to proportional placement of characters is also worth studying. To further
control and refine the result, it would also be beneficial to allow
users to interactively highlight the important structure in the input
for preservation during the deformation.
K ANG , H., L EE , S., AND C HUI , C. K. 2007. Coherent line drawing. In ACM Symposium on Non-Photorealistic Animation and
Rendering (NPAR), 4350.
K LOSE , L. A., AND M C I NTOSH , F., 2000. Pictexter. AxiomX.
M ILIOS , E. E. 1989. Shape matching using curvature processes.
Comput. Vision Graph. Image Process. 47, 2, 203226.
M ILLER , G. 1994. Efficient algorithms for local and global accessibility shading. In Proceedings of SIGGRAPH 94, 319326.
M ORI , G., B ELONGIE , S., AND M ALIK , J. 2005. Efficient shape
matching using shape contexts. IEEE Transactions on Pattern
Analysis and Machine Intelligence 27, 11, 18321837.
Acknowledgments
This project is supported by the Research Grants Council of the
Hong Kong Special Administrative Region, under General Research Fund (CUHK417107). We would like to thank Xueting
Liu for drawing some of the line art works, and ASCII artists on
newsmth.net including Crowyue, Zeppeli, Wolfing, and Asan
for creating the ASCII arts in our comparison between the results
by our method and by hand. Thanks also to all reviewers for their
constructive comments and guidance in shaping this paper.
References
A RKIN , E. M., C HEW, L. P., H UTTENLOCHER , D. P., K EDEM ,
K., AND M ITCHELL , J. S. B. 1991. An efficiently computable
metric for comparing polygonal shapes. IEEE Trans. Pattern
Anal. Mach. Intell. 13, 3, 209216.
D., 1995.
Make a start in ASCII art.
AU ,
http://www.ludd.luth.se/vk/pics/ascii/junkyard/techstuff/tutori
als/Daniel Au.html.
WANG , Z., B OVIK , A. C., S HEIKH , H. R., M EMBER , S., S I MONCELLI , E. P., AND M EMBER , S. 2004. Image quality assessment: From error visibility to structural similarity. IEEE
Transactions on Image Processing 13, 600612.
B ELONGIE , S., M ALIK , J., AND P UZICHA , J. 2002. Shape matching and object recognition using shape contexts. IEEE Tran. Pattern Analysis and Machine Intelligience 24, 4, 509522.
30
(s1) dragon-man
(s2) banquet
(a) Frame 1
(b) Frame 3
Figure 17: Animation of toitorse
(s3) church
(s4) Golden Temple
Figure 18: Inputs of examples in this paper
31
(c) Frame 6
(s5) train