/usr/bin/pbilat is in radiance 4R0+20110410-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/bin/csh -f
# RCSid $Id: pbilat.csh,v 1.3 2008/11/10 19:08:19 greg Exp $
#
# Bilateral Filter (fixed parameters for now)
#
set bfrac=0.02
set sigma=0.4
set vmin=1e-7
if ( $#argv != 1 ) then
goto userr
endif
set inp="$1"
set rad=`getinfo -d < $inp:q | rcalc -i '-Y ${yr} +X ${xr}' -e '$1=sqrt(xr*yr)*'$bfrac`
set extrem=`pextrem -o $inp:q | rcalc -e "vmin:$vmin" -e 'max(a,b):if(a-b,a,b);$1=max($3*.265+$4*.670+$5*.065,vmin)'`
set nseg=`ev "ceil(log10($extrem[2]/$extrem[1])/$sigma)"`
if ( $nseg > 20 ) set nseg=20
onintr done
set tdir=`mktemp -d /tmp/blf.XXXXXX`
set gfunc="sq(x):x*x;gfunc(x):if(sq(x)-sq($sigma),0,sq(1-sq(x/$sigma)))"
set i=0
set imglist=()
while ( $i <= $nseg )
set intens=`ev "$extrem[1]*($extrem[2]/$extrem[1])^($i/$nseg)"`
pcomb -e $gfunc:q -e "vmin:$vmin" \
-e 'max(a,b):if(a-b,a,b);l1=max(li(1),vmin)' \
-e "lo=gfunc(log10(l1)-log10($intens))" \
-o $inp > $tdir/gimg.hdr
pcomb -e 'sf=gi(2);ro=sf*ri(1);go=sf*gi(1);bo=sf*bi(1)' \
-o $inp $tdir/gimg.hdr > $tdir/g_p.hdr
pgblur -r $rad $tdir/g_p.hdr \
| pcomb -e 'sf=if(gi(2)-1e-6,1/gi(2),1e6)' \
-e 'ro=sf*ri(1);go=sf*gi(1);bo=sf*bi(1)' \
- "\!pgblur -r $rad $tdir/gimg.hdr" \
> $tdir/gimg$i.hdr
set imglist=($imglist $tdir/gimg$i.hdr)
@ i++
end
cat > $tdir/interp.cal << _EOF_
{ Segmented intensity image interpolation }
max(a,b) : if(a-b, a, b);
NSEG : $nseg;
l1 = max(li(1), $vmin);
val = NSEG / log($extrem[2]/$extrem[1]) * (log(l1) - log($extrem[1]));
iv = floor(val);
ival = if(iv - (NSEG-1), NSEG-1, max(iv, 0));
xval = val - ival;
ro = (1-xval)*ri(ival+2) + xval*ri(ival+3);
go = (1-xval)*gi(ival+2) + xval*gi(ival+3);
bo = (1-xval)*bi(ival+2) + xval*bi(ival+3);
_EOF_
pcomb -h -f $tdir/interp.cal -o $inp:q $imglist
done:
rm -rf $tdir
exit 0
userr:
echo Usage: $0 input.hdr
|