diff --git a/tests/color_util.c b/tests/color_util.c index 9267aefe..1f0928b6 100644 --- a/tests/color_util.c +++ b/tests/color_util.c @@ -454,13 +454,23 @@ rgb_diff_stat_update(struct rgb_diff_stat *stat, { unsigned i; double ssd = 0.0; + double diff[COLOR_CHAN_NUM]; + double two_norm; for (i = 0; i < COLOR_CHAN_NUM; i++) { - double diff = val->rgb[i] - ref->rgb[i]; + diff[i] = val->rgb[i] - ref->rgb[i]; - scalar_stat_update(&stat->rgb[i], diff, pos); - ssd += diff * diff; + scalar_stat_update(&stat->rgb[i], diff[i], pos); + ssd += diff[i] * diff[i]; } + two_norm = sqrt(ssd); - scalar_stat_update(&stat->two_norm, sqrt(ssd), pos); + scalar_stat_update(&stat->two_norm, two_norm, pos); + + if (stat->dump) { + fprintf(stat->dump, "%.8g %.8g %.8g %.8g %.5g %.5g %.5g %.5g\n", + two_norm, + diff[COLOR_CHAN_R], diff[COLOR_CHAN_G], diff[COLOR_CHAN_B], + pos->r, pos->g, pos->b, pos->a); + } } diff --git a/tests/color_util.h b/tests/color_util.h index 9ad09588..7a361a6b 100644 --- a/tests/color_util.h +++ b/tests/color_util.h @@ -148,6 +148,18 @@ struct scalar_stat { struct rgb_diff_stat { struct scalar_stat rgb[COLOR_CHAN_NUM]; struct scalar_stat two_norm; + + /** Debug dump into file + * + * Initialize this to a writable file to get a record of all values + * ever fed through this statistics accumulator. The file shall be + * text with the two-norm error, the rgb difference, and their position + * per line: + * norm diff.r diff.g diff.b pos.r pos.g pos.b pos.a + * + * Set to NULL to not record. + */ + FILE *dump; }; void