ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/normpat.csh
(Generate patch)

Comparing ray/src/px/normpat.csh (file contents):
Revision 1.4 by greg, Fri Jan 4 23:01:51 1991 UTC vs.
Revision 2.2 by greg, Sun Jan 5 18:14:47 1992 UTC

# Line 2 | Line 2
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)
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"
15 >                set pf="$pf -x $argv[1] -y $argv[1] -p 1 -r .67"
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:
# Line 29 | Line 37 | dofiles:
37   onintr quit
38   set td=/usr/tmp/np$$
39   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
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   };
41 >   rm:${  $25   };    gm:${  $26   };    bm:${  $27   };
42 >  rcx:${   $1   };   gcx:${   $9   };   bcx:${  $17   };
43 >  rcy:${   $2   };   gcy:${  $10   };   bcy:${  $18   };
44 >  rsx:${   $3   };   gsx:${  $11   };   bsx:${  $19   };
45 >  rsy:${   $4   };   gsy:${  $12   };   bsy:${  $20   };
46 > rcxcy:${   $5   }; gcxcy:${  $13   }; bcxcy:${  $21   };
47 > rcxsy:${   $6   }; gcxsy:${  $14   }; bcxsy:${  $22   };
48 > rsxcy:${   $7   }; gsxcy:${  $15   }; bsxcy:${  $23   };
49 > rsxsy:${   $8   }; gsxsy:${  $16   }; bsxsy:${  $24   };
50   '_EOF_'
51   cat > $td/coef.cal << '_EOF_'
52   $1=$3*2*cx; $2=$3*2*cy; $3=$3*2*sx; $4=$3*2*sy;
# Line 51 | Line 55 | $9=$4*2*cx; $10=$4*2*cy; $11=$4*2*sx; $12=$4*2*sy;
55   $13=$4*4*cx*cy; $14=$4*4*cx*sy; $15=$4*4*sx*cy; $16=$4*4*sx*sy;
56   $17=$5*2*cx; $18=$5*2*cy; $19=$5*2*sx; $20=$5*2*sy;
57   $21=$5*4*cx*cy; $22=$5*4*cx*sy; $23=$5*4*sx*cy; $24=$5*4*sx*sy;
58 + $25=$3; $26=$4; $27=$5;
59   cx=cos(wx); cy=cos(wy);
60   sx=sin(wx); sy=sin(wy);
61   wx=2*PI*($1+.5)/xres; wy=2*PI*($2+.5)/yres;
62   '_EOF_'
63   cat > $td/fsub.cal << '_EOF_'
64 < ro=ri(1)-rcx*cx-rcy*cy-rsx*sx-rsy*sy
65 <        -rcxcy*cx*cy-rcxsy*cx*sy-rsxcy*sx*cy-rsxsy*sx*sy;
66 < go=gi(1)-gcx*cx-gcy*cy-gsx*sx-gsy*sy
67 <        -gcxcy*cx*cy-gcxsy*cx*sy-gsxcy*sx*cy-gsxsy*sx*sy;
68 < bo=bi(1)-bcx*cx-bcy*cy-bsx*sx-bsy*sy
69 <        -bcxcy*cx*cy-bcxsy*cx*sy-bsxcy*sx*cy-bsxsy*sx*sy;
64 > PI:3.14159265358979323846;
65 > ro=ri(1)*rm/(rm+rcx*cx+rcy*cy+rsx*sx+rsy*sy
66 >                +rcxcy*cx*cy+rcxsy*cx*sy+rsxcy*sx*cy+rsxsy*sx*sy);
67 > go=gi(1)*gm/(gm+gcx*cx+gcy*cy+gsx*sx+gsy*sy
68 >                +gcxcy*cx*cy+gcxsy*cx*sy+gsxcy*sx*cy+gsxsy*sx*sy);
69 > bo=bi(1)*bm/(bm+bcx*cx+bcy*cy+bsx*sx+bsy*sy
70 >                +bcxcy*cx*cy+bcxsy*cx*sy+bsxcy*sx*cy+bsxsy*sx*sy);
71   cx=cos(wx); cy=cos(wy);
72   sx=sin(wx); sy=sin(wy);
73   wx=2*PI*(x+.5)/xres; wy=2*PI*(y+.5)/yres;
68 PI=3.14159265358979323846;
74   '_EOF_'
75   foreach f ($*)
76          if ( $?verb ) then
# Line 82 | Line 87 | w
87   q
88   _EOF_
89          set resolu=`getinfo -d < $td/pf | sed 's/-Y \([0-9]*\) +X \([0-9]*\)/\2 \1/'`
90 +        if ( ! $?dofsub ) then
91 +                mv $td/pf $td/hf
92 +                goto donefsub
93 +        endif
94          if ( $?verb ) then
95                  echo computing Fourier coefficients...
96          endif
# Line 93 | Line 102 | _EOF_
102                  cat $td/coef
103                  echo removing low frequencies...
104          endif
105 <        if ( ! $?blend ) then
97 <                ( getinfo - < $td/hf >> $f & ) > /dev/null
98 <        endif
99 <        pcomb -f $td/fsub.cal -f $td/coef \
105 >        pcomb -f $td/coef -f $td/fsub.cal \
106                  -e "xres=$resolu[1];yres=$resolu[2]" \
107                  $td/pf > $td/hf
108 +        donefsub:
109          if ( $?blend ) then
110                  if ( $?verb ) then
111                          echo blending edges...
112                  endif
113                  @ mar= $resolu[1] - 3
114 <                pcompos -x 3 $td/hf 0 0 > $td/left
115 <                pcompos $td/hf -$mar 0 > $td/right
114 >                @ les= $resolu[1] - 1
115 >                pcompos -x 1 $td/hf 0 0 | pfilt -1 -x 3 > $td/left
116 >                pcompos $td/hf -$les 0 | pfilt -1 -x 3 > $td/right
117                  pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
118                          -e 'f(p)=(3-x)/7*p(1)+(4+x)/7*p(2)' \
119                          $td/right $td/left > $td/left.patch
# Line 115 | Line 123 | _EOF_
123                  pcompos $td/hf 0 0 $td/left.patch 0 0 $td/right.patch $mar 0 \
124                          > $td/hflr
125                  @ mar= $resolu[2] - 3
126 <                pcompos -y 3 $td/hflr 0 0 > $td/bottom
127 <                pcompos $td/hflr 0 -$mar > $td/top
126 >                @ les= $resolu[2] - 1
127 >                pcompos -y 1 $td/hflr 0 0 | pfilt -1 -y 3 > $td/bottom
128 >                pcompos $td/hflr 0 -$les | pfilt -1 -y 3 > $td/top
129                  pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
130                          -e 'f(p)=(3-y)/7*p(1)+(4+y)/7*p(2)' \
131                          $td/top $td/bottom > $td/bottom.patch
# Line 125 | Line 134 | _EOF_
134                          $td/bottom $td/top > $td/top.patch
135                  pcompos $td/hflr 0 0 $td/bottom.patch 0 0 $td/top.patch 0 $mar \
136                          | getinfo - >> $f
137 +        else
138 +                getinfo - < $td/hf >> $f
139          endif
140          if ( $?verb ) then
141                  echo $f done.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines