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.2 by greg, Fri Jan 4 12:05:59 1991 UTC vs.
Revision 2.7 by greg, Mon Aug 25 04:50:32 2008 UTC

# Line 1 | Line 1
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 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:
26 +                set verb
27 +                breaksw
28          case -*:
29                  echo bad option $argv[1]
30                  exit 1
# Line 24 | Line 35 | while ($#argv > 0)
35   end
36   dofiles:
37   onintr quit
38 < set td=/usr/tmp/np$$
39 < mkdir $td
40 < set ha=$0
41 < set ha=$ha:t
42 < if ( $?blend ) then
43 <        set ha="$ha -b"
44 < else
45 <        mknod $td/hf p
46 < endif
38 > set td=`mktemp -d /tmp/np.XXXXXX`
39 > goto skipthis
40 > cat > $td/coef.fmt << '_EOF_'
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;
53 > $5=$3*4*cx*cy; $6=$3*4*cx*sy; $7=$3*4*sx*cy; $8=$3*4*sx*sy;
54 > $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/xres*($1+.5); wy=2*PI/yres*($2+.5);
62 > '_EOF_'
63 > cat > $td/fsub.cal << '_EOF_'
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/xres*(x+.5); wy=2*PI/yres*(y+.5);
74 > '_EOF_'
75 > skipthis:
76   foreach f ($*)
77 <        echo $f\:
78 <        echo adjusting size/exposure...
77 >        if ( $?verb ) then
78 >                echo $f\:
79 >                echo adjusting exposure/size...
80 >        endif
81          $pf $f > $td/pf
82          getinfo < $td/pf > $f
83          ed - $f << _EOF_
# Line 45 | Line 87 | $ha
87   w
88   q
89   _EOF_
90 <        if ( ! $?blend ) then
91 <                getinfo - < $td/hf >> $f &
90 >        set resolu=`getinfo -d < $td/pf | sed 's/-Y \([1-9][0-9]*\) +X \([1-9][0-9]*\)/\2 \1/'`
91 >        if ( ! $?dofsub ) then
92 >                mv $td/pf $td/hf
93 >                goto donefsub
94          endif
95 <        set resolu=`getinfo -d < $td/pf | sed 's/-Y \([0-9]*\) +X \([0-9]*\)/\2 \1/'`
96 <        echo computing Fourier coefficients...
97 <        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`
98 <        echo "cosx cosy sinx siny"
99 <        echo $coef[1-4]
100 <        echo "cosx*cosy cosx*siny sinx*cosy sinx*siny"
101 <        echo $coef[5-8]
102 <        echo removing low frequencies...
103 <        pcomb -e 'ro=ri(1)*f;go=gi(1)*f;bo=bi(1)*f;f=1-fc-fs-f0-f1' \
104 <                -e "fc=$coef[1]*cos(wx)+$coef[2]*cos(wy)" \
105 <                -e "fs=$coef[3]*sin(wx)+$coef[4]*sin(wy)" \
106 <                -e "f0=$coef[5]*cos(wx)*cos(wy)+$coef[6]*cos(wx)*sin(wy)" \
107 <                -e "f1=$coef[7]*sin(wx)*cos(wy)+$coef[8]*sin(wx)*sin(wy)" \
108 <                -e "wx=2*3.1416/$resolu[1]*x;wy=2*3.1416/$resolu[2]*y" \
109 <                $td/pf > $td/hf
95 >        # if ( $?verb ) then
96 >        #       echo computing Fourier coefficients...
97 >        # endif
98 >        # pfilt -1 -x 32 -y 32 $td/pf | pvalue -h \
99 >        #       | rcalc -e 'xres:32;yres:32' -f $td/coef.cal \
100 >        #       | total -m | rcalc -o $td/coef.fmt \
101 >        #       > $td/coef
102 >        if ( $?verb ) then
103 >                # cat $td/coef
104 >                echo removing low frequencies...
105 >        endif
106 >        pgblur -r `ev "sqrt($resolu[1]*$resolu[2])/8"` $td/pf > $td/lf
107 >        pcomb -e 's=1/li(2);ro=s*ri(1);go=s*gi(1);bo=s*bi(1)' \
108 >                        $td/pf $td/lf > $td/hf
109 >        # pcomb -f $td/coef -f $td/fsub.cal $td/pf > $td/hf
110 >        donefsub:
111          if ( $?blend ) then
112 <                echo blending edges...
112 >                if ( $?verb ) then
113 >                        echo blending edges...
114 >                endif
115                  @ mar= $resolu[1] - 3
116 <                pcompos -x 3 $td/hf 0 0 > $td/left
117 <                pcompos $td/hf -$mar 0 > $td/right
116 >                @ les= $resolu[1] - 1
117 >                pcompos -x 1 $td/hf 0 0 | pfilt -1 -x 3 > $td/left
118 >                pcompos $td/hf -$les 0 | pfilt -1 -x 3 > $td/right
119                  pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
120                          -e 'f(p)=(3-x)/7*p(1)+(4+x)/7*p(2)' \
121                          $td/right $td/left > $td/left.patch
# Line 77 | Line 125 | _EOF_
125                  pcompos $td/hf 0 0 $td/left.patch 0 0 $td/right.patch $mar 0 \
126                          > $td/hflr
127                  @ mar= $resolu[2] - 3
128 <                pcompos -y 3 $td/hflr 0 0 > $td/bottom
129 <                pcompos $td/hflr 0 -$mar > $td/top
128 >                @ les= $resolu[2] - 1
129 >                pcompos -y 1 $td/hflr 0 0 | pfilt -1 -y 3 > $td/bottom
130 >                pcompos $td/hflr 0 -$les | pfilt -1 -y 3 > $td/top
131                  pcomb -e 'ro=f(ri);go=f(gi);bo=f(bi)' \
132                          -e 'f(p)=(3-y)/7*p(1)+(4+y)/7*p(2)' \
133                          $td/top $td/bottom > $td/bottom.patch
# Line 87 | Line 136 | _EOF_
136                          $td/bottom $td/top > $td/top.patch
137                  pcompos $td/hflr 0 0 $td/bottom.patch 0 0 $td/top.patch 0 $mar \
138                          | getinfo - >> $f
139 +        else
140 +                getinfo - < $td/hf >> $f
141          endif
142 <        echo $f done.
142 >        if ( $?verb ) then
143 >                echo $f done.
144 >        endif
145   end
146   quit:
147   rm -rf $td

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines