[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29877] branches/soc-2010-leifandersen/ tests/render/run.py: Improved the comparison algorithum, especially after realizing the histogram() gave the pixel values as the domain, rather than the range.
Leif Andersen
leif.a.andersen at gmail.com
Fri Jul 2 19:52:22 CEST 2010
Revision: 29877
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29877
Author: leifandersen
Date: 2010-07-02 19:52:22 +0200 (Fri, 02 Jul 2010)
Log Message:
-----------
Improved the comparison algorithum, especially after realizing the histogram() gave the pixel values as the domain, rather than the range. Although I think there might be something wrong with my equations, as all images, even visably different ones, get 0% difference.
Modified Paths:
--------------
branches/soc-2010-leifandersen/tests/render/run.py
Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py 2010-07-02 17:49:40 UTC (rev 29876)
+++ branches/soc-2010-leifandersen/tests/render/run.py 2010-07-02 17:52:22 UTC (rev 29877)
@@ -26,9 +26,11 @@
diff_path = None
bad_pixels = None
pixel_count = None
+ diff_sum = None
good_image = None
test_image = None
diff_image = None
+ pixel_range = None
def __init__(self, blend_path, good_path, test_path):
self.blend_path = blend_path
@@ -44,13 +46,18 @@
self.test_image = Image.open(self.test_path)
def setup_test(self):
+ self.diff_sum = 0
self.diff_image = ImageChops.difference(self.good_image, self.test_image)
self.bad_pixels = 0
- self.pixel_count = len(self.diff_image.histogram())
- for num in self.diff_image.histogram():
- if num > 300:
- self.bad_pixels+=1
- if self.bad_pixels < self.pixel_count/10:
+ self.pixel_range = len(self.diff_image.histogram())
+ self.pixel_count = self.diff_image.size[0] * self.diff_image.size[1]
+ for i in range(0,self.diff_image.size[0]):
+ for j in range(0, self.diff_image.size[1]):
+ p = self.diff_image.getpixel((i,j))
+ self.diff_sum+= p[0] + p[1] + p[2]
+ if p[0] + p[1] + p[2] > 10:
+ self.bad_pixels+=1
+ if self.bad_pixels < self.pixel_count/5 and self.diff_sum < self.pixel_range*self.pixel_count/50:
self.passed = True
else:
self.passed = False
@@ -105,9 +112,9 @@
file.write('<td><img src="' + os.path.join('output', string.replace(image.name, '.blend', '_0001.png')) + '" alt="Latest Render" width="200" height="150"></td>\n')
file.write('<td><img src="' + os.path.join('output', string.replace(image.name, '.blend', '_diff.png')) + '" alt="Image Diff" width="200" height="150"></td>\n')
if image.passed:
- file.write('<td><font color="ooffoo">OK</font>: ' + str(image.bad_pixels) + ' of ' + str(image.pixel_count) + ' pixels different</td>\n')
+ file.write('<td><font color="ooffoo">OK</font>: ' + str(image.bad_pixels) + ' of ' + str(image.pixel_count) + ' pixels different, ' + str(image.diff_sum/(image.pixel_range*image.pixel_count)) + '% different.</td>\n')
else:
- file.write('<td><font color="ff0000">FAIL</font>: ' + str(image.bad_pixels) + ' of ' + str(image.pixel_count) + ' pixels different</td>\n')
+ file.write('<td><font color="ff0000">FAIL</font>: ' + str(image.bad_pixels) + ' of ' + str(image.pixel_count) + ' pixels different, ' + str(image.diff_sum/(image.pixel_range*image.pixel_count)) + '% different.</td>\n')
file.write('</tr>\n')
file.write('</table>\n</body>\n</html>')
file.close()
More information about the Bf-blender-cvs
mailing list