IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2010-08-30 20:11:43 (10 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 | ||
---|---|---|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres) | |
153 | static uint8_t *diff(const uint8_t *a, const uint8_t *b, int xres, int yres, | |
154 | int mark_areas) | |
154 | 155 | { |
155 | 156 | uint8_t *res, *p; |
156 | 157 | int x, y; |
157 | int has_a, has_b; | |
158 | unsigned val_a, val_b; | |
158 | 159 | |
159 | 160 | res = p = malloc(xres*yres*3); |
160 | 161 | if (!res) { |
... | ... | |
163 | 164 | } |
164 | 165 | for (y = 0; y != yres; y++) |
165 | 166 | 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) { | |
169 | 170 | set_pixel(p, both, b); |
170 | } else if (has_a) { | |
171 | } else if (val_a < val_b) { | |
171 | 172 | 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) { | |
174 | 176 | set_pixel(p, b_only, b); |
175 | change(x, y); | |
177 | if (mark_areas) | |
178 | change(x, y); | |
176 | 179 | } else { |
180 | abort(); /* no longer used */ | |
177 | 181 | memset(p, 255, 3); |
178 | 182 | // memcpy(p, "\0\0\xff", 3); |
179 | 183 | } |
... | ... | |
280 | 284 | { |
281 | 285 | fprintf(stderr, |
282 | 286 | "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" | |
284 | 288 | "%6s %*s [file_a'.ppm file_b'.ppm] [out.ppm]\n\n" |
285 | 289 | " file_a.ppm and file_b.ppm are two input images\n" |
286 | 290 | " file_a'.ppm and file_b'.ppm if present, are searched for changes as well\n" |
... | ... | |
385 | 389 | } |
386 | 390 | if (!force && !areas && !memcmp(old, new, x*y*3)) |
387 | 391 | return 1; |
388 | d = diff(old, new, x, y); | |
392 | d = diff(old, new, x, y, !shadow_old); | |
389 | 393 | if (frame_dist) |
390 | 394 | mark_areas(d, x, y); |
391 | 395 |
scripts/schhist2web | ||
---|---|---|
193 | 193 | schname="$new" |
194 | 194 | fi |
195 | 195 | 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 | |
197 | 198 | 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" | |
200 | 201 | # |
201 | 202 | # potential optimization here: remember Postscript files from previous |
202 | 203 | # run (or their md5sum) and check if they have changed. If not, skip |
... | ... | |
205 | 206 | # |
206 | 207 | gitsch2ps $sanitize "$dir" "$schname" $n "$tmp" || exit |
207 | 208 | 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 | |
208 | 218 | ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm" |
209 | 219 | normalizeschps -w 120 "$m" | schps2ppm - "$ppm" || exit |
220 | ||
221 | # Pixmap with thick lines, for the thumbnails | |
210 | 222 | ppm="$cache/fat_$n/`basename "$m" .ps`.ppm" |
211 | 223 | normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit |
212 | ps="$cache/ps_$n/`basename "$m"`" | |
213 | normalizeschps "$m" "$ps" || exit | |
214 | 224 | done |
215 | 225 | rm -rf "$tmp" |
216 | 226 | fi |
... | ... | |
295 | 305 | while read m; do |
296 | 306 | a="$cache/ppm_$n/$m.ppm" |
297 | 307 | fat_a="$cache/fat_$n/$m.ppm" |
308 | hard_a="$cache/hard_$n/$m.ppm" | |
298 | 309 | b="$cache/ppm_$next/$m.ppm" |
299 | 310 | fat_b="$cache/fat_$next/$m.ppm" |
311 | hard_b="$cache/hard_$next/$m.ppm" | |
300 | 312 | diff="$out/diff_$next/$m.png" |
301 | 313 | thumb="$out/thumb_$next/$m.png" |
302 | 314 | |
303 | 315 | if [ -f "$a" -a -f "$b" ]; then |
304 | 316 | 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 | |
306 | 318 | s="$s<IMG src=\"unchanged.png\"" |
307 | 319 | continue |
308 | 320 | fi |
309 | 321 | pngdiff shrink "$thumb" -f $THUMB_OPTS "$fat_a" "$fat_b" \ |
310 | "$a" "$b" || exit | |
322 | "$hard_a" "$hard_b" || exit | |
311 | 323 | mkdir -p "$out/pdf_$next" |
312 | 324 | schps2pdf -T BEFORE -T AFTER -o "$out/pdf_$next/$m.pdf" \ |
313 | 325 | "$cache/ps_$n/$m.ps" "$cache/ps_$next/$m.ps" || exit |
scripts/schps2ppm | ||
---|---|---|
20 | 20 | cat <<EOF 1>&2 |
21 | 21 | usage: $0 [options] [file.ps [file.ppm]] |
22 | 22 | |
23 | -r XxY image resolution (default: $RES) | |
23 | -n disable alpha blending | |
24 | -r XxY image resolution (default: $RES) | |
24 | 25 | EOF |
25 | 26 | exit 1 |
26 | 27 | } |
27 | 28 | |
28 | 29 | |
30 | alpha=true | |
29 | 31 | while true; do |
30 | 32 | case "$1" in |
33 | -n) alpha=false | |
34 | shift;; | |
31 | 35 | -r) [ -z "$2" ] && usage |
32 | 36 | RES="$2" |
33 | 37 | shift 2;; |
... | ... | |
48 | 52 | |
49 | 53 | cat "$in" | |
50 | 54 | gs -sDEVICE=ppmraw -sOutputFile=- -g$IRES -r$res \ |
51 | -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -q - | | |
55 | `$alpha && echo '' -dTextAlphaBits=4 -dGraphicsAlphaBits=4` \ | |
56 | -q - | | |
52 | 57 | pnmflip -r270 >"$out" |