| Index: gm/rebaseline_server/imagediffdb.py
|
| diff --git a/gm/rebaseline_server/imagediffdb.py b/gm/rebaseline_server/imagediffdb.py
|
| index 8c010f8a2bbf364e010153a393cd15c5b03267af..8cec46bc9434fcb74ee7d1b1d2619e0411704618 100644
|
| --- a/gm/rebaseline_server/imagediffdb.py
|
| +++ b/gm/rebaseline_server/imagediffdb.py
|
| @@ -31,7 +31,7 @@ sys.path.append(
|
| 'tools'))
|
| import find_run_binary
|
|
|
| -SKPDIFF_BINARY_NAME = 'skpdiff'
|
| +SKPDIFF_BINARY = find_run_binary.find_path_to_program('skpdiff')
|
|
|
| DEFAULT_IMAGE_SUFFIX = '.png'
|
| DEFAULT_IMAGES_SUBDIR = 'images'
|
| @@ -115,13 +115,12 @@ class DiffRecord(object):
|
| skpdiff_csv_dir = tempfile.mkdtemp()
|
| try:
|
| skpdiff_csv_output = os.path.join(skpdiff_csv_dir, 'skpdiff-output.csv')
|
| - skpdiff_binary = find_run_binary.find_path_to_program(SKPDIFF_BINARY_NAME)
|
| expected_img = os.path.join(storage_root, expected_images_subdir,
|
| str(expected_image_locator) + image_suffix)
|
| actual_img = os.path.join(storage_root, actual_images_subdir,
|
| str(actual_image_locator) + image_suffix)
|
| find_run_binary.run_command(
|
| - [skpdiff_binary, '-p', expected_img, actual_img,
|
| + [SKPDIFF_BINARY, '-p', expected_img, actual_img,
|
| '--csv', skpdiff_csv_output, '-d', 'perceptual'])
|
| with contextlib.closing(open(skpdiff_csv_output)) as csv_file:
|
| for row in csv.DictReader(csv_file):
|
| @@ -172,7 +171,10 @@ class DiffRecord(object):
|
|
|
| def get_weighted_diff_measure(self):
|
| """Returns a weighted measure of image diffs, as a float between 0 and 100
|
| - (inclusive)."""
|
| + (inclusive).
|
| +
|
| + TODO(epoger): Delete this function, now that we have perceptual diff?
|
| + """
|
| return self._weighted_diff_measure
|
|
|
| def get_max_diff_per_channel(self):
|
| @@ -265,6 +267,8 @@ def _calculate_weighted_diff_metric(histogram, num_pixels):
|
| pixel between two images), calculate the weighted diff metric (a
|
| stab at how different the two images really are).
|
|
|
| + TODO(epoger): Delete this function, now that we have perceptual diff?
|
| +
|
| Args:
|
| histogram: PIL histogram of a per-channel diff between two images
|
| num_pixels: integer; the total number of pixels in the diff image
|
| @@ -274,8 +278,6 @@ def _calculate_weighted_diff_metric(histogram, num_pixels):
|
| # TODO(epoger): As a wild guess at an appropriate metric, weight each
|
| # different pixel by the square of its delta value. (The more different
|
| # a pixel is from its expectation, the more we care about it.)
|
| - # In the long term, we will probably use some metric generated by
|
| - # skpdiff anyway.
|
| assert(len(histogram) % VALUES_PER_BAND == 0)
|
| num_bands = len(histogram) / VALUES_PER_BAND
|
| max_diff = num_pixels * num_bands * (VALUES_PER_BAND - 1)**2
|
|
|