From d756f57d5612c2fa4b6fff7db9af57ffbaef59cc Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 29 Oct 2011 22:28:25 +0000 Subject: [PATCH] empirical tweaks to emc algorithm svn path=/trunk/; revision=4 --- anaglyph.c | 29 ++++++++++++----------------- stereofy.sh | 27 ++++++++++----------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/anaglyph.c b/anaglyph.c index 4aa84ff..1ade952 100644 --- a/anaglyph.c +++ b/anaglyph.c @@ -100,11 +100,11 @@ unsigned char* half_rc(unsigned char *out, const unsigned char *l, const unsigne //red-cyan Dubois unsigned char* dubois_rc(unsigned char *out, const unsigned char *l, const unsigned char *r){ - out[0] = (unsigned char)mm((456*(int)l[0] + 500*(int)l[1] + 176*(int)l[2] + + out[0] = (unsigned char) mm((456*(int)l[0] + 500*(int)l[1] + 176*(int)l[2] + -43*(int)r[0] + -88*(int)r[1] + -2*(int)r[2]) / 1000, 0, 255); - out[1] = (unsigned char)mm((-40*(int)l[0] + -38*(int)l[1] + -16*(int)l[2] + + out[1] = (unsigned char) mm((-40*(int)l[0] + -38*(int)l[1] + -16*(int)l[2] + 378*(int)r[0] + 734*(int)r[1] + -18*(int)r[2]) / 1000, 0, 255); - out[2] = (unsigned char)mm((-15*(int)l[0] + -21*(int)l[1] + -5*(int)l[2] + + out[2] = (unsigned char) mm((-15*(int)l[0] + -21*(int)l[1] + -5*(int)l[2] + -72*(int)r[0] +-113*(int)r[1] + 1226*(int)r[2]) / 1000, 0, 255); return out; } @@ -117,19 +117,14 @@ unsigned char* full_mc(unsigned char *out, const unsigned char *l, const unsigne return out; } -//magenta-cyan "Dubois" -unsigned char* dubois_mc(unsigned char *out, const unsigned char *l, const unsigned char *r){ - out[0] = (unsigned char)mm((529*(int)l[0] + 705*(int)l[1] + 24*(int)l[2] + - -62*(int)r[0] +-158*(int)r[1] + -39*(int)r[2]) / 1000, 0, 255); - out[1] = (unsigned char)mm((-40*(int)l[0] + -38*(int)l[1] + -16*(int)l[2] + - 378*(int)r[0] + 734*(int)r[1] + -18*(int)r[2]) / 1000, 0, 255); - out[2] = (unsigned char)mm((-15*(int)l[0] + -24*(int)l[1] + 8*(int)l[2] + - -32*(int)r[0] + -19*(int)r[1] + 1081*(int)r[2]) / 1000, 0, 255); - -// out[2] = (unsigned char)mm((-15*(int)l[0] + -27*(int)l[1] + 21*(int)l[2] + gm -// 9*(int)r[0] + 75*(int)r[1] + 937*(int)r[2]) / 1000, 0, 255); -// out[2] = (unsigned char)mm((-15*(int)l[0] + -21*(int)l[1] + -5*(int)l[2] + rc -// -72*(int)r[0] +-113*(int)r[1] + 1226*(int)r[2]) / 1000, 0, 255); +//magenta-cyan experimental +unsigned char* experimental_mc(unsigned char *out, const unsigned char *l, const unsigned char *r){ + out[0] = (unsigned char) mm((556*(int)l[0] + 400*(int)l[1] + 176*(int)l[2] + + -43*(int)r[0] + -88*(int)r[1] + -2*(int)r[2]) / 950, 0, 255); + out[1] = (unsigned char) mm((-40*(int)l[0] + -38*(int)l[1] + -16*(int)l[2] + + 278*(int)r[0] + 734*(int)r[1] + -18*(int)r[2]) / 1100, 0, 255); + out[2] = (unsigned char) mm((-15*(int)l[0] + -21*(int)l[1] + 600*(int)l[2] + + -72*(int)r[0] +-113*(int)r[1] + 621*(int)r[2]) / 950, 0, 255); return out; } @@ -154,8 +149,8 @@ unsigned char* (*parse_func(const char *arg))(unsigned char*, const unsigned cha if (!strcmp(arg, "-drc")) return &dubois_rc; if (!strcmp(arg, "-fmc")) return &full_mc; - if (!strcmp(arg, "-dmc")) return &dubois_mc; if (!strcmp(arg, "-dab")) return &dubois_ab; + if (!strcmp(arg, "-emc")) return &experimental_mc; exit(error(1)); return &dubois_rc; } diff --git a/stereofy.sh b/stereofy.sh index 919c2a8..d3f4763 100755 --- a/stereofy.sh +++ b/stereofy.sh @@ -1,7 +1,7 @@ #!/bin/sh algo="d" #algorythm, Dubois by default -model="gm" #color model, green-magenta by default +model="rc" #color model, green-magenta by default param="" #leave blank, will be -$algo$model left='' right='' @@ -9,22 +9,15 @@ stereo='' while [ -n "$1" ]; do case "$1" in - -d|--dubois]) algo="d" - ;; - -f|--full|--full-color]) algo="f" - ;; - -h|--half|--half-color]) algo="d" - ;; - -rc|--rc|--red-cyan) model="rc" - ;; - -mc|--mc|--magenta-cyan) model="mc" - ;; - -gm|--gm|--green-magenta) model="gm" - ;; - -ab|--ab|--amber-blue|yellow-blue) model="ab" - ;; - -[dfh]rc|-[dfh]gm|-[fd]mc|-dab) param="$1" - ;; + -d|--dubois) algo="d";; + -f|--full|--full-color) algo="f";; + -h|--half|--half-color) algo="d";; + -rc|--rc|--red-cyan) model="rc";; + -mc|--mc|--magenta-cyan) model="mc";; + -gm|--gm|--green-magenta) model="gm";; + -ab|--ab|--amber-blue|yellow-blue) model="ab";; + -[dfh]rc|-[dfh]gm|-[fe]mc|-dab) param="$1";; + -*) echo "no such color model" >/dev/stderr; exit 1;; *) if [ -z "$left" ]; then left="$1" elif [ -z "$right" ]; then -- 2.39.2