From b56750afbdf3eb232455dc4777d13c1922907f31 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 19 Jul 2009 16:54:32 +0100 Subject: [PATCH] Laxer identification for subpixel antialiasing --- pctb/structure.c | 17 ++++++++++------- pctb/x.gdb | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pctb/structure.c b/pctb/structure.c index e86f2c5..f10addc 100644 --- a/pctb/structure.c +++ b/pctb/structure.c @@ -565,7 +565,7 @@ static inline Fixpt int2fixpt(int x) { return x<> FIXPT_SHIFT; + return (a*b + dbl2fixpt(0.5)) / int2fixpt(1); } #define MFP(v) fprintf(stderr," %s=%lx=%f", #v,(v),fixpt2dbl((v))) @@ -609,22 +609,25 @@ static inline Fixpt find_aa_density(const RgbImage *ri, Point p) { Fixpt alpha_mean= fixpt_mul(alpha_total, one_third); Fixpt thresh= dbl2fixpt(1.5/AAMAXVAL); - Fixpt alpha_min= alpha_mean - thresh; - Fixpt alpha_max= alpha_mean + thresh; + Fixpt alpha_min= alpha_mean - thresh*2; + Fixpt alpha_max= alpha_mean + thresh*2; for (i=0; i<3; i++) MUST( alpha_min <= alpha[i] && alpha[i] <= alpha_max, MP(p); MRGB(here);MRGB(aa_background);MRGB(aa_foreground); - MFP(aa_alpha_mean_max); - MFP(alpha_min); MI(i);MFP(alpha[i]);MFP(alpha_max) ); + MFP(aa_alpha_mean_max);MFP(thresh);MFP(alpha_mean); + MFP(alpha_min);MI(i);MFP(alpha[i]);MFP(alpha_max) ); - MUST( 0 <= alpha_mean && alpha_mean <= aa_alpha_mean_max, + MUST( -thresh <= alpha_mean && alpha_mean <= aa_alpha_mean_max + thresh, MP(p); MRGB(here);MRGB(aa_background);MRGB(aa_foreground); - MFP(aa_alpha_mean_max); + MFP(aa_alpha_mean_max);MFP(thresh); MFP(alpha_mean); MFP(alpha[0]);MFP(alpha[1]);MFP(alpha[2]); ); + if (alpha_mean < 0) alpha_mean= 0; + if (alpha_mean > aa_alpha_mean_max) alpha_mean= aa_alpha_mean_max; + return alpha_mean; } diff --git a/pctb/x.gdb b/pctb/x.gdb index 371162b..1133843 100644 --- a/pctb/x.gdb +++ b/pctb/x.gdb @@ -1,5 +1,5 @@ file ypp-commodities -set args -Drect 2>u --edit-charset --raw-tsv --same >raw.tsv -break structure.c:596 if here!=aa_background +set args -Drect 2>u --edit-charset --find-island --ocean sage +#break structure.c:596 if here!=aa_background break mustfail2 run -- 2.30.2