52 |
|
headline(char *s, void *p) |
53 |
|
{ |
54 |
|
IMGHEAD *ip = (IMGHEAD *)p; |
55 |
< |
char fmt[32]; |
55 |
> |
char fmt[MAXFMTLEN]; |
56 |
|
|
57 |
|
if (isview(s)) { |
58 |
|
ip->gotview += (sscanview(ip->vp, s) > 0); |
111 |
|
exprev = ih.ev; |
112 |
|
if (!fgetsresolu(&rs, fp)) |
113 |
|
goto readerr; |
114 |
+ |
if (rs.rt != PIXSTANDARD) { |
115 |
+ |
sprintf(errmsg, "unsupported orientation in picture \"%s\"", fname); |
116 |
+ |
error(USER, errmsg); |
117 |
+ |
} |
118 |
|
if (!imres.xr) { /* allocate buffers */ |
119 |
|
imres = rs; |
120 |
|
imsum = (COLOR *)ecalloc(imres.xr*imres.yr, sizeof(COLOR)); |
132 |
|
goto readerr; |
133 |
|
fclose(fp); |
134 |
|
sprintf(fname, zbfspec, fno); /* load depth buffer */ |
135 |
< |
if ((fd = open(fname, O_RDONLY)) < 0) { |
135 |
> |
if ((fd = open_float_depth(fname, (long)rs.xr*rs.yr)) < 0) { |
136 |
|
sprintf(errmsg, "cannot open depth buffer \"%s\"", fname); |
137 |
|
error(SYSTEM, errmsg); |
138 |
|
} |
150 |
|
/* Interpolate between two image pixels */ |
151 |
|
/* XXX skipping expensive ray vector calculations for now */ |
152 |
|
static void |
153 |
< |
interp_pixel(COLOR con, const VIEW *vwn, int xn, int yn, double zn, |
154 |
< |
double pos, int xp, int yp) |
153 |
> |
interp_pixel(COLOR con, const VIEW *vwn, int xn, int yn, double zval, |
154 |
> |
double pos, int xp, int yp, int interpOK) |
155 |
|
{ |
156 |
|
const int hres = scanlen(&imres); |
157 |
|
RREAL ipos; |
158 |
|
FVECT wprev, wcoor, rdir; |
159 |
|
int np, xd, yd, nd; |
160 |
|
COLOR cpr; |
161 |
< |
double sf, zval; |
161 |
> |
double sf; |
162 |
|
/* check if off image */ |
163 |
|
if ((xp < 0) | (xp >= hres)) |
164 |
|
return; |
168 |
|
xd = (1.-pos)*xp + pos*xn + .5; |
169 |
|
yd = (1.-pos)*yp + pos*yn + .5; |
170 |
|
nd = yd*hres + xd; |
171 |
< |
/* check interpolated depth */ |
172 |
< |
zval = (1.-pos)*zprev[np] + pos*zn; |
171 |
> |
/* check depth */ |
172 |
> |
if (interpOK) |
173 |
> |
zval = (1.-pos)*zprev[np] + pos*zval; |
174 |
|
if (zval >= zbuf[nd]) |
175 |
|
return; |
176 |
< |
copycolor(imbuf[nd], con); /* assign interpolated color */ |
176 |
> |
zbuf[nd] = zval; /* assign new depth */ |
177 |
> |
copycolor(imbuf[nd], con); /* assign new color */ |
178 |
> |
if (!interpOK) |
179 |
> |
return; |
180 |
|
scalecolor(imbuf[nd], pos); |
181 |
|
sf = (1.-pos)/exprev; |
182 |
|
colr_color(cpr, imprev[np]); |
183 |
|
scalecolor(cpr, sf); |
184 |
|
addcolor(imbuf[nd], cpr); |
177 |
– |
zbuf[nd] = zval; /* assign new depth */ |
185 |
|
} |
186 |
|
|
187 |
|
|
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
< |
/* Fill in missing pixels from immediate neighbors */ |
210 |
> |
/* Expand foreground pixels to mitigate aliasing/fill errors */ |
211 |
|
static void |
212 |
|
fill_missing(void) |
213 |
|
{ |
214 |
|
int n, m; |
215 |
|
|
216 |
|
for (n = imres.xr*imres.yr; n--; ) |
217 |
< |
if (zbuf[n] >= .9*FHUGE && |
211 |
< |
zbuf[m = neigh_zmin(zbuf,n)] < .9*FHUGE) |
217 |
> |
if (zbuf[n] > 1.25*zbuf[m = neigh_zmin(zbuf,n)]) |
218 |
|
copycolor(imbuf[n], imbuf[m]); |
219 |
|
} |
220 |
|
|
264 |
|
error(USER, err); |
265 |
|
if (!fgetsresolu(&rs, fpimg)) |
266 |
|
goto readerr; |
267 |
+ |
if (rs.rt != PIXSTANDARD) { |
268 |
+ |
sprintf(errmsg, "unsupported orientation in picture \"%s\"", fname); |
269 |
+ |
error(USER, errmsg); |
270 |
+ |
} |
271 |
|
if ((rs.xr != imres.xr) | (rs.yr != imres.yr)) { |
272 |
|
sprintf(errmsg, "resolution mismatch for picture \"%s\"", fname); |
273 |
|
error(USER, errmsg); |
321 |
|
scalecolor(cval, sf); |
322 |
|
interp_pixel(cval, &fvw, h, n, zscan[h], fpos, |
323 |
|
h + (int)mscan[3*h] - 32768, |
324 |
< |
n - (int)mscan[3*h+1] + 32768); |
324 |
> |
n - (int)mscan[3*h+1] + 32768, |
325 |
> |
mscan[3*h+2]); |
326 |
|
} |
327 |
|
} |
328 |
|
/* fill in missing pixels */ |
398 |
|
/* get frame range & sampling */ |
399 |
|
switch (sscanf(argv[1], "%lf,%lf/%d", &fstart, &fend, &nsamps)) { |
400 |
|
case 1: |
390 |
– |
nsamps = 0; |
401 |
|
fend = fstart; |
402 |
+ |
nsamps = 0; |
403 |
|
break; |
404 |
|
case 2: |
405 |
|
nsamps = 0; |
407 |
|
case 3: |
408 |
|
if (fend < fstart) |
409 |
|
goto userr; |
410 |
+ |
if (fend <= fstart+FTINY) |
411 |
+ |
nsamps = 0; |
412 |
|
break; |
413 |
|
default: |
414 |
|
goto userr; |
439 |
|
write_average(stdout); |
440 |
|
return(fflush(stdout) == EOF); |
441 |
|
userr: |
442 |
< |
fprintf(stderr, "Usage: %s f0,f1 HDRspec ZBUFspec MVOspec\n", progname); |
442 |
> |
fprintf(stderr, "Usage: %s f0,f1[/n] HDRspec ZBUFspec MVOspec\n", progname); |
443 |
|
return(1); |
444 |
|
} |