summary refs log tree commit diff
path: root/pamsistoaglyph.html
blob: dd5a7419bba2687c4220c4bc46df0020472f1b8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pamsistoaglyph User Manual</title></head>
<body>
<h1>pamsistoaglyph</h1>
Updated: 05 April 2009
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>

pamsistoaglyph - convert a single-image stereogram to a red/cyan
anaglyphic image


<h2 id="synopsis">SYNOPSIS</h2>

<p><b>pamsistoaglyph</b>
[--<b>invert</b>]
[--<b>sep</b>=<i>number</i>]
[--<b>minsep</b>=<i>number</i>]
[--<b>gray</b>=<i>number</i>]
[<i>in_netpbmfile</i>


<p>All options can be abbreviated to their shortest unique prefix. You
may use either white space or an equals sign between an option name
and its value.


<h2 id="description">DESCRIPTION</h2>

<p>This program is part of <a href="index.html">Netpbm</a>.

<p><b>pamsistoaglyph</b> reads a Netpbm image as input and
produces a Netpbm image as output.

<p><b>pamsistoaglyph</b> takes a single-image stereogram
(SIS) such as those produced by <a href=
"pamstereogram.html">pamstereogram</a>
and converts it to a red/cyan anaglyphic image such as those produced
by <a href="ppm3d.html">ppm3d</a>.
Many people have trouble tricking their eyes into focusing beyond the
image in front of them and are therefore unable to perceive the 3-D
shape hidden within a single-image stereogram.  Anaglyphic stereograms
are easier to perceive in 3-D but require a pair of red/cyan glasses
such as those often used to watch 3-D movies. The goal of
<b>pamsistoaglyph</b> is to help people who have trouble
viewing single-image stereograms see the intriguing 3-D effect.

<p><b>pamsistoaglyph</b> can convert single-image random-dot
stereograms (SIRDS), wallpaper stereograms, and even dual-image
stereograms to anaglyphic images.


<h2 id="options">OPTIONS</h2>

<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pamsistoaglyph</b> recognizes the following
command line options:

<p>For most images, no command-line options need to be specified.  The
following options are available, however, for unusual circumstances.

<dl>
<dt><b>--invert</b>
<dd>Swap the left- and right-eye
    images. <b>pamsistoaglyph</b> assumes that its input
    represents a wall-eyed stereogram and generates the anaglyphic
    image accordingly. If the generated image appears to recede into
    the page where it should pop out of the page (and vice versa),
    this typically implies that the input image represents a
    cross-eyed stereogram. Use <b>--invert</b> to correct
    the image depth.

<dt><b>--sep</b>=<i>number</i>
<dd>Specify the distance in pixels between the left- and right-eye
    images. Essentially, this corresponds to the distance between
    repetitions of the background pattern.  The <b>--sep</b>
    option should rarely be necessary
    as <b>pamsistoaglyph</b> is fairly good at determining
    automatically the eye-separation distance.

<dt><b>--minsep</b>=<i>number</i>
<dd>This option is similar to <b>--sep</b> but
    constrains <b>pamsistoaglyph</b> only to
    a <i>minimum</i> eye-separation distance. Any distance larger
    than <i>number</i> is acceptable.  The <b>--minsep</b>
    option should rarely be necessary
    as <b>pamsistoaglyph</b> is fairly good at determining
    automatically the eye-separation distance.  The default value for
    the minimum eye-separation distance is 10% of the image width;
    this value seems to work well in practice.

<dt><b>--gray</b>=<i>number</i>
<dd>Limit the number of gray levels to use when searching for the
    optimal eye-separation
    distance.  Because <b>pamsistoaglyph</b> looks for
    repeated patterns, it is vulnerable to being confused by slight
    variations in color.  By reducing the input image to grayscale and
    capping the number of gray levels,
    <b>pamsistoaglyph</b> ameliorates the effects of
    unintentional color variations (such as those caused by conversion
    from a low-quality JPEG image, for example). The default of 63
    seems to work well so the <b>--gray</b> option should
    rarely be necessary.
</dl>


<h2 id="notes">NOTES</h2>

<p>The registration algorithm used by <b>pamsistoaglyph</b>
was developed specifically for this program. As far as the author
knows, there are no existing algorithms for converting stereograms to
anaglyphs.  The algorithm works as follows:

<ol>
<li>Convert the image to grayscale to increase the ability to identify
    matches.

<li>Count the number of pixels that match <i>N</i> pixels ahead in the
    image for all <i>N</i> in [1, <i>width</i>/2].

<li>Maintain a running mean (&mu;) and standard deviation (&sigma;) of
    the number of matched pixels.

<li>Store the <i>N</i> corresponding to each spike in the number of
    matched pixels. A spike is defined as a tally that exceeds the
    mean plus one, two, or three standard deviations. Only the first
    spike of a given standard-deviation multiplier is stored.

<li>If a tally greater than &mu;+3&sigma; was encountered, return the
    corresponding <i>N</i>. If not, then if a tally greater than
    &mu;+2&sigma; was encountered, return the
    corresponding <i>N</i>. If not, then if a tally greater than
    &mu;+&sigma; was encountered, return the
    corresponding <i>N</i>. If not, then return the <i>N</i> that
    produces the minimum average distance between matched pixels
    (i.e.,&nbsp;<i>#matches</i> divided by <i>#pixels</i>). If no
    such <i>N</i> exceeds the minimum allowable eye-separation value,
    return zero to indicate failure.

<li>If the algorithm returned zero, rerun the algorithm independently
    on each row of the input image and return the median of
    all <i>N</i> that exceed the minimum allowable eye-separation
    value. If no such <i>N</i> exists, abort with an error
    message.
</ol>

<h2 id="history">HISTORY</h2>

<p>Scott Pakin wrote <b>pamsistoaglyph</b> in April 2009.  It first appeared
in Netpbm in Release 10.47 (June 2009).


<h2 id="author">AUTHOR</h2>

<p>Copyright (C) 2009 Scott
Pakin, <a href="mailto:scott+pbm@pakin.org">scott+pbm@pakin.org</a>


<h2 id="seealso">SEE ALSO</h2>

<ul>

<li><b><a href="pamstereogram.html">pamstereogram</a></b>
<li><b><a href="ppm3d.html">ppm3d</a></b>,
<li>&lt;<a href="http://en.wikipedia.org/wiki/Stereogram">http://en.wikipedia.org/wiki/Stereogram</a>&gt;

</ul>


<hr />
<h2 id="index">Table Of Contents</h2>

<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
<li><a href="#options">OPTIONS</a>
<li><a href="#notes">NOTES</a>
<li><a href="#history">HISTORY</a>
<li><a href="#author">AUTHOR</a>
<li><a href="#seealso">SEE ALSO</a>
</ul>

</body>
</html>