ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/normpat.csh
Revision: 1.3
Committed: Fri Jan 4 16:54:25 1991 UTC (33 years, 4 months ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 1.2: +28 -14 lines
Log Message:
fixed calculation of normalization

File Contents

# User Rev Content
1 greg 1.1 #!/bin/csh -f
2     # SCCSid "$SunId$ LBL"
3     #
4 greg 1.2 # Normalize a pattern for tiling (-b option blends edges) by removing
5     # lowest frequencies from image and reducing to standard size (-r option)
6 greg 1.1 #
7 greg 1.2 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 greg 1.3 case -v:
18     set verb
19     breaksw
20 greg 1.2 case -*:
21     echo bad option $argv[1]
22     exit 1
23     default:
24     goto dofiles
25     endsw
26     shift argv
27     end
28     dofiles:
29     onintr quit
30     set td=/usr/tmp/np$$
31     mkdir $td
32     set ha=$0
33     set ha=$ha:t
34     if ( $?blend ) then
35     set ha="$ha -b"
36     else
37     mknod $td/hf p
38     endif
39 greg 1.1 foreach f ($*)
40 greg 1.3 if ( $?verb ) then
41     echo $f\:
42     echo adjusting exposure/size...
43     endif
44 greg 1.2 $pf $f > $td/pf
45     getinfo < $td/pf > $f
46     ed - $f << _EOF_
47     i
48     $ha
49     .
50     w
51     q
52     _EOF_
53 greg 1.3 set resolu=`getinfo -d < $td/pf | sed 's/-Y \([0-9]*\) +X \([0-9]*\)/\2 \1/'`
54     if ( $?verb ) then
55     echo computing Fourier coefficients...
56     endif
57     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`
58     if ( $?verb ) then
59     echo "cosx cosy sinx siny"
60     echo $coef[1-4]
61     echo "cosx*cosy cosx*siny sinx*cosy sinx*siny"
62     echo $coef[5-8]
63     echo removing low frequencies...
64     endif
65 greg 1.2 if ( ! $?blend ) then
66 greg 1.3 ( getinfo - < $td/hf >> $f & ) > /dev/null
67 greg 1.2 endif
68 greg 1.3 pcomb -e 'ro=f*ri(1);go=f*gi(1);bo=f*bi(1);f=(i-fc-fs-f0-f1)/i' \
69     -e 'i=.263*ri(1)+.655*gi(1)+.082*bi(1)' \
70 greg 1.1 -e "fc=$coef[1]*cos(wx)+$coef[2]*cos(wy)" \
71     -e "fs=$coef[3]*sin(wx)+$coef[4]*sin(wy)" \
72     -e "f0=$coef[5]*cos(wx)*cos(wy)+$coef[6]*cos(wx)*sin(wy)" \
73     -e "f1=$coef[7]*sin(wx)*cos(wy)+$coef[8]*sin(wx)*sin(wy)" \
74     -e "wx=2*3.1416/$resolu[1]*x;wy=2*3.1416/$resolu[2]*y" \
75 greg 1.2 $td/pf > $td/hf
76     if ( $?blend ) then
77 greg 1.3 if ( $?verb ) then
78     echo blending edges...
79     endif
80 greg 1.2 @ mar= $resolu[1] - 3
81     pcompos -x 3 $td/hf 0 0 > $td/left
82     pcompos $td/hf -$mar 0 > $td/right
83     pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
84     -e 'f(p)=(3-x)/7*p(1)+(4+x)/7*p(2)' \
85     $td/right $td/left > $td/left.patch
86     pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
87     -e 'f(p)=(1+x)/7*p(1)+(6-x)/7*p(2)' \
88     $td/left $td/right > $td/right.patch
89     pcompos $td/hf 0 0 $td/left.patch 0 0 $td/right.patch $mar 0 \
90     > $td/hflr
91     @ mar= $resolu[2] - 3
92     pcompos -y 3 $td/hflr 0 0 > $td/bottom
93     pcompos $td/hflr 0 -$mar > $td/top
94     pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
95     -e 'f(p)=(3-y)/7*p(1)+(4+y)/7*p(2)' \
96     $td/top $td/bottom > $td/bottom.patch
97     pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
98     -e 'f(p)=(1+y)/7*p(1)+(6-y)/7*p(2)' \
99     $td/bottom $td/top > $td/top.patch
100     pcompos $td/hflr 0 0 $td/bottom.patch 0 0 $td/top.patch 0 $mar \
101     | getinfo - >> $f
102     endif
103 greg 1.3 if ( $?verb ) then
104     echo $f done.
105     endif
106 greg 1.1 end
107 greg 1.2 quit:
108     rm -rf $td