Date:2010-08-30 20:11:43 (9 years 4 months ago)
Author:Werner Almesberger
Commit:78f6cfbfda4942457e7a158a4f9fafd5e1fca067
Message:Attempt at avoiding the false changes seen on Xue. Seems that alpha-blending produces minute differences where there should be none.

- scripts/ppmdiff/ppmdiff.c (diff): instead of looking for all or noting
changes, also detect gradual changes
- scripts/ppmdiff/ppmdiff.c (diff, main): don't mark areas with differences
in the main images if using shadow images
- scripts/schps2ppm: new option to disable alpha blending
- scripts/schhist2web: cache pixmaps with default line thickness and no
alpha blending in hard_*
- scripts/schhist2web: base marking of areas with differences exclusively
on the hard_* pixmaps
Files: scripts/ppmdiff/ppmdiff.c (4 diffs)
scripts/schhist2web (3 diffs)
scripts/schps2ppm (2 diffs)

Change Details

scripts/ppmdiff/ppmdiff.c
150150}
151151
152152
153static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres)
153static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres,
154    int mark_areas)
154155{
155156    uint8_t *res, *p;
156157    int x, y;
157    int has_a, has_b;
158    unsigned val_a, val_b;
158159
159160    res = p = malloc(xres*yres*3);
160161    if (!res) {
...... 
163164    }
164165    for (y = 0; y != yres; y++)
165166        for (x = 0; x != xres; x++) {
166            has_a = (a[0] & a[1] & a[2]) != 255;
167            has_b = (b[0] & b[1] & b[2]) != 255;
168            if (has_a && has_b) {
167            val_a = a[0]+a[1]+a[2];
168            val_b = b[0]+b[1]+b[2];
169            if (val_a == val_b) {
169170                set_pixel(p, both, b);
170            } else if (has_a) {
171            } else if (val_a < val_b) {
171172                set_pixel(p, a_only, a);
172                change(x, y);
173            } else if (has_b) {
173                if (mark_areas)
174                    change(x, y);
175            } else if (val_a > val_b) {
174176                set_pixel(p, b_only, b);
175                change(x, y);
177                if (mark_areas)
178                    change(x, y);
176179            } else {
180                abort(); /* no longer used */
177181                memset(p, 255, 3);
178182// memcpy(p, "\0\0\xff", 3);
179183            }
...... 
280284{
281285    fprintf(stderr,
282286"usage: %s [-f] [-a color] [-b color] [-c color] [-d pixels]\n"
283"%6s %*s [-m color] [-n color] [-w pixels] file_a.ppm file_b.ppm\n\n"
287"%6s %*s [-m color] [-n color] [-w pixels] file_a.ppm file_b.ppm\n"
284288"%6s %*s [file_a'.ppm file_b'.ppm] [out.ppm]\n\n"
285289" file_a.ppm and file_b.ppm are two input images\n"
286290" file_a'.ppm and file_b'.ppm if present, are searched for changes as well\n"
...... 
385389    }
386390    if (!force && !areas && !memcmp(old, new, x*y*3))
387391        return 1;
388    d = diff(old, new, x, y);
392    d = diff(old, new, x, y, !shadow_old);
389393    if (frame_dist)
390394        mark_areas(d, x, y);
391395
scripts/schhist2web
193193    schname="$new"
194194    fi
195195    tmp=`pwd`/_schhist2web
196    trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$tmp\"" 0
196    trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$cache/ps_$n\" \
197      \"$cache/hard_$n\" \"$tmp\"" 0
197198    if [ ! -d "$cache/ppm_$n" ]; then
198    rm -rf "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n"
199    mkdir "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n"
199    rm -rf "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n" "$cache/hard_$n"
200    mkdir "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n" "$cache/hard_$n"
200201    #
201202    # potential optimization here: remember Postscript files from previous
202203    # run (or their md5sum) and check if they have changed. If not, skip
...... 
205206    #
206207    gitsch2ps $sanitize "$dir" "$schname" $n "$tmp" || exit
207208    for m in "$tmp"/*.ps; do
209        # Postscript, for making PDFs later
210        ps="$cache/ps_$n/`basename "$m"`"
211        normalizeschps "$m" "$ps" || exit
212
213        # Unadorned pixmap, for comparison
214        ppm="$cache/hard_$n/`basename "$m" .ps`.ppm"
215        schps2ppm -n "$ps" "$ppm" || exit
216
217        # Pixmap with thin lines, for the detail views
208218        ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm"
209219        normalizeschps -w 120 "$m" | schps2ppm - "$ppm" || exit
220
221        # Pixmap with thick lines, for the thumbnails
210222        ppm="$cache/fat_$n/`basename "$m" .ps`.ppm"
211223        normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit
212        ps="$cache/ps_$n/`basename "$m"`"
213        normalizeschps "$m" "$ps" || exit
214224    done
215225    rm -rf "$tmp"
216226    fi
...... 
295305    while read m; do
296306    a="$cache/ppm_$n/$m.ppm"
297307    fat_a="$cache/fat_$n/$m.ppm"
308    hard_a="$cache/hard_$n/$m.ppm"
298309    b="$cache/ppm_$next/$m.ppm"
299310    fat_b="$cache/fat_$next/$m.ppm"
311    hard_b="$cache/hard_$next/$m.ppm"
300312    diff="$out/diff_$next/$m.png"
301313    thumb="$out/thumb_$next/$m.png"
302314
303315    if [ -f "$a" -a -f "$b" ]; then
304316        s="$s<TD align=\"center\" valign=\"middle\">"
305        if ! pngdiff cat "$diff" "$a" "$b"; then
317        if ! pngdiff cat "$diff" "$a" "$b" "$hard_a" "$hard_b"; then
306318        s="$s<IMG src=\"unchanged.png\""
307319        continue
308320        fi
309321        pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" \
310          "$a" "$b" || exit
322          "$hard_a" "$hard_b" || exit
311323        mkdir -p "$out/pdf_$next"
312324        schps2pdf -T BEFORE -T AFTER -o "$out/pdf_$next/$m.pdf" \
313325          "$cache/ps_$n/$m.ps" "$cache/ps_$next/$m.ps" || exit
scripts/schps2ppm
2020    cat <<EOF 1>&2
2121usage: $0 [options] [file.ps [file.ppm]]
2222
23  -r XxY image resolution (default: $RES)
23  -n disable alpha blending
24  -r XxY image resolution (default: $RES)
2425EOF
2526    exit 1
2627}
2728
2829
30alpha=true
2931while true; do
3032    case "$1" in
33    -n) alpha=false
34    shift;;
3135    -r) [ -z "$2" ] && usage
3236    RES="$2"
3337    shift 2;;
...... 
4852
4953cat "$in" |
5054  gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \
51  -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q - |
55   `$alpha && echo '' -dTextAlphaBits=4 -dGraphicsAlphaBits=4` \
56   -q - |
5257  pnmflip -r270 >"$out"

Archive Download the corresponding diff file



interactive