20 |
|
|
21 |
|
#include <ctype.h> |
22 |
|
|
23 |
< |
VIEW ourview = STDVIEW(470); /* viewing parameters */ |
23 |
> |
VIEW ourview = STDVIEW; /* viewing parameters */ |
24 |
> |
int hresolu, vresolu; /* image resolution */ |
25 |
|
|
26 |
|
int psample = 8; /* pixel sample size */ |
27 |
|
double maxdiff = .15; /* max. sample difference */ |
45 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
46 |
|
|
47 |
|
int greyscale = 0; /* map colors to brightness? */ |
48 |
< |
char *devname = "X"; /* output device name */ |
48 |
> |
char *devname = dev_default; /* output device name */ |
49 |
|
|
50 |
|
struct driver *dev = NULL; /* driver functions */ |
51 |
|
|
115 |
|
newimage(); /* set up image */ |
116 |
|
|
117 |
|
for ( ; ; ) { /* quit in command() */ |
118 |
< |
while (ourview.hresolu <= 1<<pdepth && |
119 |
< |
ourview.vresolu <= 1<<pdepth) |
118 |
> |
while (hresolu <= 1<<pdepth && |
119 |
> |
vresolu <= 1<<pdepth) |
120 |
|
command("done: "); |
121 |
|
|
122 |
< |
if (ourview.hresolu <= psample<<pdepth && |
123 |
< |
ourview.vresolu <= psample<<pdepth) { |
122 |
> |
if (hresolu <= psample<<pdepth && |
123 |
> |
vresolu <= psample<<pdepth) { |
124 |
|
sprintf(buf, "%d sampling...\n", 1<<pdepth); |
125 |
|
(*dev->comout)(buf); |
126 |
|
rsample(); |
127 |
|
} else { |
128 |
|
sprintf(buf, "%d refining...\n", 1<<pdepth); |
129 |
|
(*dev->comout)(buf); |
130 |
< |
refine(&ptrunk, 0, 0, ourview.hresolu, |
130 |
< |
ourview.vresolu, pdepth+1); |
130 |
> |
refine(&ptrunk, 0, 0, hresolu, vresolu, pdepth+1); |
131 |
|
} |
132 |
|
if (dev->inpready) |
133 |
|
command(": "); |
145 |
|
char inpbuf[256]; |
146 |
|
char *args; |
147 |
|
again: |
148 |
< |
(*dev->comout)(prompt); /* get command + arguments */ |
149 |
< |
(*dev->comin)(inpbuf); |
148 |
> |
(*dev->comin)(inpbuf, prompt); /* get command + arguments */ |
149 |
|
for (args = inpbuf; *args && *args != ' '; args++) |
150 |
|
; |
151 |
|
if (*args) *args++ = '\0'; |
265 |
|
* difference, we subsample the super-pixels. The testing process |
266 |
|
* includes initialization of the next row. |
267 |
|
*/ |
268 |
< |
xsiz = (((pframe.r-pframe.l)<<pdepth)+ourview.hresolu-1) / |
269 |
< |
ourview.hresolu; |
271 |
< |
ysiz = (((pframe.u-pframe.d)<<pdepth)+ourview.vresolu-1) / |
272 |
< |
ourview.vresolu; |
268 |
> |
xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu; |
269 |
> |
ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu; |
270 |
|
rl = (RECT *)malloc(xsiz*sizeof(RECT)); |
271 |
|
pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); |
272 |
|
if (rl == NULL || pl == NULL) |
275 |
|
* Initialize the bottom row. |
276 |
|
*/ |
277 |
|
rl[0].l = rl[0].d = 0; |
278 |
< |
rl[0].r = ourview.hresolu; rl[0].u = ourview.vresolu; |
278 |
> |
rl[0].r = hresolu; rl[0].u = vresolu; |
279 |
|
pl[0] = findrect(pframe.l, pframe.d, &ptrunk, rl, pdepth); |
280 |
|
for (x = 1; x < xsiz; x++) { |
281 |
|
rl[x].l = rl[x].d = 0; |
282 |
< |
rl[x].r = ourview.hresolu; rl[x].u = ourview.vresolu; |
283 |
< |
pl[x] = findrect(pframe.l+((x*ourview.hresolu)>>pdepth), |
282 |
> |
rl[x].r = hresolu; rl[x].u = vresolu; |
283 |
> |
pl[x] = findrect(pframe.l+((x*hresolu)>>pdepth), |
284 |
|
pframe.d, &ptrunk, rl+x, pdepth); |
285 |
|
} |
286 |
|
/* sample the image */ |
308 |
|
* Find super-pixel at this position in next row. |
309 |
|
*/ |
310 |
|
r.l = r.d = 0; |
311 |
< |
r.r = ourview.hresolu; r.u = ourview.vresolu; |
312 |
< |
p = findrect(pframe.l+((x*ourview.hresolu)>>pdepth), |
313 |
< |
pframe.d+(((y+1)*ourview.vresolu)>>pdepth), |
311 |
> |
r.r = hresolu; r.u = vresolu; |
312 |
> |
p = findrect(pframe.l+((x*hresolu)>>pdepth), |
313 |
> |
pframe.d+(((y+1)*vresolu)>>pdepth), |
314 |
|
&ptrunk, &r, pdepth); |
315 |
|
/* |
316 |
|
* Test super-pixel in next row. |