1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
26 |
|
#define sscan(y) (ourspict+(y)*hresolu) |
27 |
|
#define wscan(y) (ourweigh+(y)*hresolu) |
28 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
29 |
+ |
#define bscan(y) (ourbpict+(y)*hresolu) |
30 |
|
#define averaging (ourweigh != NULL) |
31 |
+ |
#define blurring (ourbpict != NULL) |
32 |
|
#define usematrix (hasmatrix & !averaging) |
33 |
|
#define zisnorm (!usematrix | ourview.type != VT_PER) |
34 |
|
|
39 |
|
|
40 |
|
#define PACKSIZ 256 /* max. calculation packet size */ |
41 |
|
|
42 |
< |
#define RTCOM "rtrace -h- -ovl -fff " |
42 |
> |
#define RTCOM "rtrace -h- -ovl -fff -ld- -i- -I- " |
43 |
|
|
44 |
|
#define ABS(x) ((x)>0?(x):-(x)) |
45 |
|
|
61 |
|
COLOR *ourspict; /* output pixel sums (averaging) */ |
62 |
|
float *ourweigh = NULL; /* output pixel weights (averaging) */ |
63 |
|
float *ourzbuf; /* corresponding z-buffer */ |
64 |
+ |
COLOR *ourbpict = NULL; /* blurred picture (view averaging) */ |
65 |
|
|
66 |
+ |
VIEW avgview; /* average view for -B option */ |
67 |
+ |
int nvavg; /* number of views averaged */ |
68 |
+ |
|
69 |
|
char *progname; |
70 |
|
|
71 |
|
int fillo = F_FORE|F_BACK; /* selected fill options */ |
76 |
|
COLOR backcolor = BLKCOLOR; /* background color (float) */ |
77 |
|
double backz = 0.0; /* background z value */ |
78 |
|
int normdist = 1; /* i/o normalized distance? */ |
79 |
+ |
char ourfmt[LPICFMT+1] = PICFMT; /* original picture format */ |
80 |
|
double ourexp = -1; /* original picture exposure */ |
81 |
|
int expadj = 0; /* exposure adjustment (f-stops) */ |
82 |
|
double rexpadj = 1; /* real exposure adjustment */ |
83 |
|
|
84 |
< |
VIEW theirview = STDVIEW; /* input view */ |
84 |
> |
VIEW theirview; /* input view */ |
85 |
|
int gotview; /* got input view? */ |
86 |
|
int wrongformat = 0; /* input in another format? */ |
87 |
|
RESOLU tresolu; /* input resolution */ |
93 |
|
#define childpid (PDesc[2]) |
94 |
|
unsigned short queue[PACKSIZ][2]; /* pending pixels */ |
95 |
|
int packsiz; /* actual packet size */ |
96 |
< |
int queuesiz; /* number of pixels pending */ |
96 |
> |
int queuesiz = 0; /* number of pixels pending */ |
97 |
|
|
98 |
|
extern double movepixel(); |
99 |
|
|
102 |
|
int argc; |
103 |
|
char *argv[]; |
104 |
|
{ |
105 |
< |
#define check(ol,al) if (argv[i][ol] || \ |
106 |
< |
badarg(argc-i-1,argv+i+1,al)) \ |
105 |
> |
#define check(ol,al) if (argv[an][ol] || \ |
106 |
> |
badarg(argc-an-1,argv+an+1,al)) \ |
107 |
|
goto badopt |
108 |
|
int gotvfile = 0; |
109 |
|
int doavg = -1; |
110 |
+ |
int doblur = 0; |
111 |
|
char *zfile = NULL; |
112 |
|
char *expcomp = NULL; |
113 |
< |
char *err; |
106 |
< |
int i, rval; |
113 |
> |
int i, an, rval; |
114 |
|
|
115 |
|
progname = argv[0]; |
116 |
|
|
117 |
< |
for (i = 1; i < argc && argv[i][0] == '-'; i++) { |
118 |
< |
rval = getviewopt(&ourview, argc-i, argv+i); |
117 |
> |
for (an = 1; an < argc && argv[an][0] == '-'; an++) { |
118 |
> |
rval = getviewopt(&ourview, argc-an, argv+an); |
119 |
|
if (rval >= 0) { |
120 |
< |
i += rval; |
120 |
> |
an += rval; |
121 |
|
continue; |
122 |
|
} |
123 |
< |
switch (argv[i][1]) { |
123 |
> |
switch (argv[an][1]) { |
124 |
|
case 'e': /* exposure */ |
125 |
|
check(2,"f"); |
126 |
< |
expcomp = argv[++i]; |
126 |
> |
expcomp = argv[++an]; |
127 |
|
break; |
128 |
|
case 't': /* threshold */ |
129 |
|
check(2,"f"); |
130 |
< |
zeps = atof(argv[++i]); |
130 |
> |
zeps = atof(argv[++an]); |
131 |
|
break; |
132 |
|
case 'a': /* average */ |
133 |
|
check(2,NULL); |
134 |
|
doavg = 1; |
135 |
|
break; |
136 |
+ |
case 'B': /* blur views */ |
137 |
+ |
check(2,NULL); |
138 |
+ |
doblur = 1; |
139 |
+ |
break; |
140 |
|
case 'q': /* quick (no avg.) */ |
141 |
|
check(2,NULL); |
142 |
|
doavg = 0; |
146 |
|
normdist = !normdist; |
147 |
|
break; |
148 |
|
case 'f': /* fill type */ |
149 |
< |
switch (argv[i][2]) { |
149 |
> |
switch (argv[an][2]) { |
150 |
|
case '0': /* none */ |
151 |
|
check(3,NULL); |
152 |
|
fillo = 0; |
165 |
|
break; |
166 |
|
case 's': /* sample */ |
167 |
|
check(3,"i"); |
168 |
< |
fillsamp = atoi(argv[++i]); |
168 |
> |
fillsamp = atoi(argv[++an]); |
169 |
|
break; |
170 |
|
case 'c': /* color */ |
171 |
|
check(3,"fff"); |
172 |
|
fillfunc = backfill; |
173 |
< |
setcolor(backcolor, atof(argv[i+1]), |
174 |
< |
atof(argv[i+2]), atof(argv[i+3])); |
173 |
> |
setcolor(backcolor, atof(argv[an+1]), |
174 |
> |
atof(argv[an+2]), atof(argv[an+3])); |
175 |
|
setcolr(backcolr, colval(backcolor,RED), |
176 |
|
colval(backcolor,GRN), |
177 |
|
colval(backcolor,BLU)); |
178 |
< |
i += 3; |
178 |
> |
an += 3; |
179 |
|
break; |
180 |
|
case 'z': /* z value */ |
181 |
|
check(3,"f"); |
182 |
|
fillfunc = backfill; |
183 |
< |
backz = atof(argv[++i]); |
183 |
> |
backz = atof(argv[++an]); |
184 |
|
break; |
185 |
|
case 'r': /* rtrace */ |
186 |
|
check(3,"s"); |
187 |
|
fillfunc = rcalfill; |
188 |
< |
calstart(RTCOM, argv[++i]); |
188 |
> |
calstart(RTCOM, argv[++an]); |
189 |
|
break; |
190 |
|
default: |
191 |
|
goto badopt; |
193 |
|
break; |
194 |
|
case 'z': /* z file */ |
195 |
|
check(2,"s"); |
196 |
< |
zfile = argv[++i]; |
196 |
> |
zfile = argv[++an]; |
197 |
|
break; |
198 |
|
case 'x': /* x resolution */ |
199 |
|
check(2,"i"); |
200 |
< |
hresolu = atoi(argv[++i]); |
200 |
> |
hresolu = atoi(argv[++an]); |
201 |
|
break; |
202 |
|
case 'y': /* y resolution */ |
203 |
|
check(2,"i"); |
204 |
< |
vresolu = atoi(argv[++i]); |
204 |
> |
vresolu = atoi(argv[++an]); |
205 |
|
break; |
206 |
|
case 'p': /* pixel aspect */ |
207 |
< |
if (argv[i][2] != 'a') |
207 |
> |
if (argv[an][2] != 'a') |
208 |
|
goto badopt; |
209 |
|
check(3,"f"); |
210 |
< |
pixaspect = atof(argv[++i]); |
210 |
> |
pixaspect = atof(argv[++an]); |
211 |
|
break; |
212 |
|
case 'v': /* view file */ |
213 |
< |
if (argv[i][2] != 'f') |
213 |
> |
if (argv[an][2] != 'f') |
214 |
|
goto badopt; |
215 |
|
check(3,"s"); |
216 |
< |
gotvfile = viewfile(argv[++i], &ourview, 0, 0); |
216 |
> |
gotvfile = viewfile(argv[++an], &ourview, 0, 0); |
217 |
|
if (gotvfile < 0) |
218 |
< |
syserror(argv[i]); |
218 |
> |
syserror(argv[an]); |
219 |
|
else if (gotvfile == 0) { |
220 |
|
fprintf(stderr, "%s: bad view file\n", |
221 |
< |
argv[i]); |
221 |
> |
argv[an]); |
222 |
|
exit(1); |
223 |
|
} |
224 |
|
break; |
225 |
|
default: |
226 |
|
badopt: |
227 |
|
fprintf(stderr, "%s: command line error at '%s'\n", |
228 |
< |
progname, argv[i]); |
228 |
> |
progname, argv[an]); |
229 |
|
goto userr; |
230 |
|
} |
231 |
|
} |
232 |
|
/* check arguments */ |
233 |
< |
if ((argc-i)%2) |
233 |
> |
if ((argc-an)%2) |
234 |
|
goto userr; |
235 |
|
if (fillsamp == 1) |
236 |
|
fillo &= ~F_BACK; |
237 |
|
if (doavg < 0) |
238 |
< |
doavg = (argc-i) > 2; |
238 |
> |
doavg = (argc-an) > 2; |
239 |
|
if (expcomp != NULL) |
240 |
|
if (expcomp[0] == '+' | expcomp[0] == '-') { |
241 |
|
expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5); |
242 |
< |
if (doavg) |
242 |
> |
if (doavg | doblur) |
243 |
|
rexpadj = pow(2.0, atof(expcomp)); |
244 |
|
else |
245 |
|
rexpadj = pow(2.0, (double)expadj); |
248 |
|
goto userr; |
249 |
|
rexpadj = atof(expcomp); |
250 |
|
expadj = log(rexpadj)/LOG2 + (rexpadj>1 ? .5 : -.5); |
251 |
< |
if (!doavg) |
251 |
> |
if (!(doavg | doblur)) |
252 |
|
rexpadj = pow(2.0, (double)expadj); |
253 |
|
} |
254 |
|
/* set view */ |
255 |
< |
if ((err = setview(&ourview)) != NULL) { |
256 |
< |
fprintf(stderr, "%s: %s\n", progname, err); |
255 |
> |
if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) { |
256 |
> |
fprintf(stderr, "%s: no view on standard input!\n", |
257 |
> |
progname); |
258 |
|
exit(1); |
259 |
|
} |
260 |
|
normaspect(viewaspect(&ourview), &pixaspect, &hresolu, &vresolu); |
269 |
|
if (ourpict == NULL) |
270 |
|
syserror(progname); |
271 |
|
} |
272 |
+ |
if (doblur) { |
273 |
+ |
ourbpict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR)); |
274 |
+ |
if (ourbpict == NULL) |
275 |
+ |
syserror(progname); |
276 |
+ |
} |
277 |
|
ourzbuf = (float *)bmalloc(hresolu*vresolu*sizeof(float)); |
278 |
|
if (ourzbuf == NULL) |
279 |
|
syserror(progname); |
263 |
– |
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
280 |
|
/* new header */ |
281 |
|
newheader("RADIANCE", stdout); |
282 |
< |
/* get input */ |
283 |
< |
for ( ; i < argc; i += 2) |
284 |
< |
addpicture(argv[i], argv[i+1]); |
285 |
< |
/* fill in spaces */ |
286 |
< |
if (fillo&F_BACK) |
287 |
< |
backpicture(fillfunc, fillsamp); |
288 |
< |
else |
289 |
< |
fillpicture(fillfunc); |
282 |
> |
/* run pictures */ |
283 |
> |
do { |
284 |
> |
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
285 |
> |
for (i = an; i < argc; i += 2) |
286 |
> |
addpicture(argv[i], argv[i+1]); |
287 |
> |
if (fillo&F_BACK) /* fill in spaces */ |
288 |
> |
backpicture(fillfunc, fillsamp); |
289 |
> |
else |
290 |
> |
fillpicture(fillfunc); |
291 |
> |
/* aft clipping */ |
292 |
> |
clipaft(); |
293 |
> |
} while (addblur() && nextview(stdin) != EOF); |
294 |
|
/* close calculation */ |
295 |
|
caldone(); |
276 |
– |
/* aft clipping */ |
277 |
– |
clipaft(); |
296 |
|
/* add to header */ |
297 |
|
printargs(argc, argv, stdout); |
298 |
< |
if (gotvfile) { |
298 |
> |
compavgview(); |
299 |
> |
if (doblur | gotvfile) { |
300 |
|
fputs(VIEWSTR, stdout); |
301 |
< |
fprintview(&ourview, stdout); |
301 |
> |
fprintview(&avgview, stdout); |
302 |
|
putc('\n', stdout); |
303 |
|
} |
304 |
|
if (pixaspect < .99 | pixaspect > 1.01) |
309 |
|
ourexp = rexpadj; |
310 |
|
if (ourexp < .995 | ourexp > 1.005) |
311 |
|
fputexpos(ourexp, stdout); |
312 |
< |
fputformat(COLRFMT, stdout); |
312 |
> |
if (strcmp(ourfmt, PICFMT)) /* print format if known */ |
313 |
> |
fputformat(ourfmt, stdout); |
314 |
|
putc('\n', stdout); |
315 |
|
/* write picture */ |
316 |
|
writepicture(); |
321 |
|
exit(0); |
322 |
|
userr: |
323 |
|
fprintf(stderr, |
324 |
< |
"Usage: %s [view opts][-t eps][-z zout][-e spec][-a|-q][-fT][-n] pfile zspec ..\n", |
324 |
> |
"Usage: %s [view opts][-t eps][-z zout][-e spec][-B][-a|-q][-fT][-n] pfile zspec ..\n", |
325 |
|
progname); |
326 |
|
exit(1); |
327 |
|
#undef check |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
+ |
int |
332 |
|
headline(s) /* process header string */ |
333 |
|
char *s; |
334 |
|
{ |
335 |
|
char fmt[32]; |
336 |
|
|
337 |
|
if (isheadid(s)) |
338 |
< |
return; |
338 |
> |
return(0); |
339 |
|
if (formatval(fmt, s)) { |
340 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
341 |
< |
return; |
340 |
> |
if (globmatch(ourfmt, fmt)) { |
341 |
> |
wrongformat = 0; |
342 |
> |
strcpy(ourfmt, fmt); |
343 |
> |
} else |
344 |
> |
wrongformat = 1; |
345 |
> |
return(0); |
346 |
|
} |
347 |
< |
putc('\t', stdout); |
348 |
< |
fputs(s, stdout); |
349 |
< |
|
347 |
> |
if (nvavg < 2) { |
348 |
> |
putc('\t', stdout); |
349 |
> |
fputs(s, stdout); |
350 |
> |
} |
351 |
|
if (isexpos(s)) { |
352 |
|
theirexp *= exposval(s); |
353 |
< |
return; |
353 |
> |
return(0); |
354 |
|
} |
355 |
|
if (isview(s) && sscanview(&theirview, s) > 0) |
356 |
|
gotview++; |
357 |
+ |
return(0); |
358 |
|
} |
359 |
|
|
360 |
|
|
361 |
+ |
nextview(fp) /* get and set next view */ |
362 |
+ |
FILE *fp; |
363 |
+ |
{ |
364 |
+ |
char linebuf[256]; |
365 |
+ |
char *err; |
366 |
+ |
register int i; |
367 |
+ |
|
368 |
+ |
if (fp != NULL) { |
369 |
+ |
do /* get new view */ |
370 |
+ |
if (fgets(linebuf, sizeof(linebuf), fp) == NULL) |
371 |
+ |
return(EOF); |
372 |
+ |
while (!isview(linebuf) || !sscanview(&ourview, linebuf)); |
373 |
+ |
} |
374 |
+ |
/* set new view */ |
375 |
+ |
if ((err = setview(&ourview)) != NULL) { |
376 |
+ |
fprintf(stderr, "%s: %s\n", progname, err); |
377 |
+ |
exit(1); |
378 |
+ |
} |
379 |
+ |
if (!nvavg) { /* first view */ |
380 |
+ |
copystruct(&avgview, &ourview); |
381 |
+ |
return(nvavg++); |
382 |
+ |
} |
383 |
+ |
/* add to average view */ |
384 |
+ |
for (i = 0; i < 3; i++) { |
385 |
+ |
avgview.vp[i] += ourview.vp[i]; |
386 |
+ |
avgview.vdir[i] += ourview.vdir[i]; |
387 |
+ |
avgview.vup[i] += ourview.vup[i]; |
388 |
+ |
} |
389 |
+ |
avgview.horiz += ourview.horiz; |
390 |
+ |
avgview.vert += ourview.vert; |
391 |
+ |
avgview.hoff += ourview.hoff; |
392 |
+ |
avgview.voff += ourview.voff; |
393 |
+ |
avgview.vfore += ourview.vfore; |
394 |
+ |
avgview.vaft += ourview.vaft; |
395 |
+ |
return(nvavg++); |
396 |
+ |
} |
397 |
+ |
|
398 |
+ |
|
399 |
+ |
compavgview() /* compute average view */ |
400 |
+ |
{ |
401 |
+ |
register int i; |
402 |
+ |
double f; |
403 |
+ |
|
404 |
+ |
if (nvavg < 2) |
405 |
+ |
return; |
406 |
+ |
f = 1.0/nvavg; |
407 |
+ |
for (i = 0; i < 3; i++) { |
408 |
+ |
avgview.vp[i] *= f; |
409 |
+ |
avgview.vdir[i] *= f; |
410 |
+ |
avgview.vup[i] *= f; |
411 |
+ |
} |
412 |
+ |
avgview.horiz *= f; |
413 |
+ |
avgview.vert *= f; |
414 |
+ |
avgview.hoff *= f; |
415 |
+ |
avgview.voff *= f; |
416 |
+ |
avgview.vfore *= f; |
417 |
+ |
avgview.vaft *= f; |
418 |
+ |
if (setview(&avgview) != NULL) /* in case of emergency... */ |
419 |
+ |
copystruct(&avgview, &ourview); |
420 |
+ |
pixaspect = viewaspect(&avgview) * hresolu / vresolu; |
421 |
+ |
} |
422 |
+ |
|
423 |
+ |
|
424 |
|
addpicture(pfile, zspec) /* add picture to output */ |
425 |
|
char *pfile, *zspec; |
426 |
|
{ |
437 |
|
syserror(pfile); |
438 |
|
/* get header with exposure and view */ |
439 |
|
theirexp = 1.0; |
440 |
+ |
copystruct(&theirview, &stdview); |
441 |
|
gotview = 0; |
442 |
< |
printf("%s:\n", pfile); |
442 |
> |
if (nvavg < 2) |
443 |
> |
printf("%s:\n", pfile); |
444 |
|
getheader(pfp, headline, NULL); |
445 |
|
if (wrongformat || !gotview || !fgetsresolu(&tresolu, pfp)) { |
446 |
|
fprintf(stderr, "%s: picture format error\n", pfile); |
524 |
|
{ |
525 |
|
double m4t[4][4]; |
526 |
|
|
527 |
< |
if (vw1->type != VT_PER && vw1->type != VT_PAR) |
527 |
> |
if (vw1->type != VT_PER & vw1->type != VT_PAR) |
528 |
|
return(0); |
529 |
< |
if (vw2->type != VT_PER && vw2->type != VT_PAR) |
529 |
> |
if (vw2->type != VT_PER & vw2->type != VT_PAR) |
530 |
|
return(0); |
531 |
|
setident4(xfmat); |
532 |
|
xfmat[0][0] = vw1->hvec[0]; |
643 |
|
y1 = p0->y + c1*s1y/l1; |
644 |
|
for (c2 = l2; c2-- > 0; ) { |
645 |
|
x = x1 + c2*s2x/l2; |
646 |
< |
if (x < 0 || x >= hresolu) |
646 |
> |
if (x < 0 | x >= hresolu) |
647 |
|
continue; |
648 |
|
y = y1 + c2*s2y/l2; |
649 |
< |
if (y < 0 || y >= vresolu) |
649 |
> |
if (y < 0 | y >= vresolu) |
650 |
|
continue; |
651 |
|
if (averaging) { |
652 |
|
if (zscan(y)[x] <= 0 || zscan(y)[x]-z |
681 |
|
if (usematrix) { |
682 |
|
pos[0] += theirview.hoff - .5; |
683 |
|
pos[1] += theirview.voff - .5; |
684 |
+ |
if (normdist & theirview.type == VT_PER) |
685 |
+ |
d = sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
686 |
+ |
+ pos[1]*pos[1]*theirview.vn2); |
687 |
+ |
else |
688 |
+ |
d = 1.; |
689 |
+ |
pos[2] += d*theirview.vfore; |
690 |
|
if (theirview.type == VT_PER) { |
691 |
< |
if (normdist) /* adjust distance */ |
594 |
< |
pos[2] /= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
595 |
< |
+ pos[1]*pos[1]*theirview.vn2); |
691 |
> |
pos[2] /= d; |
692 |
|
pos[0] *= pos[2]; |
693 |
|
pos[1] *= pos[2]; |
694 |
|
} |
695 |
|
multp3(pos, pos, theirs2ours); |
696 |
< |
if (pos[2] <= 0) |
696 |
> |
if (pos[2] <= ourview.vfore) |
697 |
|
return(0); |
698 |
|
if (ourview.type == VT_PER) { |
699 |
|
pos[0] /= pos[2]; |
701 |
|
} |
702 |
|
pos[0] += .5 - ourview.hoff; |
703 |
|
pos[1] += .5 - ourview.voff; |
704 |
+ |
pos[2] -= ourview.vfore; |
705 |
|
} else { |
706 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
707 |
|
return(0); |
715 |
|
if (pos[2] <= 0) |
716 |
|
return(0); |
717 |
|
} |
718 |
< |
if (pos[0] < 0 || pos[0] >= 1-FTINY || pos[1] < 0 || pos[1] >= 1-FTINY) |
718 |
> |
if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY) |
719 |
|
return(0); |
720 |
|
if (!averaging) |
721 |
|
return(1); |
932 |
|
for (x = 0; x < hresolu; x++) |
933 |
|
if (zscan(y)[x] <= 0) |
934 |
|
(*fill)(x,y); |
935 |
+ |
if (fill == rcalfill) |
936 |
+ |
clearqueue(); |
937 |
|
} |
938 |
|
|
939 |
|
|
945 |
|
double yzn2, vx; |
946 |
|
|
947 |
|
if (ourview.vaft <= FTINY) |
948 |
< |
return; |
948 |
> |
return(0); |
949 |
|
tstdist = ourview.vaft - ourview.vfore; |
950 |
|
for (y = 0; y < vresolu; y++) { |
951 |
|
if (adjtest) { /* adjust test */ |
969 |
|
zscan(y)[x] = 0.0; |
970 |
|
} |
971 |
|
} |
972 |
+ |
return(1); |
973 |
|
} |
974 |
|
|
975 |
|
|
976 |
+ |
addblur() /* add to blurred picture */ |
977 |
+ |
{ |
978 |
+ |
COLOR cval; |
979 |
+ |
double d; |
980 |
+ |
register int i; |
981 |
+ |
|
982 |
+ |
if (!blurring) |
983 |
+ |
return(0); |
984 |
+ |
i = hresolu*vresolu; |
985 |
+ |
if (nvavg < 2) |
986 |
+ |
if (averaging) |
987 |
+ |
while (i--) { |
988 |
+ |
copycolor(ourbpict[i], ourspict[i]); |
989 |
+ |
d = 1.0/ourweigh[i]; |
990 |
+ |
scalecolor(ourbpict[i], d); |
991 |
+ |
} |
992 |
+ |
else |
993 |
+ |
while (i--) |
994 |
+ |
colr_color(ourbpict[i], ourpict[i]); |
995 |
+ |
else |
996 |
+ |
if (averaging) |
997 |
+ |
while (i--) { |
998 |
+ |
copycolor(cval, ourspict[i]); |
999 |
+ |
d = 1.0/ourweigh[i]; |
1000 |
+ |
scalecolor(cval, d); |
1001 |
+ |
addcolor(ourbpict[i], cval); |
1002 |
+ |
} |
1003 |
+ |
else |
1004 |
+ |
while (i--) { |
1005 |
+ |
colr_color(cval, ourpict[i]); |
1006 |
+ |
addcolor(ourbpict[i], cval); |
1007 |
+ |
} |
1008 |
+ |
/* print view */ |
1009 |
+ |
printf("VIEW%d:", nvavg); |
1010 |
+ |
fprintview(&ourview, stdout); |
1011 |
+ |
putchar('\n'); |
1012 |
+ |
return(1); |
1013 |
+ |
} |
1014 |
+ |
|
1015 |
+ |
|
1016 |
|
writepicture() /* write out picture (alters buffer) */ |
1017 |
|
{ |
1018 |
|
int y; |
1021 |
|
|
1022 |
|
fprtresolu(hresolu, vresolu, stdout); |
1023 |
|
for (y = vresolu-1; y >= 0; y--) |
1024 |
< |
if (averaging) { |
1024 |
> |
if (blurring) { |
1025 |
> |
for (x = 0; x < hresolu; x++) { /* compute avg. */ |
1026 |
> |
d = rexpadj/nvavg; |
1027 |
> |
scalecolor(bscan(y)[x], d); |
1028 |
> |
} |
1029 |
> |
if (fwritescan(bscan(y), hresolu, stdout) < 0) |
1030 |
> |
syserror(progname); |
1031 |
> |
} else if (averaging) { |
1032 |
|
for (x = 0; x < hresolu; x++) { /* average pixels */ |
1033 |
|
d = rexpadj/wscan(y)[x]; |
1034 |
|
scalecolor(sscan(y)[x], d); |
1171 |
|
} |
1172 |
|
/* mark end and get results */ |
1173 |
|
bzero((char *)fbp, 6*sizeof(float)); |
1174 |
< |
if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*queuesiz, |
1174 |
> |
if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*(queuesiz+1), |
1175 |
|
6*sizeof(float)*(queuesiz+1)) != |
1176 |
< |
4*sizeof(float)*queuesiz) { |
1176 |
> |
4*sizeof(float)*(queuesiz+1)) { |
1177 |
|
fprintf(stderr, "%s: error reading from rtrace process\n", |
1178 |
|
progname); |
1179 |
|
exit(1); |