Mercurial > hg > orthanc-stone
annotate Resources/Colormaps/GenerateColormaps.py @ 1314:9b126de2cde2 broker
Since the observer system now uses shared_ptr and many registrations are
done in the constructors, and since we cannot called shared_from_this() in
the constructors, it is mandatory to split construction from registration.
This has been done by making many ctors protected and replacing them
by factory methods that directly return shared_ptrs + added PostConstructor
method when base classes perform shared_from_this() calls too.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 16 Mar 2020 11:19:50 +0100 |
parents | 351ab0da0150 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 | |
3 import array | |
4 import matplotlib.pyplot as plt | |
5 | |
6 def GenerateColormap(name): | |
7 colormap = [] | |
8 | |
9 for gray in range(256): | |
10 if name == 'red': | |
11 color = (gray / 255.0, 0, 0) | |
12 elif name == 'green': | |
13 color = (0, gray / 255.0, 0) | |
14 elif name == 'blue': | |
15 color = (0, 0, gray / 255.0) | |
16 else: | |
17 color = plt.get_cmap(name) (gray) | |
18 | |
19 colormap += map(lambda k: int(round(color[k] * 255)), range(3)) | |
20 | |
21 colormap[0] = 0 | |
22 colormap[1] = 0 | |
23 colormap[2] = 0 | |
24 | |
25 return array.array('B', colormap).tostring() | |
26 | |
27 | |
28 for name in [ | |
29 'hot', | |
30 'jet', | |
31 'blue', | |
32 'green', | |
33 'red', | |
34 ]: | |
35 with open('%s.lut' % name, 'w') as f: | |
36 f.write(GenerateColormap(name)) |