mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-12-28 14:44:15 +02:00
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
This commit is contained in:
parent
66cf6a296e
commit
78f6cfbfda
@ -150,11 +150,12 @@ static void set_pixel(uint8_t *p, const uint8_t *color, const uint8_t *value)
|
||||
}
|
||||
|
||||
|
||||
static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres)
|
||||
static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres,
|
||||
int mark_areas)
|
||||
{
|
||||
uint8_t *res, *p;
|
||||
int x, y;
|
||||
int has_a, has_b;
|
||||
unsigned val_a, val_b;
|
||||
|
||||
res = p = malloc(xres*yres*3);
|
||||
if (!res) {
|
||||
@ -163,17 +164,20 @@ static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres)
|
||||
}
|
||||
for (y = 0; y != yres; y++)
|
||||
for (x = 0; x != xres; x++) {
|
||||
has_a = (a[0] & a[1] & a[2]) != 255;
|
||||
has_b = (b[0] & b[1] & b[2]) != 255;
|
||||
if (has_a && has_b) {
|
||||
val_a = a[0]+a[1]+a[2];
|
||||
val_b = b[0]+b[1]+b[2];
|
||||
if (val_a == val_b) {
|
||||
set_pixel(p, both, b);
|
||||
} else if (has_a) {
|
||||
} else if (val_a < val_b) {
|
||||
set_pixel(p, a_only, a);
|
||||
change(x, y);
|
||||
} else if (has_b) {
|
||||
if (mark_areas)
|
||||
change(x, y);
|
||||
} else if (val_a > val_b) {
|
||||
set_pixel(p, b_only, b);
|
||||
change(x, y);
|
||||
if (mark_areas)
|
||||
change(x, y);
|
||||
} else {
|
||||
abort(); /* no longer used */
|
||||
memset(p, 255, 3);
|
||||
// memcpy(p, "\0\0\xff", 3);
|
||||
}
|
||||
@ -280,7 +284,7 @@ static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-f] [-a color] [-b color] [-c color] [-d pixels]\n"
|
||||
"%6s %*s [-m color] [-n color] [-w pixels] file_a.ppm file_b.ppm\n\n"
|
||||
"%6s %*s [-m color] [-n color] [-w pixels] file_a.ppm file_b.ppm\n"
|
||||
"%6s %*s [file_a'.ppm file_b'.ppm] [out.ppm]\n\n"
|
||||
" file_a.ppm and file_b.ppm are two input images\n"
|
||||
" file_a'.ppm and file_b'.ppm if present, are searched for changes as well\n"
|
||||
@ -385,7 +389,7 @@ int main(int argc, char *const *argv)
|
||||
}
|
||||
if (!force && !areas && !memcmp(old, new, x*y*3))
|
||||
return 1;
|
||||
d = diff(old, new, x, y);
|
||||
d = diff(old, new, x, y, !shadow_old);
|
||||
if (frame_dist)
|
||||
mark_areas(d, x, y);
|
||||
|
||||
|
@ -193,10 +193,11 @@ for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do
|
||||
schname="$new"
|
||||
fi
|
||||
tmp=`pwd`/_schhist2web
|
||||
trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$tmp\"" 0
|
||||
trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$cache/ps_$n\" \
|
||||
\"$cache/hard_$n\" \"$tmp\"" 0
|
||||
if [ ! -d "$cache/ppm_$n" ]; then
|
||||
rm -rf "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n"
|
||||
mkdir "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n"
|
||||
rm -rf "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n" "$cache/hard_$n"
|
||||
mkdir "$cache/ppm_$n" "$cache/fat_$n" "$cache/ps_$n" "$cache/hard_$n"
|
||||
#
|
||||
# potential optimization here: remember Postscript files from previous
|
||||
# run (or their md5sum) and check if they have changed. If not, skip
|
||||
@ -205,12 +206,21 @@ for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do
|
||||
#
|
||||
gitsch2ps $sanitize "$dir" "$schname" $n "$tmp" || exit
|
||||
for m in "$tmp"/*.ps; do
|
||||
ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm"
|
||||
normalizeschps -w 120 "$m" | schps2ppm - "$ppm" || exit
|
||||
ppm="$cache/fat_$n/`basename "$m" .ps`.ppm"
|
||||
normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit
|
||||
# Postscript, for making PDFs later
|
||||
ps="$cache/ps_$n/`basename "$m"`"
|
||||
normalizeschps "$m" "$ps" || exit
|
||||
|
||||
# Unadorned pixmap, for comparison
|
||||
ppm="$cache/hard_$n/`basename "$m" .ps`.ppm"
|
||||
schps2ppm -n "$ps" "$ppm" || exit
|
||||
|
||||
# Pixmap with thin lines, for the detail views
|
||||
ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm"
|
||||
normalizeschps -w 120 "$m" | schps2ppm - "$ppm" || exit
|
||||
|
||||
# Pixmap with thick lines, for the thumbnails
|
||||
ppm="$cache/fat_$n/`basename "$m" .ps`.ppm"
|
||||
normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit
|
||||
done
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
@ -295,19 +305,21 @@ for n in `cd "$dir" && git rev-list $first..HEAD~1` $first; do
|
||||
while read m; do
|
||||
a="$cache/ppm_$n/$m.ppm"
|
||||
fat_a="$cache/fat_$n/$m.ppm"
|
||||
hard_a="$cache/hard_$n/$m.ppm"
|
||||
b="$cache/ppm_$next/$m.ppm"
|
||||
fat_b="$cache/fat_$next/$m.ppm"
|
||||
hard_b="$cache/hard_$next/$m.ppm"
|
||||
diff="$out/diff_$next/$m.png"
|
||||
thumb="$out/thumb_$next/$m.png"
|
||||
|
||||
if [ -f "$a" -a -f "$b" ]; then
|
||||
s="$s<TD align=\"center\" valign=\"middle\">"
|
||||
if ! pngdiff cat "$diff" "$a" "$b"; then
|
||||
if ! pngdiff cat "$diff" "$a" "$b" "$hard_a" "$hard_b"; then
|
||||
s="$s<IMG src=\"unchanged.png\""
|
||||
continue
|
||||
fi
|
||||
pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" \
|
||||
"$a" "$b" || exit
|
||||
"$hard_a" "$hard_b" || exit
|
||||
mkdir -p "$out/pdf_$next"
|
||||
schps2pdf -T BEFORE -T AFTER -o "$out/pdf_$next/$m.pdf" \
|
||||
"$cache/ps_$n/$m.ps" "$cache/ps_$next/$m.ps" || exit
|
||||
|
@ -20,14 +20,18 @@ usage()
|
||||
cat <<EOF 1>&2
|
||||
usage: $0 [options] [file.ps [file.ppm]]
|
||||
|
||||
-r XxY image resolution (default: $RES)
|
||||
-n disable alpha blending
|
||||
-r XxY image resolution (default: $RES)
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
alpha=true
|
||||
while true; do
|
||||
case "$1" in
|
||||
-n) alpha=false
|
||||
shift;;
|
||||
-r) [ -z "$2" ] && usage
|
||||
RES="$2"
|
||||
shift 2;;
|
||||
@ -48,5 +52,6 @@ res=`expr 72 \* $X / 800`
|
||||
|
||||
cat "$in" |
|
||||
gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \
|
||||
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q - |
|
||||
`$alpha && echo '' -dTextAlphaBits=4 -dGraphicsAlphaBits=4` \
|
||||
-q - |
|
||||
pnmflip -r270 >"$out"
|
||||
|
Loading…
Reference in New Issue
Block a user