ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/normpat.csh
Revision: 1.2
Committed: Fri Jan 4 12:05:59 1991 UTC (33 years, 4 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 1.1: +82 -7 lines
Log Message:
added edge blending and resolution options

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 and reducing to standard size (-r option)
6 #
7 set pf="pfilt -e 2"
8 while ($#argv > 0)
9 switch ($argv[1])
10 case -r:
11 shift argv
12 set pf="$pf -x $argv[1] -y $argv[1] -p 1"
13 breaksw
14 case -b:
15 set blend
16 breaksw
17 case -*:
18 echo bad option $argv[1]
19 exit 1
20 default:
21 goto dofiles
22 endsw
23 shift argv
24 end
25 dofiles:
26 onintr quit
27 set td=/usr/tmp/np$$
28 mkdir $td
29 set ha=$0
30 set ha=$ha:t
31 if ( $?blend ) then
32 set ha="$ha -b"
33 else
34 mknod $td/hf p
35 endif
36 foreach f ($*)
37 echo $f\:
38 echo adjusting size/exposure...
39 $pf $f > $td/pf
40 getinfo < $td/pf > $f
41 ed - $f << _EOF_
42 i
43 $ha
44 .
45 w
46 q
47 _EOF_
48 if ( ! $?blend ) then
49 getinfo - < $td/hf >> $f &
50 endif
51 set resolu=`getinfo -d < $td/pf | sed 's/-Y \([0-9]*\) +X \([0-9]*\)/\2 \1/'`
52 echo computing Fourier coefficients...
53 set coef=`pfilt -1 -x 32 -y 32 $td/pf | pvalue -h -b | rcalc -e '$1=2*$3*cos(wx);$2=2*$3*cos(wy);$3=2*$3*sin(wx);$4=2*$3*sin(wy);$5=4*$3*cos(wx)*cos(wy);$6=4*$3*cos(wx)*sin(wy);$7=4*$3*sin(wx)*cos(wy);$8=4*$3*sin(wx)*sin(wy);' -e 'wx=2*PI/32*$1;wy=2*PI/32*$2' | total -m`
54 echo "cosx cosy sinx siny"
55 echo $coef[1-4]
56 echo "cosx*cosy cosx*siny sinx*cosy sinx*siny"
57 echo $coef[5-8]
58 echo removing low frequencies...
59 pcomb -e 'ro=ri(1)*f;go=gi(1)*f;bo=bi(1)*f;f=1-fc-fs-f0-f1' \
60 -e "fc=$coef[1]*cos(wx)+$coef[2]*cos(wy)" \
61 -e "fs=$coef[3]*sin(wx)+$coef[4]*sin(wy)" \
62 -e "f0=$coef[5]*cos(wx)*cos(wy)+$coef[6]*cos(wx)*sin(wy)" \
63 -e "f1=$coef[7]*sin(wx)*cos(wy)+$coef[8]*sin(wx)*sin(wy)" \
64 -e "wx=2*3.1416/$resolu[1]*x;wy=2*3.1416/$resolu[2]*y" \
65 $td/pf > $td/hf
66 if ( $?blend ) then
67 echo blending edges...
68 @ mar= $resolu[1] - 3
69 pcompos -x 3 $td/hf 0 0 > $td/left
70 pcompos $td/hf -$mar 0 > $td/right
71 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
72 -e 'f(p)=(3-x)/7*p(1)+(4+x)/7*p(2)' \
73 $td/right $td/left > $td/left.patch
74 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
75 -e 'f(p)=(1+x)/7*p(1)+(6-x)/7*p(2)' \
76 $td/left $td/right > $td/right.patch
77 pcompos $td/hf 0 0 $td/left.patch 0 0 $td/right.patch $mar 0 \
78 > $td/hflr
79 @ mar= $resolu[2] - 3
80 pcompos -y 3 $td/hflr 0 0 > $td/bottom
81 pcompos $td/hflr 0 -$mar > $td/top
82 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
83 -e 'f(p)=(3-y)/7*p(1)+(4+y)/7*p(2)' \
84 $td/top $td/bottom > $td/bottom.patch
85 pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
86 -e 'f(p)=(1+y)/7*p(1)+(6-y)/7*p(2)' \
87 $td/bottom $td/top > $td/top.patch
88 pcompos $td/hflr 0 0 $td/bottom.patch 0 0 $td/top.patch 0 $mar \
89 | getinfo - >> $f
90 endif
91 echo $f done.
92 end
93 quit:
94 rm -rf $td