-
Notifications
You must be signed in to change notification settings - Fork 7
/
unsharp.sh
executable file
·62 lines (55 loc) · 1.5 KB
/
unsharp.sh
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
57
58
59
60
61
62
#!/bin/bash
# Part of Macro-scripts package (a complete Open Source workflow for processing macro focus stacking photographs)
# Written by Sergey Mashchenko
# Unsharp masking for macro shots, using three different unsharp scales
# Good numbers: 4:0.5:0.5
# Radii for the three scales (pixels):
#rad_x=24
rad_x=22
#rad_y=6
rad_y=6
# 1.5:
rad_z=2
# Default strength for each scale:
s_x=0.05
s_y=0.15
# 1:
s_z=1
echo
if test $# -eq 0
then
echo "Syntax: unsharp.sh [strength] in_file out_file"
echo
echo "If 'strength' is skipped, it is assumed to be 1."
echo "If 'strength' is a single number, all spatial scales will be sharpened by the same amount (given by that number)."
echo "If 'strength' has the following form - x:y:z - the largest scale will be sharpened using 'x' strength,"
echo " the middle scale will use 'y', and the smallest scale will use 'z'."
echo
exit
fi
if test $# -eq 2
then
x=1
y=1
z=1
IN="$1"
OUT="$2"
else
IN="$2"
OUT="$3"
N=`echo $1 |grep : |wc -l `
if test $N -eq 0
then
x=$1
y=$1
z=$1
else
x=`echo $1 | cut -d: -f1`
y=`echo $1 | cut -d: -f2`
z=`echo $1 | cut -d: -f3`
fi
fi
echo "Using the large/middle/small scale sharpening strengths $x, $y, $z"
echo
# Unsharp masking, done in the following order: large scale, middle scale, small scale:
convert "$IN" -unsharp 0x$rad_x+`echo $x $s_x | awk '{print $1*$2}'`+0 -unsharp 0x$rad_y+`echo $y $s_y | awk '{print $1*$2}'`+0 -unsharp 0x$rad_z+`echo $z $s_z | awk '{print $1*$2}'`+0 "$OUT"