ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/normpat.csh
Revision: 1.5
Committed: Fri Jan 4 23:36:35 1991 UTC (33 years, 4 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 1.4: +16 -11 lines
Log Message:
made Fourier transform optional

File Contents

# Content
1 #!/bin/csh -f
2 # SCCSid "$SunId$ LBL"
3 #
4 # Normalize a pattern for tiling (-b option blends edges) by removing
5 # lowest frequencies from image (-f option) and reducing to
6 # standard size (-r option)
7 #
8 set ha=$0
9 set ha=$ha:t
10 set pf="pfilt -e 2"
11 while ($#argv > 0)
12 switch ($argv[1])
13 case -r:
14 shift argv
15 set pf="$pf -x $argv[1] -y $argv[1] -p 1"
16 breaksw
17 case -f:
18 set ha="$ha -f"
19 set dofsub
20 breaksw
21 case -b:
22 set ha="$ha -b"
23 set blend
24 breaksw
25 case -v:
26 set verb
27 breaksw
28 case -*:
29 echo bad option $argv[1]
30 exit 1
31 default:
32 goto dofiles
33 endsw
34 shift argv
35 end
36 dofiles:
37 onintr quit
38 set td=/usr/tmp/np$$
39 mkdir $td
40 cat > $td/coef.fmt << '_EOF_'
41 rcx=${ $1 }; rcy=${ $2 }; rsx=${ $3 }; rsy=${ $4 };
42 rcxcy=${ $5 }; rcxsy=${ $6 }; rsxcy=${ $7 }; rsxsy=${ $8 };
43 gcx=${ $9 }; gcy=${ $10 }; gsx=${ $11 }; gsy=${ $12 };
44 gcxcy=${ $13 }; gcxsy=${ $14 }; gsxcy=${ $15 }; gsxsy=${ $16 };
45 bcx=${ $17 }; bcy=${ $18 }; bsx=${ $19 }; bsy=${ $20 };
46 bcxcy=${ $21 }; bcxsy=${ $22 }; bsxcy=${ $23 }; bsxsy=${ $24 };
47 '_EOF_'
48 cat > $td/coef.cal << '_EOF_'
49 $1=$3*2*cx; $2=$3*2*cy; $3=$3*2*sx; $4=$3*2*sy;
50 $5=$3*4*cx*cy; $6=$3*4*cx*sy; $7=$3*4*sx*cy; $8=$3*4*sx*sy;
51 $9=$4*2*cx; $10=$4*2*cy; $11=$4*2*sx; $12=$4*2*sy;
52 $13=$4*4*cx*cy; $14=$4*4*cx*sy; $15=$4*4*sx*cy; $16=$4*4*sx*sy;
53 $17=$5*2*cx; $18=$5*2*cy; $19=$5*2*sx; $20=$5*2*sy;
54 $21=$5*4*cx*cy; $22=$5*4*cx*sy; $23=$5*4*sx*cy; $24=$5*4*sx*sy;
55 cx=cos(wx); cy=cos(wy);
56 sx=sin(wx); sy=sin(wy);
57 wx=2*PI*($1+.5)/xres; wy=2*PI*($2+.5)/yres;
58 '_EOF_'
59 cat > $td/fsub.cal << '_EOF_'
60 ro=ri(1)-rcx*cx-rcy*cy-rsx*sx-rsy*sy
61 -rcxcy*cx*cy-rcxsy*cx*sy-rsxcy*sx*cy-rsxsy*sx*sy;
62 go=gi(1)-gcx*cx-gcy*cy-gsx*sx-gsy*sy
63 -gcxcy*cx*cy-gcxsy*cx*sy-gsxcy*sx*cy-gsxsy*sx*sy;
64 bo=bi(1)-bcx*cx-bcy*cy-bsx*sx-bsy*sy
65 -bcxcy*cx*cy-bcxsy*cx*sy-bsxcy*sx*cy-bsxsy*sx*sy;
66 cx=cos(wx); cy=cos(wy);
67 sx=sin(wx); sy=sin(wy);
68 wx=2*PI*(x+.5)/xres; wy=2*PI*(y+.5)/yres;
69 PI=3.14159265358979323846;
70 '_EOF_'
71 foreach f ($*)
72 if ( $?verb ) then
73 echo $f\:
74 echo adjusting exposure/size...
75 endif
76 $pf $f > $td/pf
77 getinfo < $td/pf > $f
78 ed - $f << _EOF_
79 i
80 $ha
81 .
82 w
83 q
84 _EOF_
85 set resolu=`getinfo -d < $td/pf | sed 's/-Y \([0-9]*\) +X \([0-9]*\)/\2 \1/'`
86 if ( ! $?dofsub ) then
87 mv $td/pf $td/hf
88 goto donefsub
89 endif
90 if ( $?verb ) then
91 echo computing Fourier coefficients...
92 endif
93 pfilt -1 -x 32 -y 32 $td/pf | pvalue -h \
94 | rcalc -f $td/coef.cal -e 'xres=32;yres=32' \
95 | total -m | rcalc -o $td/coef.fmt \
96 > $td/coef
97 if ( $?verb ) then
98 cat $td/coef
99 echo removing low frequencies...
100 endif
101 pcomb -f $td/fsub.cal -f $td/coef \
102 -e "xres=$resolu[1];yres=$resolu[2]" \
103 $td/pf > $td/hf
104 donefsub:
105 if ( $?blend ) then
106 if ( $?verb ) then
107 echo blending edges...
108 endif
109 @ mar= $resolu[1] - 3
110 pcompos -x 3 $td/hf 0 0 > $td/left
111 pcompos $td/hf -$mar 0 > $td/right
112 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
113 -e 'f(p)=(3-x)/7*p(1)+(4+x)/7*p(2)' \
114 $td/right $td/left > $td/left.patch
115 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
116 -e 'f(p)=(1+x)/7*p(1)+(6-x)/7*p(2)' \
117 $td/left $td/right > $td/right.patch
118 pcompos $td/hf 0 0 $td/left.patch 0 0 $td/right.patch $mar 0 \
119 > $td/hflr
120 @ mar= $resolu[2] - 3
121 pcompos -y 3 $td/hflr 0 0 > $td/bottom
122 pcompos $td/hflr 0 -$mar > $td/top
123 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
124 -e 'f(p)=(3-y)/7*p(1)+(4+y)/7*p(2)' \
125 $td/top $td/bottom > $td/bottom.patch
126 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
127 -e 'f(p)=(1+y)/7*p(1)+(6-y)/7*p(2)' \
128 $td/bottom $td/top > $td/top.patch
129 pcompos $td/hflr 0 0 $td/bottom.patch 0 0 $td/top.patch 0 $mar \
130 | getinfo - >> $f
131 else
132 getinfo - < $td/hf >> $f
133 endif
134 if ( $?verb ) then
135 echo $f done.
136 endif
137 end
138 quit:
139 rm -rf $td