empirical tweaks to emc algorithm
[stereofy] / stereofy.sh
1 #!/bin/sh
2
3 algo="d"   #algorythm, Dubois by default
4 model="rc" #color model, green-magenta by default
5 param=""   #leave blank, will be -$algo$model
6 left=''
7 right=''
8 stereo=''
9
10 while [ -n "$1" ]; do
11   case "$1" in
12     -d|--dubois) algo="d";;
13     -f|--full|--full-color) algo="f";;
14     -h|--half|--half-color) algo="d";;
15     -rc|--rc|--red-cyan) model="rc";;
16     -mc|--mc|--magenta-cyan) model="mc";;
17     -gm|--gm|--green-magenta) model="gm";;
18     -ab|--ab|--amber-blue|yellow-blue) model="ab";;
19     -[dfh]rc|-[dfh]gm|-[fe]mc|-dab) param="$1";;
20     -*) echo "no such color model" >/dev/stderr; exit 1;;
21     *)  if [ -z "$left" ]; then
22           left="$1"
23         elif [ -z "$right" ]; then
24           right="$1"
25         elif [ -z "$stereo" ]; then
26           stereo="$1"
27         fi
28         ;;
29   esac
30   shift 1;
31 done
32
33 [ -z "$param" ] && param="-$algo$model"
34 [ -z "$stereo" ] && stereo="${left}_stereo.jpg"
35
36 geom=$(identify "$left" |sed -rn 's:^.* ([0-9]+x[0-9]+) .*$:\1:gp')
37
38 echo -n bitmapping...
39 stream "$left" "$left.bts"
40 stream "$right" "$right.bts"
41
42 echo -n anaglyphing...
43 anaglyph "$param" "$left.bts" "$right.bts" "$stereo.bts"
44
45 if [ $? = 0 ]; then
46   echo -n converting...
47   convert -depth 8 -size "$geom" "rgb:$stereo.bts" "$stereo"
48 fi
49
50 echo cleaning...
51 rm "$left.bts" "$right.bts" "$stereo.bts" 2>/dev/null