5 |
|
set Ldmax=100 # maximum display luminance |
6 |
|
set nsteps=100 # number of steps in perceptual histogram |
7 |
|
set cvratio=0.05 # fraction of pixels to ignore in envelope clipping |
8 |
< |
set td=/usr/tmp |
8 |
> |
set td=/tmp |
9 |
|
set tf0=$td/tf$$ |
10 |
|
set tf1=$td/hist$$ |
11 |
|
set tf1b=$td/hist$$.diff |
18 |
|
shift argv |
19 |
|
endif |
20 |
|
if ( $#argv != 1 ) then |
21 |
< |
echo "Usage: $0 [-a] input.pic > output.pic" |
21 |
> |
echo "Usage: $0 [-a] input.hdr > output.hdr" |
22 |
|
exit 1 |
23 |
|
endif |
24 |
|
set ifile=$1 |
25 |
|
set ibase=$ifile:t |
26 |
< |
if ( "$ibase" =~ *.pic ) set ibase=$ibase:r |
26 |
> |
if ( "$ibase" =~ *.hdr ) set ibase=$ibase:r |
27 |
|
set ibase=$ibase:t |
28 |
|
onintr quit |
29 |
|
pextrem -o $ifile > $tf0 |
100 |
|
while ( 1 ) |
101 |
|
# Compute mapping function |
102 |
|
sed 's/^.*[ ]//' $tf1 | total -1 -r \ |
103 |
< |
| rcalc -e '$1=$1/'$totcount | lam $tf1 - \ |
103 |
> |
| rcalc -e '$1=$1/'$totcount | rlam $tf1 - \ |
104 |
|
| tabfunc -i 0 cf > $tf4 |
105 |
|
# Compute difference with visible envelope |
106 |
|
rcalc -f $tf4 -f $tf3 -e "T:$totcount*Stepsiz" \ |
149 |
|
endif |
150 |
|
end |
151 |
|
# Mung histogram |
152 |
< |
echo $diffs | tr ' ' '\012' | lam $tf1 - \ |
152 |
> |
echo $diffs | tr ' ' '\012' | rlam $tf1 - \ |
153 |
|
| rcalc -f $tf4 -f $tf3 -e "T:$totcount*Stepsiz" \ |
154 |
|
-e 'clfq=floor(T*clamp(Lb($1))+.5)' \ |
155 |
|
-e '$1=$1;$2=$3+clfq' > $tf1b |