diff options
author | Tomas Kulhanek <tomas.kulhanek@stfc.ac.uk> | 2019-02-21 02:11:13 -0500 |
---|---|---|
committer | Tomas Kulhanek <tomas.kulhanek@stfc.ac.uk> | 2019-02-21 02:11:13 -0500 |
commit | 61bfe1f57fbda958e24e227e567676fafd7f6d3e (patch) | |
tree | 4cc35408ea76e534ce17abd348a523d5b7bc059c /test/testroutines.py | |
parent | 3caa686662f7d937cf7eb852dde437cd66e79a6e (diff) | |
download | regularization-61bfe1f57fbda958e24e227e567676fafd7f6d3e.tar.gz regularization-61bfe1f57fbda958e24e227e567676fafd7f6d3e.tar.bz2 regularization-61bfe1f57fbda958e24e227e567676fafd7f6d3e.tar.xz regularization-61bfe1f57fbda958e24e227e567676fafd7f6d3e.zip |
restructured sources
Diffstat (limited to 'test/testroutines.py')
-rw-r--r-- | test/testroutines.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/testroutines.py b/test/testroutines.py new file mode 100644 index 0000000..8da5c5e --- /dev/null +++ b/test/testroutines.py @@ -0,0 +1,37 @@ +import numpy as np +from PIL import Image + +class TiffReader(object): + def imread(self, filename): + return np.asarray(Image.open(filename)) + + +############################################################################### +def printParametersToString(pars): + txt = r'' + for key, value in pars.items(): + if key == 'algorithm': + txt += "{0} = {1}".format(key, value.__name__) + elif key == 'input': + txt += "{0} = {1}".format(key, np.shape(value)) + elif key == 'refdata': + txt += "{0} = {1}".format(key, np.shape(value)) + else: + txt += "{0} = {1}".format(key, value) + txt += '\n' + return txt + + +def nrmse(im1, im2): + rmse = np.sqrt(np.sum((im2 - im1) ** 2) / float(im1.size)) + max_val = max(np.max(im1), np.max(im2)) + min_val = min(np.min(im1), np.min(im2)) + return 1 - (rmse / (max_val - min_val)) + + +def rmse(im1, im2): + rmse = np.sqrt(np.sum((im1 - im2) ** 2) / float(im1.size)) + return rmse + + +############################################################################### |