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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD><TITLE>Ppmshadow User Manual</TITLE></HEAD>
<BODY>
<H1>ppmshadow</H1>
Updated: 24 June 2017
<BR><A HREF="#index">Table Of Contents</A>
<H2 id="name">NAME</H2>
ppmshadow - add simulated shadows to a PPM image
<H2 id="synopsis">SYNOPSIS</H2>
<B>ppmshadow</B>
[<B>-b</B> <I>blur_size</I>]
[<B>-k</B>]
[<B>-t</B>]
[<B>-x</B> <I>xoffset</I>]
[<B>-y</B> <I>yoffset</I>]
[<I>ppmfile</I>]
<H2 id="description">DESCRIPTION</H2>
<p>This program is part of <a href="index.html">Netpbm</a>.
<p><B>ppmshadow</B> adds a simulated shadow to an image, giving the
appearance that the contents of the image float above the page,
casting a diffuse shadow on the background. Shadows can either be
black, as cast by opaque objects, or translucent, where the shadow
takes on the color of the object which casts it. You can specify the
crispness of the shadow and its displacement from the image with command
line options.
<p><b>ppmshadow</b> sees your image as a foreground on a background.
The background color is whatever color the top left pixel of your image is.
The background is all the pixels that are that color and the foreground
is everything else. The shadow that <b>ppmshadow</b> generates is a
shadow of the foreground, cast on the background.
<p>The shadow is the same size as the foreground, plus some fringes
as determined by the <b>-b</b> option. It is truncated to fit in your
image. The output image is the same dimensions as the input image.
<p>You can use <b>pamcomp</b> to place a foreground image over a background
before running <b>ppmshadow</b> on it. You can use <b>ppmmake</b> to make
the background image (just an image of a solid color).
<p>The output has the same dimensions and maxval as the input.
<p>The blurring to make the fringes of the shadow will not have a desirable
effect if the color depth (maxval) of the image is too low -- you need a high
maxval to get all the shades needed to create a smooth gradient. So if your
input has low maxval (including most notably if the input is PBM, which means
its maxval is 1), run it through <b>pamdepth</b> to raise its maxval. 255 is
usually a good choice.
<p>Input is a PPM file named by the <I>ppmfile</I> command line argument; if
you don't specify <I>ppmfile</I>, the input is Standard Input.
<P>The output is a PPM file, written to Standard Output.
<H2 id="options">OPTIONS</H2>
<DL COMPACT>
<DT><B>-b</B> <I>blur_size</I>
<DD>
Sets the distance of the light source from the image. Larger values
move the light source closer, casting a more diffuse shadow, while
smaller settings move the light further away, yielding a sharper
shadow. <i>blur_size</i> is the number of pixels of fringe there is
on the shadow, beyond where the shadow would be if there were no
blurring.
<p>The default is 11 pixels.
<p>Note that this option controls only the fringing effect of moving
the light source closer to the object. It does not make the shadow
grow or shrink as would happpen in the real world if you moved a point
light source closer to and further from an object.
<DT><B>-k</B>
<DD>
Keep the intermediate temporary image files. When debugging, these
intermediate files provide many clues as to the source of an error.
See <a href="#files">below</a> for a list of the contents of each file.
<DT><B>-t</B>
<DD>
Consider the non-background material in the image translucent -- it
casts shadows of its own color rather than a black shadow, which is
default. This often results in fuzzy, difficult-to-read images but in
some circumstances may look better.
<DT><B>-x</B><I> xoffset</I>
<DD>Specifies the displacement of the light source to the left of the
image. Larger settings of <B>xoffset</B> displace the shadow to the
right, as would be cast by a light further to the left. If not
specified, the horizontal offset is half of <I>blur_size </I> (above),
to the left.
<DT><B>-y</B><I> yoffset</I>
<DD> Specifies the displacement of the light source above the top of
the image. Larger settings displace the shadow downward,
corresponding to moving the light further above the top of the image.
If you don't specify <B>-y</B>, the vertical offset defaults to the
same as the horizontal offset (above), upward.
</DL>
<H2 id="limitations">LIMITATIONS</H2>
<p>The source image must contain sufficient space on the edges in the
direction in which the shadow is cast to contain the shadow -- if it
doesn't some of the internal steps may fail. You can usually expand
the border of a too-tightly-cropped image with <B>pnmmargin</B> before
processing it with <B>ppmshadow</B>.
<P>Black pixels and pixels with the same color as the image
background don't cast a shadow. If this causes unintentional
"holes" in the shadow, fill the offending areas with a color
which differs from black or the background by RGB values of 1, which
will be imperceptible to the viewer. Since the comparison is exact,
the modified areas will now cast shadows.
<P>The background color of the source image (which is preserved in
the output) is deemed to be the color of the pixel at the top left of
the input image. If that pixel isn't part of the background, simply
add a one-pixel border at the top of the image, generate the shadow
image, then delete the border from it.
<P>If something goes wrong along the way, the error messages from the
various Netpbm programs <B>ppmshadow</B> calls will, in general,
provide little or no clue as to where <B>ppmshadow</B> went astray.
In this case, Specify the <B>-k</B> option and examine the
intermediate results in the temporary files (which this option causes
to be preserved). If you manually run the commands that
<B>ppmshadow</B> runs on these files, you can figure out where the
problem is. In problem cases where you want to manually tweak the
image generation process along the way, you can keep the intermediate
files with the <B>-k </B> option, modify them appropriately with an
image editor, then recombine them with the steps used by the code in
<B>ppmshadow</B>.
<P>Shadows are by default black, as cast by opaque material in the
image occluding white light. Use the <B>-t</B> option to simulate
translucent material, where the shadow takes on the color of the
object that casts it. If the contrast between the image and
background is insufficient, the <B>-t</B> option may yield
unattractive results which resemble simple blurring of the original
image.
<P>Because Netpbm used to have a maximum maxval of 255, which meant
that the largest convolution kernel <B>pnmconvol</B> could use was 11
by 11, <B>ppmshadow</B> includes a horrid, CPU-time-burning kludge
which, if a blur of greater than 11 is requested, performs an initial
convolution with an 11 x 11 kernel, then calls <B>pnmsmooth</B>
(which is itself a program that calls <b>pnmconvol</b> with a 3 x 3
kernel) as many times as the requested blur exceeds 11. It's ugly,
but it gets the job done on those rare occasions where you need a blur
greater than 11.
<P>If you wish to generate an image at high resolution, then scale it
to publication size with <B>pamscale</B> in order to eliminate jagged
edges by resampling, it's best to generate the shadow in the original
high resolution image, prior to scaling it down in size. If you scale
first and then add the shadow, you'll get an unsightly jagged stripe
between the edge of material and its shadow, due to resampled pixels
intermediate between the image and background obscuring the shadow.
<H2 id="exitstatus">EXIT STATUS</H2>
<B>ppmshadow</B> returns status 0 if processing was completed without
errors, and a nonzero Unix error code if an error prevented generation
of output. Some errors may result in the script aborting, usually
displaying error messages from various Netpbm components it uses,
without returning a nonzero error code. When this happens, the output
file will be empty, so be sure to test this if you need to know if the
program succeeded.
<H2 id="seealso">SEE ALSO</H2>
<B><A HREF="pnm.html">pnm</A></B>,
<B><A HREF="pnmmargin.html">pnmmargin</A></B>,
<B><A HREF="pnmconvol.html">pnmconvol</A></B>,
<B><A HREF="pamscale.html">pamscale</A></B>,
<B><A HREF="pnmsmooth.html">pnmsmooth</A></B>,
<B><A HREF="ppm.html">ppm</A></B>
<H2 id="tempfiles">TEMPORARY FILES</H2>
<p><B>ppmshadow</B> creates a number of temporary files as it executes. It
creates a new directory for them in the directory named by the
<b>TMPDIR</b> environment variable, defaulting to <b>/tmp</b> if it is not
set.
<p>In normal operation, <B>ppmshadow</B> finds a unique name for the
temporary directory and deletes each temporary file as
soon as it is done with it and leaves no debris around after it
completes. To preserve the intermediate files for debugging, use the
<B>-k</B> command line option. In that case, the directory name is
<b>ppmshadow</b><i>pid</i>, where <i>pid</i> is the process ID of
the <b>ppmshadow</b> process, and the program fails if <b>ppmshadow</b> cannot
create that directory because the name is already in use.
<p>The temporary files are:
<DL COMPACT>
<DT><B>infile.ppm</b>
<DD>
A copy of the input.
<DT><B>background.ppm</B>
<DD>
Blank image with background of source image
<DT><B>bgmask.ppm</B>
<DD>
Positive binary mask
<DT><B>convkernel.ppm</B>
<DD>
Convolution kernel for blurring shadow
<DT><B>blurredlackshad.ppm</B>
<DD>
Blurred shadow image before coloring
<DT><B>blurred.ppm</B>
<DD>
Blurred, colored shadow image
<DT><B>shadow.ppm</B>
<DD>
Clipped shadow image, offset as requested
<DT><B>shadback.ppm</B>
<DD>
Generated shadow times positive mask
</DL>
<H2 id="author">AUTHOR</H2>
John Walker <<A
HREF="http://www.fourmilab.ch">http://www.fourmilab.ch</A>> August
8, 1997
<H2 id="copyright">COPYRIGHT</H2>
This software is in the public domain. Permission to use, copy,
modify, and distribute this software and its documentation for any
purpose and without fee is hereby granted, without any conditions or
restrictions.
<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="#limitations">LIMITATIONS</A>
<LI><A HREF="#exitstatus">EXIT STATUS</A>
<LI><A HREF="#tempfiles">TEMPORARY FILES</A>
<LI><A HREF="#seealso">SEE ALSO</A>
<LI><A HREF="#author">AUTHOR</A>
<LI><A HREF="#copyright">COPYRIGHT</A>
</UL>
</BODY>
</HTML>
|