1 |
|
#!/bin/csh -f |
2 |
< |
# SCCSid "$SunId$ LBL" |
2 |
> |
# RCSid: $Id$ |
3 |
|
# |
4 |
|
# Normalize a pattern for tiling (-b option blends edges) by removing |
5 |
|
# lowest frequencies from image (-f option) and reducing to |
35 |
|
end |
36 |
|
dofiles: |
37 |
|
onintr quit |
38 |
< |
set td=/usr/tmp/np$$ |
38 |
> |
set td=/tmp/np$$ |
39 |
|
mkdir $td |
40 |
+ |
goto skipthis |
41 |
|
cat > $td/coef.fmt << '_EOF_' |
42 |
< |
rm=${ $25 }; gm=${ $26 }; bm=${ $27 }; |
43 |
< |
rcx=${ $1 }; gcx=${ $9 }; bcx=${ $17 }; |
44 |
< |
rcy=${ $2 }; gcy=${ $10 }; bcy=${ $18 }; |
45 |
< |
rsx=${ $3 }; gsx=${ $11 }; bsx=${ $19 }; |
46 |
< |
rsy=${ $4 }; gsy=${ $12 }; bsy=${ $20 }; |
47 |
< |
rcxcy=${ $5 }; gcxcy=${ $13 }; bcxcy=${ $21 }; |
48 |
< |
rcxsy=${ $6 }; gcxsy=${ $14 }; bcxsy=${ $22 }; |
49 |
< |
rsxcy=${ $7 }; gsxcy=${ $15 }; bsxcy=${ $23 }; |
50 |
< |
rsxsy=${ $8 }; gsxsy=${ $16 }; bsxsy=${ $24 }; |
42 |
> |
rm:${ $25 }; gm:${ $26 }; bm:${ $27 }; |
43 |
> |
rcx:${ $1 }; gcx:${ $9 }; bcx:${ $17 }; |
44 |
> |
rcy:${ $2 }; gcy:${ $10 }; bcy:${ $18 }; |
45 |
> |
rsx:${ $3 }; gsx:${ $11 }; bsx:${ $19 }; |
46 |
> |
rsy:${ $4 }; gsy:${ $12 }; bsy:${ $20 }; |
47 |
> |
rcxcy:${ $5 }; gcxcy:${ $13 }; bcxcy:${ $21 }; |
48 |
> |
rcxsy:${ $6 }; gcxsy:${ $14 }; bcxsy:${ $22 }; |
49 |
> |
rsxcy:${ $7 }; gsxcy:${ $15 }; bsxcy:${ $23 }; |
50 |
> |
rsxsy:${ $8 }; gsxsy:${ $16 }; bsxsy:${ $24 }; |
51 |
|
'_EOF_' |
52 |
|
cat > $td/coef.cal << '_EOF_' |
53 |
|
$1=$3*2*cx; $2=$3*2*cy; $3=$3*2*sx; $4=$3*2*sy; |
59 |
|
$25=$3; $26=$4; $27=$5; |
60 |
|
cx=cos(wx); cy=cos(wy); |
61 |
|
sx=sin(wx); sy=sin(wy); |
62 |
< |
wx=2*PI*($1+.5)/xres; wy=2*PI*($2+.5)/yres; |
62 |
> |
wx=2*PI/xres*($1+.5); wy=2*PI/yres*($2+.5); |
63 |
|
'_EOF_' |
64 |
|
cat > $td/fsub.cal << '_EOF_' |
65 |
+ |
PI:3.14159265358979323846; |
66 |
|
ro=ri(1)*rm/(rm+rcx*cx+rcy*cy+rsx*sx+rsy*sy |
67 |
|
+rcxcy*cx*cy+rcxsy*cx*sy+rsxcy*sx*cy+rsxsy*sx*sy); |
68 |
|
go=gi(1)*gm/(gm+gcx*cx+gcy*cy+gsx*sx+gsy*sy |
71 |
|
+bcxcy*cx*cy+bcxsy*cx*sy+bsxcy*sx*cy+bsxsy*sx*sy); |
72 |
|
cx=cos(wx); cy=cos(wy); |
73 |
|
sx=sin(wx); sy=sin(wy); |
74 |
< |
wx=2*PI*(x+.5)/xres; wy=2*PI*(y+.5)/yres; |
73 |
< |
PI=3.14159265358979323846; |
74 |
> |
wx=2*PI/xres*(x+.5); wy=2*PI/yres*(y+.5); |
75 |
|
'_EOF_' |
76 |
+ |
skipthis: |
77 |
|
foreach f ($*) |
78 |
|
if ( $?verb ) then |
79 |
|
echo $f\: |
88 |
|
w |
89 |
|
q |
90 |
|
_EOF_ |
91 |
< |
set resolu=`getinfo -d < $td/pf | sed 's/-Y \([0-9]*\) +X \([0-9]*\)/\2 \1/'` |
91 |
> |
set resolu=`getinfo -d < $td/pf | sed 's/-Y \([1-9][0-9]*\) +X \([1-9][0-9]*\)/\2 \1/'` |
92 |
|
if ( ! $?dofsub ) then |
93 |
|
mv $td/pf $td/hf |
94 |
|
goto donefsub |
95 |
|
endif |
96 |
+ |
# if ( $?verb ) then |
97 |
+ |
# echo computing Fourier coefficients... |
98 |
+ |
# endif |
99 |
+ |
# pfilt -1 -x 32 -y 32 $td/pf | pvalue -h \ |
100 |
+ |
# | rcalc -e 'xres:32;yres:32' -f $td/coef.cal \ |
101 |
+ |
# | total -m | rcalc -o $td/coef.fmt \ |
102 |
+ |
# > $td/coef |
103 |
|
if ( $?verb ) then |
104 |
< |
echo computing Fourier coefficients... |
96 |
< |
endif |
97 |
< |
pfilt -1 -x 32 -y 32 $td/pf | pvalue -h \ |
98 |
< |
| rcalc -f $td/coef.cal -e 'xres=32;yres=32' \ |
99 |
< |
| total -m | rcalc -o $td/coef.fmt \ |
100 |
< |
> $td/coef |
101 |
< |
if ( $?verb ) then |
102 |
< |
cat $td/coef |
104 |
> |
# cat $td/coef |
105 |
|
echo removing low frequencies... |
106 |
|
endif |
107 |
< |
pcomb -f $td/fsub.cal -f $td/coef \ |
108 |
< |
-e "xres=$resolu[1];yres=$resolu[2]" \ |
109 |
< |
$td/pf > $td/hf |
107 |
> |
pgblur -r `ev "sqrt($resolu[1]*$resolu[2])/8"` $td/pf > $td/lf |
108 |
> |
pcomb -e 's=1/li(2);ro=s*ri(1);go=s*gi(1);bo=s*bi(1)' \ |
109 |
> |
$td/pf $td/lf > $td/hf |
110 |
> |
# pcomb -f $td/coef -f $td/fsub.cal $td/pf > $td/hf |
111 |
|
donefsub: |
112 |
|
if ( $?blend ) then |
113 |
|
if ( $?verb ) then |