| 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 |
| 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 |