rebaseline_server: delete no-longer-used weightedDiffMeasure

(replaced by perceptual diff)

NOTRY=True
R=rmistry@google.com
TBR=rmistry

Author: epoger@google.com

Review URL: https://codereview.chromium.org/334533003
This commit is contained in:
epoger 2014-06-11 20:35:59 -07:00 committed by Commit bot
parent cbbc7bf971
commit 984b97c496
8 changed files with 18 additions and 71 deletions

View File

@ -49,7 +49,6 @@ KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL = 'maxDiffPerChannel'
KEY__DIFFERENCES__NUM_DIFF_PIXELS = 'numDifferingPixels' KEY__DIFFERENCES__NUM_DIFF_PIXELS = 'numDifferingPixels'
KEY__DIFFERENCES__PERCENT_DIFF_PIXELS = 'percentDifferingPixels' KEY__DIFFERENCES__PERCENT_DIFF_PIXELS = 'percentDifferingPixels'
KEY__DIFFERENCES__PERCEPTUAL_DIFF = 'perceptualDifference' KEY__DIFFERENCES__PERCEPTUAL_DIFF = 'perceptualDifference'
KEY__DIFFERENCES__WEIGHTED_DIFF = 'weightedDiffMeasure'
class DiffRecord(object): class DiffRecord(object):
@ -117,8 +116,6 @@ class DiffRecord(object):
diff_image = _generate_image_diff(actual_image, expected_image) diff_image = _generate_image_diff(actual_image, expected_image)
diff_histogram = diff_image.histogram() diff_histogram = diff_image.histogram()
(diff_width, diff_height) = diff_image.size (diff_width, diff_height) = diff_image.size
self._weighted_diff_measure = _calculate_weighted_diff_metric(
diff_histogram, diff_width * diff_height)
self._max_diff_per_channel = _max_per_band(diff_histogram) self._max_diff_per_channel = _max_per_band(diff_histogram)
# Generate the whitediff image (any differing pixels show as white). # Generate the whitediff image (any differing pixels show as white).
@ -189,14 +186,6 @@ class DiffRecord(object):
"""Returns the perceptual difference percentage.""" """Returns the perceptual difference percentage."""
return self._perceptual_difference return self._perceptual_difference
def get_weighted_diff_measure(self):
"""Returns a weighted measure of image diffs, as a float between 0 and 100
(inclusive).
TODO(epoger): Delete this function, now that we have perceptual diff?
"""
return self._weighted_diff_measure
def get_max_diff_per_channel(self): def get_max_diff_per_channel(self):
"""Returns the maximum difference between the expected and actual images """Returns the maximum difference between the expected and actual images
for each R/G/B channel, as a list.""" for each R/G/B channel, as a list."""
@ -209,7 +198,6 @@ class DiffRecord(object):
KEY__DIFFERENCES__NUM_DIFF_PIXELS: self._num_pixels_differing, KEY__DIFFERENCES__NUM_DIFF_PIXELS: self._num_pixels_differing,
KEY__DIFFERENCES__PERCENT_DIFF_PIXELS: KEY__DIFFERENCES__PERCENT_DIFF_PIXELS:
self.get_percent_pixels_differing(), self.get_percent_pixels_differing(),
KEY__DIFFERENCES__WEIGHTED_DIFF: self.get_weighted_diff_measure(),
KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL: self._max_diff_per_channel, KEY__DIFFERENCES__MAX_DIFF_PER_CHANNEL: self._max_diff_per_channel,
KEY__DIFFERENCES__PERCEPTUAL_DIFF: self._perceptual_difference, KEY__DIFFERENCES__PERCEPTUAL_DIFF: self._perceptual_difference,
} }
@ -290,31 +278,6 @@ class ImageDiffDB(object):
# Utility functions # Utility functions
def _calculate_weighted_diff_metric(histogram, num_pixels):
"""Given the histogram of a diff image (per-channel diff at each
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
Returns: a weighted diff metric, as a float between 0 and 100 (inclusive).
"""
# 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.)
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
total_diff = 0
for index in xrange(len(histogram)):
total_diff += histogram[index] * (index % VALUES_PER_BAND)**2
return float(100 * total_diff) / max_diff
def _max_per_band(histogram): def _max_per_band(histogram):
"""Given the histogram of an image, return the maximum value of each band """Given the histogram of an image, return the maximum value of each band
(a.k.a. "color channel", such as R/G/B) across the entire image. (a.k.a. "color channel", such as R/G/B) across the entire image.

View File

@ -56,23 +56,22 @@ class ImageDiffDbTest(unittest.TestCase):
# 2. actual image locator # 2. actual image locator
# 3. actual image URL # 3. actual image URL
# 4. expected percent_pixels_differing (as a string, to 4 decimal places) # 4. expected percent_pixels_differing (as a string, to 4 decimal places)
# 5. expected weighted_diff_measure (as a string, to 4 decimal places) # 5. expected perceptual difference (as a string, to 4 decimal places)
# 6. expected perceptual difference (as a string, to 4 decimal places) # 6. expected max_diff_per_channel
# 7. expected max_diff_per_channel
selftests = [ selftests = [
[ [
'arcofzorro/16206093933823793653', 'arcofzorro/16206093933823793653',
IMG_URL_BASE + 'arcofzorro/16206093933823793653.png', IMG_URL_BASE + 'arcofzorro/16206093933823793653.png',
'arcofzorro/13786535001616823825', 'arcofzorro/13786535001616823825',
IMG_URL_BASE + 'arcofzorro/13786535001616823825.png', IMG_URL_BASE + 'arcofzorro/13786535001616823825.png',
'0.0662', '0.0113', '0.0662', [255, 255, 247], '0.0662', '0.0662', [255, 255, 247],
], ],
[ [
'gradients_degenerate_2pt/10552995703607727960', 'gradients_degenerate_2pt/10552995703607727960',
IMG_URL_BASE + 'gradients_degenerate_2pt/10552995703607727960.png', IMG_URL_BASE + 'gradients_degenerate_2pt/10552995703607727960.png',
'gradients_degenerate_2pt/11198253335583713230', 'gradients_degenerate_2pt/11198253335583713230',
IMG_URL_BASE + 'gradients_degenerate_2pt/11198253335583713230.png', IMG_URL_BASE + 'gradients_degenerate_2pt/11198253335583713230.png',
'100.0000', '66.6667', '100.0000', [255, 0, 255], '100.0000', '100.0000', [255, 0, 255],
], ],
] ]
@ -89,9 +88,8 @@ class ImageDiffDbTest(unittest.TestCase):
actual_image_locator=selftest[2]) actual_image_locator=selftest[2])
self.assertEqual('%.4f' % record.get_percent_pixels_differing(), self.assertEqual('%.4f' % record.get_percent_pixels_differing(),
selftest[4]) selftest[4])
self.assertEqual('%.4f' % record.get_weighted_diff_measure(), selftest[5]) self.assertEqual('%.4f' % record.get_perceptual_difference(), selftest[5])
self.assertEqual('%.4f' % record.get_perceptual_difference(), selftest[6]) self.assertEqual(record.get_max_diff_per_channel(), selftest[6])
self.assertEqual(record.get_max_diff_per_channel(), selftest[7])
def main(): def main():

View File

@ -88,7 +88,6 @@ class ImagePairTest(unittest.TestCase):
'numDifferingPixels': 662, 'numDifferingPixels': 662,
'percentDifferingPixels': 0.0662, 'percentDifferingPixels': 0.0662,
'perceptualDifference': 0.06620000000000914, 'perceptualDifference': 0.06620000000000914,
'weightedDiffMeasure': 0.01127756555171088,
}, },
'imageAUrl': 'arcofzorro/16206093933823793653.png', 'imageAUrl': 'arcofzorro/16206093933823793653.png',
'imageBUrl': 'arcofzorro/13786535001616823825.png', 'imageBUrl': 'arcofzorro/13786535001616823825.png',
@ -115,7 +114,6 @@ class ImagePairTest(unittest.TestCase):
'numDifferingPixels': 102400, 'numDifferingPixels': 102400,
'percentDifferingPixels': 100.00, 'percentDifferingPixels': 100.00,
'perceptualDifference': 100.00, 'perceptualDifference': 100.00,
'weightedDiffMeasure': 66.66666666666667,
}, },
'expectations': { 'expectations': {
'bugs': [1001, 1002], 'bugs': [1001, 1002],

View File

@ -35,7 +35,6 @@ IMAGEPAIR_2_AS_DICT = {
'maxDiffPerChannel': [1, 2, 3], 'maxDiffPerChannel': [1, 2, 3],
'numDifferingPixels': 111, 'numDifferingPixels': 111,
'percentDifferingPixels': 22.222, 'percentDifferingPixels': 22.222,
'weightedDiffMeasure': 33.333,
}, },
imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS: { imagepair.KEY__IMAGEPAIRS__EXTRACOLUMNS: {
'builder': 'MyBuilder', 'builder': 'MyBuilder',
@ -50,7 +49,6 @@ IMAGEPAIR_3_AS_DICT = {
'maxDiffPerChannel': [4, 5, 6], 'maxDiffPerChannel': [4, 5, 6],
'numDifferingPixels': 111, 'numDifferingPixels': 111,
'percentDifferingPixels': 44.444, 'percentDifferingPixels': 44.444,
'weightedDiffMeasure': 33.333,
}, },
imagepair.KEY__IMAGEPAIRS__EXPECTATIONS: { imagepair.KEY__IMAGEPAIRS__EXPECTATIONS: {
'bugs': [1001, 1002], 'bugs': [1001, 1002],

View File

@ -20,7 +20,6 @@ module.constant('constants', (function() {
KEY__DIFFERENCES__NUM_DIFF_PIXELS: 'numDifferingPixels', KEY__DIFFERENCES__NUM_DIFF_PIXELS: 'numDifferingPixels',
KEY__DIFFERENCES__PERCENT_DIFF_PIXELS: 'percentDifferingPixels', KEY__DIFFERENCES__PERCENT_DIFF_PIXELS: 'percentDifferingPixels',
KEY__DIFFERENCES__PERCEPTUAL_DIFF: 'perceptualDifference', KEY__DIFFERENCES__PERCEPTUAL_DIFF: 'perceptualDifference',
KEY__DIFFERENCES__WEIGHTED_DIFF: 'weightedDiffMeasure',
// NOTE: Keep these in sync with ../imagepair.py // NOTE: Keep these in sync with ../imagepair.py
KEY__IMAGEPAIRS__DIFFERENCES: 'differenceData', KEY__IMAGEPAIRS__DIFFERENCES: 'differenceData',

View File

@ -280,7 +280,7 @@
<th width="{{imageSize}}"> <th width="{{imageSize}}">
<input type="radio" <input type="radio"
name="sortColumnRadio" name="sortColumnRadio"
value="weightedDiffMeasure" value="perceptualDiff"
ng-checked="(sortColumnKey == constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF)" ng-checked="(sortColumnKey == constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF)"
ng-click="sortResultsBy(constants.KEY__IMAGEPAIRS__DIFFERENCES, constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF)"> ng-click="sortResultsBy(constants.KEY__IMAGEPAIRS__DIFFERENCES, constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF)">
perceptual difference perceptual difference

View File

@ -94,7 +94,7 @@
} }
}, },
"header": { "header": {
"dataHash": "-3232866296817265056", "dataHash": "5496105477154010366",
"isEditable": false, "isEditable": false,
"isExported": true, "isExported": true,
"schemaVersion": 3, "schemaVersion": 3,
@ -189,8 +189,7 @@
], ],
"numDifferingPixels": 6081, "numDifferingPixels": 6081,
"percentDifferingPixels": 2.4324, "percentDifferingPixels": 2.4324,
"perceptualDifference": 1.917199999999994, "perceptualDifference": 1.917199999999994
"weightedDiffMeasure": 0.06644571780084584
}, },
"extraColumns": { "extraColumns": {
"builder": "Test-Builder-We-Have-No-Expectations-File-For", "builder": "Test-Builder-We-Have-No-Expectations-File-For",
@ -211,8 +210,7 @@
], ],
"numDifferingPixels": 50097, "numDifferingPixels": 50097,
"percentDifferingPixels": 30.5767822265625, "percentDifferingPixels": 30.5767822265625,
"perceptualDifference": 3.3917, "perceptualDifference": 3.3917
"weightedDiffMeasure": 1.4826590790651433
}, },
"extraColumns": { "extraColumns": {
"builder": "Test-Builder-We-Have-No-Expectations-File-For", "builder": "Test-Builder-We-Have-No-Expectations-File-For",
@ -255,8 +253,7 @@
], ],
"numDifferingPixels": 6081, "numDifferingPixels": 6081,
"percentDifferingPixels": 2.4324, "percentDifferingPixels": 2.4324,
"perceptualDifference": 1.917199999999994, "perceptualDifference": 1.917199999999994
"weightedDiffMeasure": 0.06644571780084584
}, },
"extraColumns": { "extraColumns": {
"builder": "Test-Mac10.7-MacMini4.1-GeForce320M-x86_64-Debug", "builder": "Test-Mac10.7-MacMini4.1-GeForce320M-x86_64-Debug",
@ -277,8 +274,7 @@
], ],
"numDifferingPixels": 50097, "numDifferingPixels": 50097,
"percentDifferingPixels": 30.5767822265625, "percentDifferingPixels": 30.5767822265625,
"perceptualDifference": 3.3917, "perceptualDifference": 3.3917
"weightedDiffMeasure": 1.4826590790651433
}, },
"extraColumns": { "extraColumns": {
"builder": "Test-Mac10.7-MacMini4.1-GeForce320M-x86_64-Debug", "builder": "Test-Mac10.7-MacMini4.1-GeForce320M-x86_64-Debug",

View File

@ -110,7 +110,7 @@
} }
}, },
"header": { "header": {
"dataHash": "-5343462047057549086", "dataHash": "7849962375815855931",
"isEditable": false, "isEditable": false,
"isExported": true, "isExported": true,
"schemaVersion": 3, "schemaVersion": 3,
@ -128,8 +128,7 @@
], ],
"numDifferingPixels": 120000, "numDifferingPixels": 120000,
"percentDifferingPixels": 75.0, "percentDifferingPixels": 75.0,
"perceptualDifference": 50.122499999999995, "perceptualDifference": 50.122499999999995
"weightedDiffMeasure": 8.413046264257337
}, },
"expectations": { "expectations": {
"bugs": null, "bugs": null,
@ -155,8 +154,7 @@
], ],
"numDifferingPixels": 765891, "numDifferingPixels": 765891,
"percentDifferingPixels": 97.38807678222656, "percentDifferingPixels": 97.38807678222656,
"perceptualDifference": 25.25699999999999, "perceptualDifference": 25.25699999999999
"weightedDiffMeasure": 14.10677058693997
}, },
"expectations": { "expectations": {
"bugs": [ "bugs": [
@ -184,8 +182,7 @@
], ],
"numDifferingPixels": 422432, "numDifferingPixels": 422432,
"percentDifferingPixels": 53.715006510416664, "percentDifferingPixels": 53.715006510416664,
"perceptualDifference": 25.120500000000007, "perceptualDifference": 25.120500000000007
"weightedDiffMeasure": 14.005823726182287
}, },
"expectations": { "expectations": {
"bugs": [ "bugs": [
@ -213,8 +210,7 @@
], ],
"numDifferingPixels": 53150, "numDifferingPixels": 53150,
"percentDifferingPixels": 12.035778985507246, "percentDifferingPixels": 12.035778985507246,
"perceptualDifference": 100, "perceptualDifference": 100
"weightedDiffMeasure": 3.713243437353155
}, },
"expectations": { "expectations": {
"bugs": [ "bugs": [
@ -242,8 +238,7 @@
], ],
"numDifferingPixels": 53773, "numDifferingPixels": 53773,
"percentDifferingPixels": 12.17685688405797, "percentDifferingPixels": 12.17685688405797,
"perceptualDifference": 100, "perceptualDifference": 100
"weightedDiffMeasure": 3.6723483686597684
}, },
"expectations": { "expectations": {
"bugs": [ "bugs": [