|
From: <as...@us...> - 2009-05-19 21:29:41
|
Revision: 7124
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7124&view=rev
Author: astraw
Date: 2009-05-19 21:29:38 +0000 (Tue, 19 May 2009)
Log Message:
-----------
save difference image between failed image and baseline image
Modified Paths:
--------------
trunk/matplotlib/test/mplTest/compare.py
Modified: trunk/matplotlib/test/mplTest/compare.py
===================================================================
--- trunk/matplotlib/test/mplTest/compare.py 2009-05-19 21:29:29 UTC (rev 7123)
+++ trunk/matplotlib/test/mplTest/compare.py 2009-05-19 21:29:38 UTC (rev 7124)
@@ -5,6 +5,8 @@
import math
import operator
+import os
+import numpy as np
#=======================================================================
@@ -112,10 +114,25 @@
if ( (rms / 10000.0) <= tol ):
return None
else:
+ diff_image = os.path.join(os.path.dirname(actual),
+ 'failed-diff-'+os.path.basename(actual))
+ saveDiffImage( expected, actual, diff_image )
+
msg = " Error: Image files did not match.\n" \
" RMS Value: " + str( rms / 10000.0 ) + "\n" \
" Expected:\n " + str( expected ) + "\n" \
" Actual:\n " + str( actual ) + "\n" \
+ " Difference:\n " + str( diff_image ) + "\n" \
" Tolerance: " + str( tol ) + "\n"
return msg
+def saveDiffImage( expected, actual, output ):
+ from PIL import Image
+ expectedImage = np.array(Image.open( expected ).convert("RGB")).astype(np.float)
+ actualImage = np.array(Image.open( actual ).convert("RGB")).astype(np.float)
+ absDiffImage = abs(expectedImage-actualImage)
+ # expand differences in luminance domain
+ absDiffImage *= 10
+ save_image_np = absDiffImage.astype(np.uint8)
+ save_image = Image.fromarray(save_image_np)
+ save_image.save(output)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|