summaryrefslogtreecommitdiff
path: root/demo.py
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2020-07-25 19:45:17 +0200
committerPaweł Redman <pawel.redman@gmail.com>2020-07-25 19:45:17 +0200
commitde339a8611548cfa3f9bd8bcdaa22afd2a6e062c (patch)
tree486e4e056e4f888eb18aae38c159b0fab32ac10a /demo.py
parentf88a852f659ea3223ce69ac147912b1d346cf7be (diff)
A new class for saving and loading datasets.
Diffstat (limited to 'demo.py')
-rw-r--r--demo.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/demo.py b/demo.py
deleted file mode 100644
index 3c4b933..0000000
--- a/demo.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import os
-import matplotlib.pyplot as plt
-
-from colour import SpectralShape, COLOURCHECKER_SDS, sd_to_XYZ
-
-from otsu2018 import load_Otsu2018_spectra, Tree
-
-
-if __name__ == '__main__':
- print('Loading spectral data...')
- sds = load_Otsu2018_spectra('CommonData/spectrum_m.csv', every_nth=50)
- shape = SpectralShape(380, 730, 10)
-
- print('Initializing the tree...')
- tree = Tree(sds, shape)
-
- print('Tree...')
- before = tree.total_reconstruction_error()
- tree.optimise()
- after = tree.total_reconstruction_error()
-
- print('Error before: %g' % before)
- print('Error after: %g' % after)
-
- print('Saving the dataset...')
- os.makedirs('datasets', exist_ok=True)
- tree.write_python_dataset('datasets/otsu2018.py')
-
- print('Plotting...')
- tree.visualise()
-
- plt.figure()
-
- examples = COLOURCHECKER_SDS['ColorChecker N Ohta'].items()
- for i, (name, sd) in enumerate(examples):
- plt.subplot(2, 3, 1 + i)
- plt.title(name)
-
- plt.plot(sd.wavelengths, sd.values, label='Original')
-
- XYZ = sd_to_XYZ(sd) / 100
- recovered_sd = tree.reconstruct(XYZ)
- plt.plot(recovered_sd.wavelengths, recovered_sd.values,
- label='Recovered')
-
- plt.legend()
-
- if i + 1 == 6:
- break
-
- plt.show()