Fix the default dynamic_range in PSNR and warn if inputs don't meet the assumptions made

This commit is contained in:
Gregory R. Lee
2016-01-26 18:17:56 -05:00
parent f4773e303d
commit a8124166c1
+9 -1
View File
@@ -119,7 +119,15 @@ def psnr(im_true, im_test, dynamic_range=None):
if dynamic_range is None:
dmin, dmax = dtype_range[im_true.dtype.type]
dynamic_range = dmax - dmin
dynamic_range = dmax # assume non-negative inputs
if im_true.min() < 0:
raise ValueError(
"im_true contains negative values. Please manually specify "
"the dynamic range.")
if im_true.max() > dmax:
raise ValueError(
"im_true has a larger maximum intensity than expected for its "
"data type. Please manually specify the dynamic_range")
im_true, im_test = _as_floats(im_true, im_test)