1Ppmshadow User Manual(0) Ppmshadow User Manual(0)
2
3
4
6 ppmshadow - add simulated shadows to a PPM image
7
8
10 ppmshadow [-b blur_size] [-k] [-t] [-x xoffset] [-y yoffset] [ppmfile]
11
12
13
15 This program is part of Netpbm(1).
16
17 ppmshadow adds a simulated shadow to an image, giving the appearance
18 that the contents of the image float above the page, casting a diffuse
19 shadow on the background. Shadows can either be black, as cast by
20 opaque objects, or translucent, where the shadow takes on the color of
21 the object which casts it. You can specify the crispness of the shadow
22 and its displacement from the image with command line options.
23
24 ppmshadow sees your image as a foreground on a background. The back‐
25 ground color is whatever color the top left pixel of your image is.
26 The background is all the pixels that are that color and the foreground
27 is everything else. The shadow that ppmshadow generates is a shadow of
28 the foreground, cast on the background.
29
30 The shadow is the same size as the foreground, plus some fringes as
31 determined by the -b option. It is truncated to fit in your image.
32 The output image is the same dimensions as the input image.
33
34 You can use pamcomp to place a foreground image over a background
35 before running ppmshadow on it. You can use ppmmake to make the back‐
36 ground image (just an image of a solid color).
37
38
40 -b blur_size
41 Sets the distance of the light source from the image. Larger
42 values move the light source closer, casting a more diffuse
43 shadow, while smaller settings move the light further away,
44 yielding a sharper shadow. blur_size is the number of pixels of
45 fringe there is on the shadow, beyond where the shadow would be
46 if there were no blurring.
47
48 The default is 11 pixels.
49
50 Note that this option controls only the fringing effect of mov‐
51 ing the light source closer to the object. It does not make the
52 shadow grow or shrink as would happpen in the real world if you
53 moved a point light source closer to and further from an object.
54
55
56 -k Keep the intermediate temporary image files. When debugging,
57 these intermediate files provide many clues as to the source of
58 an error. See below ⟨#files⟩ for a list of the contents of
59 each file.
60
61
62 -t Consider the non-background material in the image translucent --
63 it casts shadows of its own color rather than a black shadow,
64 which is default. This often results in fuzzy, difficult-to-
65 read images but in some circumstances may look better.
66
67
68 -x xoffset
69 Specifies the displacement of the light source to the left of
70 the image. Larger settings of xoffset displace the shadow to
71 the right, as would be cast by a light further to the left. If
72 not specified, the horizontal offset is half of blur_size
73 (above), to the left.
74
75
76 -y yoffset
77 Specifies the displacement of the light source above the top of
78 the image. Larger settings displace the shadow downward, corre‐
79 sponding to moving the light further above the top of the image.
80 If you don't specify -y, the vertical offset defaults to the
81 same as the horizontal offset (above), upward.
82
83
84
85
86
88 Input is a PPM file named by the ppmfile command line argument; if you
89 don't specify ppmfile, the input is Standard Input.
90
91 The output is a PPM file, written to Standard Output.
92
93 ppmshadow creates a number of temporary files as it executes. It cre‐
94 ates a new directory for them, /tmp/ppmshadowpid, where pid is the
95 process ID of the ppmshadow process. If the TMPDIR environment vari‐
96 able is set, ppmshadow creates the directory there instead of /tmp.
97
98 In normal operation, ppmshadow deletes each temporary file as soon as
99 it is done with it and leaves no debris around after it completes. To
100 preserve the intermediate files for debugging, use the -k command line
101 option.
102
103 The temporary files are:
104
105
106
107 infile.ppm
108 A copy of the input.
109
110
111 bgmask.ppm
112 Positive binary mask
113
114
115 convkernel.ppm
116 Convolution kernel for blurring shadow
117
118
119 blurred.ppm
120 Blurred, colored shadow image
121
122
123 blurred2.ppm
124 Blurred shadow image before coloring
125
126
127 shadow.ppm
128 Clipped shadow image, offset as requested
129
130
131 background.ppm
132 Blank image with background of source image
133
134
135 shadow.ppm
136 Offset shadow
137
138
139 fgmask.ppm
140 Inverse mask file
141
142
143 justfg.ppm
144 Just the foreground. Rest is black. Original image times
145 inverse mask.
146
147
148 shadback.ppm
149 Generated shadow times positive mask
150
151
152 allbutfg.ppm
153 Everything but the foreground (foreground area is black).
154
155
156
157
159 The source image must contain sufficient space on the edges in the
160 direction in which the shadow is cast to contain the shadow -- if it
161 doesn't some of the internal steps may fail. You can usually expand
162 the border of a too-tightly-cropped image with pnmmargin before pro‐
163 cessing it with ppmshadow.
164
165 Black pixels and pixels with the same color as the image background
166 don't cast a shadow. If this causes unintentional 'holes' in the
167 shadow, fill the offending areas with a color which differs from black
168 or the background by RGB values of 1, which will be imperceptible to
169 the viewer. Since the comparison is exact, the modified areas will now
170 cast shadows.
171
172 The background color of the source image (which is preserved in the
173 output) is deemed to be the color of the pixel at the top left of the
174 input image. If that pixel isn't part of the background, simply add a
175 one-pixel border at the top of the image, generate the shadow image,
176 then delete the border from it.
177
178 If something goes wrong along the way, the error messages from the var‐
179 ious Netpbm programs ppmshadow calls will, in general, provide little
180 or no clue as to where ppmshadow went astray. In this case, Specify
181 the -k option and examine the intermediate results in the temporary
182 files (which this option causes to be preserved). If you manually run
183 the commands that ppmshadow runs on these files, you can figure out
184 where the problem is. In problem cases where you want to manually
185 tweak the image generation process along the way, you can keep the
186 intermediate files with the -k option, modify them appropriately with
187 an image editor, then recombine them with the steps used by the code in
188 ppmshadow.
189
190 See the ppmshadow.doc file in the Netpbm source tree for additional
191 details and examples of the intermediate files and debugging ppmshadow.
192
193 Shadows are by default black, as cast by opaque material in the image
194 occluding white light. Use the -t option to simulate translucent mate‐
195 rial, where the shadow takes on the color of the object that casts it.
196 If the contrast between the image and background is insufficient, the
197 -t option may yield unattractive results which resemble simple blurring
198 of the original image.
199
200 Because Netpbm used to have a maximum maxval of 255, which meant that
201 the largest convolution kernel pnmconvol could use was 11 by 11,
202 ppmshadow includes a horrid, CPU-time-burning kludge which, if a blur
203 of greater than 11 is requested, performs an initial convolution with
204 an 11 x 11 kernel, then calls pnmsmooth (which is itself a program that
205 calls pnmconvol with a 3 x 3 kernel) as many times as the requested
206 blur exceeds 11. It's ugly, but it gets the job done on those rare
207 occasions where you need a blur greater than 11.
208
209 If you wish to generate an image at high resolution, then scale it to
210 publication size with pamscale in order to eliminate jagged edges by
211 resampling, it's best to generate the shadow in the original high reso‐
212 lution image, prior to scaling it down in size. If you scale first and
213 then add the shadow, you'll get an unsightly jagged stripe between the
214 edge of material and its shadow, due to resampled pixels intermediate
215 between the image and background obscuring the shadow.
216
217
219 ppmshadow returns status 0 if processing was completed without errors,
220 and a nonzero Unix error code if an error prevented generation of out‐
221 put. Some errors may result in the script aborting, usually displaying
222 error messages from various Netpbm components it uses, without return‐
223 ing a nonzero error code. When this happens, the output file will be
224 empty, so be sure to test this if you need to know if the program suc‐
225 ceeded.
226
227
229 pnm(1), pnmmargin(1), pnmconvol(1), pamscale(1), pnmsmooth(1), ppm(1)
230
231
232
234 John Walker http://www.fourmilab.ch ⟨http://www.fourmilab.ch⟩ August
235 8, 1997
236
237
239 This software is in the public domain. Permission to use, copy, mod‐
240 ify, and distribute this software and its documentation for any purpose
241 and without fee is hereby granted, without any conditions or restric‐
242 tions.
243
244
245
246netpbm documentation 17 April 2005 Ppmshadow User Manual(0)