kopia lustrzana https://github.com/OpenDroneMap/WebODM
Extracted colormaps from main code. Added as side util class
rodzic
92064410dc
commit
734b7ebd86
|
@ -1,297 +0,0 @@
|
||||||
import matplotlib
|
|
||||||
import numpy
|
|
||||||
|
|
||||||
ndvi = matplotlib.colors.LinearSegmentedColormap.from_list(
|
|
||||||
'ndvi', [
|
|
||||||
'#AD0028',
|
|
||||||
'#C5142A',
|
|
||||||
'#E02D2C',
|
|
||||||
'#EF4C3A',
|
|
||||||
'#FE6C4A',
|
|
||||||
'#FF8D5A',
|
|
||||||
'#FFAB69',
|
|
||||||
'#FFC67D',
|
|
||||||
'#FFE093',
|
|
||||||
'#FFEFAB',
|
|
||||||
'#FDFEC2',
|
|
||||||
'#EAF7AC',
|
|
||||||
'#FDFEC2',
|
|
||||||
'#EAF7AC',
|
|
||||||
'#D5EF94',
|
|
||||||
'#B9E383',
|
|
||||||
'#9BD873',
|
|
||||||
'#B9E383',
|
|
||||||
'#9BD873',
|
|
||||||
'#77CA6F',
|
|
||||||
'#53BD6B',
|
|
||||||
'#14AA60',
|
|
||||||
'#009755',
|
|
||||||
'#007E47',
|
|
||||||
],
|
|
||||||
256,
|
|
||||||
)
|
|
||||||
|
|
||||||
x = numpy.linspace(0, 1, 256)
|
|
||||||
cmap_vals = ndvi(x)[:, :]
|
|
||||||
cmap_uint8 = (cmap_vals * 255).astype('uint8')
|
|
||||||
ndvi_dict = {idx: value.tolist() for idx, value in enumerate(cmap_uint8)}
|
|
||||||
|
|
||||||
custom_colormaps = [{"discrete_ndvi": {
|
|
||||||
0: [174, 0, 40, 255],
|
|
||||||
1: [174, 0, 40, 255],
|
|
||||||
2: [174, 0, 40, 255],
|
|
||||||
3: [174, 0, 40, 255],
|
|
||||||
4: [174, 0, 40, 255],
|
|
||||||
5: [174, 0, 40, 255],
|
|
||||||
6: [174, 0, 40, 255],
|
|
||||||
7: [174, 0, 40, 255],
|
|
||||||
8: [174, 0, 40, 255],
|
|
||||||
9: [174, 0, 40, 255],
|
|
||||||
10: [174, 0, 40, 255],
|
|
||||||
11: [174, 0, 40, 255],
|
|
||||||
12: [174, 0, 40, 255],
|
|
||||||
13: [174, 0, 40, 255],
|
|
||||||
14: [174, 0, 40, 255],
|
|
||||||
15: [174, 0, 40, 255],
|
|
||||||
16: [174, 0, 40, 255],
|
|
||||||
17: [174, 0, 40, 255],
|
|
||||||
18: [174, 0, 40, 255],
|
|
||||||
19: [174, 0, 40, 255],
|
|
||||||
20: [174, 0, 40, 255],
|
|
||||||
21: [174, 0, 40, 255],
|
|
||||||
22: [174, 0, 40, 255],
|
|
||||||
23: [174, 0, 40, 255],
|
|
||||||
24: [174, 0, 40, 255],
|
|
||||||
25: [174, 0, 40, 255],
|
|
||||||
26: [174, 0, 40, 255],
|
|
||||||
27: [174, 0, 40, 255],
|
|
||||||
28: [174, 0, 40, 255],
|
|
||||||
29: [174, 0, 40, 255],
|
|
||||||
30: [174, 0, 40, 255],
|
|
||||||
31: [174, 0, 40, 255],
|
|
||||||
32: [174, 0, 40, 255],
|
|
||||||
33: [174, 0, 40, 255],
|
|
||||||
34: [174, 0, 40, 255],
|
|
||||||
35: [174, 0, 40, 255],
|
|
||||||
36: [174, 0, 40, 255],
|
|
||||||
37: [174, 0, 40, 255],
|
|
||||||
38: [174, 0, 40, 255],
|
|
||||||
39: [174, 0, 40, 255],
|
|
||||||
40: [174, 0, 40, 255],
|
|
||||||
41: [174, 0, 40, 255],
|
|
||||||
42: [174, 0, 40, 255],
|
|
||||||
43: [174, 0, 40, 255],
|
|
||||||
44: [174, 0, 40, 255],
|
|
||||||
45: [174, 0, 40, 255],
|
|
||||||
46: [174, 0, 40, 255],
|
|
||||||
47: [174, 0, 40, 255],
|
|
||||||
48: [174, 0, 40, 255],
|
|
||||||
49: [174, 0, 40, 255],
|
|
||||||
50: [174, 0, 40, 255],
|
|
||||||
51: [254, 142, 86, 255],
|
|
||||||
52: [254, 142, 86, 255],
|
|
||||||
53: [254, 142, 86, 255],
|
|
||||||
54: [254, 142, 86, 255],
|
|
||||||
55: [254, 142, 86, 255],
|
|
||||||
56: [254, 142, 86, 255],
|
|
||||||
57: [254, 142, 86, 255],
|
|
||||||
58: [254, 142, 86, 255],
|
|
||||||
59: [254, 142, 86, 255],
|
|
||||||
60: [254, 142, 86, 255],
|
|
||||||
61: [254, 142, 86, 255],
|
|
||||||
62: [254, 142, 86, 255],
|
|
||||||
63: [254, 142, 86, 255],
|
|
||||||
64: [254, 142, 86, 255],
|
|
||||||
65: [254, 142, 86, 255],
|
|
||||||
66: [254, 142, 86, 255],
|
|
||||||
67: [254, 142, 86, 255],
|
|
||||||
68: [254, 142, 86, 255],
|
|
||||||
69: [254, 142, 86, 255],
|
|
||||||
70: [254, 142, 86, 255],
|
|
||||||
71: [254, 142, 86, 255],
|
|
||||||
72: [254, 142, 86, 255],
|
|
||||||
73: [254, 142, 86, 255],
|
|
||||||
74: [254, 142, 86, 255],
|
|
||||||
75: [254, 142, 86, 255],
|
|
||||||
76: [254, 142, 86, 255],
|
|
||||||
77: [254, 142, 86, 255],
|
|
||||||
78: [254, 142, 86, 255],
|
|
||||||
79: [254, 142, 86, 255],
|
|
||||||
80: [254, 142, 86, 255],
|
|
||||||
81: [254, 142, 86, 255],
|
|
||||||
82: [254, 142, 86, 255],
|
|
||||||
83: [254, 142, 86, 255],
|
|
||||||
84: [254, 142, 86, 255],
|
|
||||||
85: [254, 142, 86, 255],
|
|
||||||
86: [254, 142, 86, 255],
|
|
||||||
87: [254, 142, 86, 255],
|
|
||||||
88: [254, 142, 86, 255],
|
|
||||||
89: [254, 142, 86, 255],
|
|
||||||
90: [254, 142, 86, 255],
|
|
||||||
91: [254, 142, 86, 255],
|
|
||||||
92: [254, 142, 86, 255],
|
|
||||||
93: [254, 142, 86, 255],
|
|
||||||
94: [254, 142, 86, 255],
|
|
||||||
95: [254, 142, 86, 255],
|
|
||||||
96: [254, 142, 86, 255],
|
|
||||||
97: [254, 142, 86, 255],
|
|
||||||
98: [254, 142, 86, 255],
|
|
||||||
99: [254, 142, 86, 255],
|
|
||||||
100: [254, 142, 86, 255],
|
|
||||||
101: [254, 142, 86, 255],
|
|
||||||
102: [236, 246, 177, 255],
|
|
||||||
103: [236, 246, 177, 255],
|
|
||||||
104: [236, 246, 177, 255],
|
|
||||||
105: [236, 246, 177, 255],
|
|
||||||
106: [236, 246, 177, 255],
|
|
||||||
107: [236, 246, 177, 255],
|
|
||||||
108: [236, 246, 177, 255],
|
|
||||||
109: [236, 246, 177, 255],
|
|
||||||
110: [236, 246, 177, 255],
|
|
||||||
111: [236, 246, 177, 255],
|
|
||||||
112: [236, 246, 177, 255],
|
|
||||||
113: [236, 246, 177, 255],
|
|
||||||
114: [236, 246, 177, 255],
|
|
||||||
115: [236, 246, 177, 255],
|
|
||||||
116: [236, 246, 177, 255],
|
|
||||||
117: [236, 246, 177, 255],
|
|
||||||
118: [236, 246, 177, 255],
|
|
||||||
119: [236, 246, 177, 255],
|
|
||||||
120: [236, 246, 177, 255],
|
|
||||||
121: [236, 246, 177, 255],
|
|
||||||
122: [236, 246, 177, 255],
|
|
||||||
123: [236, 246, 177, 255],
|
|
||||||
124: [236, 246, 177, 255],
|
|
||||||
125: [236, 246, 177, 255],
|
|
||||||
126: [236, 246, 177, 255],
|
|
||||||
127: [236, 246, 177, 255],
|
|
||||||
128: [236, 246, 177, 255],
|
|
||||||
129: [236, 246, 177, 255],
|
|
||||||
130: [236, 246, 177, 255],
|
|
||||||
131: [236, 246, 177, 255],
|
|
||||||
132: [236, 246, 177, 255],
|
|
||||||
133: [236, 246, 177, 255],
|
|
||||||
134: [236, 246, 177, 255],
|
|
||||||
135: [236, 246, 177, 255],
|
|
||||||
136: [236, 246, 177, 255],
|
|
||||||
137: [236, 246, 177, 255],
|
|
||||||
138: [236, 246, 177, 255],
|
|
||||||
139: [236, 246, 177, 255],
|
|
||||||
140: [236, 246, 177, 255],
|
|
||||||
141: [236, 246, 177, 255],
|
|
||||||
142: [236, 246, 177, 255],
|
|
||||||
143: [236, 246, 177, 255],
|
|
||||||
144: [236, 246, 177, 255],
|
|
||||||
145: [236, 246, 177, 255],
|
|
||||||
146: [236, 246, 177, 255],
|
|
||||||
147: [236, 246, 177, 255],
|
|
||||||
148: [236, 246, 177, 255],
|
|
||||||
149: [236, 246, 177, 255],
|
|
||||||
150: [236, 246, 177, 255],
|
|
||||||
151: [236, 246, 177, 255],
|
|
||||||
152: [236, 246, 177, 255],
|
|
||||||
153: [84, 188, 108, 255],
|
|
||||||
154: [1, 126, 71, 255],
|
|
||||||
155: [1, 126, 71, 255],
|
|
||||||
156: [1, 126, 71, 255],
|
|
||||||
157: [1, 126, 71, 255],
|
|
||||||
158: [1, 126, 71, 255],
|
|
||||||
159: [1, 126, 71, 255],
|
|
||||||
160: [1, 126, 71, 255],
|
|
||||||
161: [1, 126, 71, 255],
|
|
||||||
162: [1, 126, 71, 255],
|
|
||||||
163: [1, 126, 71, 255],
|
|
||||||
164: [1, 126, 71, 255],
|
|
||||||
165: [1, 126, 71, 255],
|
|
||||||
166: [1, 126, 71, 255],
|
|
||||||
167: [1, 126, 71, 255],
|
|
||||||
168: [1, 126, 71, 255],
|
|
||||||
169: [1, 126, 71, 255],
|
|
||||||
170: [1, 126, 71, 255],
|
|
||||||
171: [1, 126, 71, 255],
|
|
||||||
172: [1, 126, 71, 255],
|
|
||||||
173: [1, 126, 71, 255],
|
|
||||||
174: [1, 126, 71, 255],
|
|
||||||
175: [1, 126, 71, 255],
|
|
||||||
176: [1, 126, 71, 255],
|
|
||||||
177: [1, 126, 71, 255],
|
|
||||||
178: [1, 126, 71, 255],
|
|
||||||
179: [1, 126, 71, 255],
|
|
||||||
180: [1, 126, 71, 255],
|
|
||||||
181: [1, 126, 71, 255],
|
|
||||||
182: [1, 126, 71, 255],
|
|
||||||
183: [1, 126, 71, 255],
|
|
||||||
184: [1, 126, 71, 255],
|
|
||||||
185: [1, 126, 71, 255],
|
|
||||||
186: [1, 126, 71, 255],
|
|
||||||
187: [1, 126, 71, 255],
|
|
||||||
188: [1, 126, 71, 255],
|
|
||||||
189: [1, 126, 71, 255],
|
|
||||||
190: [1, 126, 71, 255],
|
|
||||||
191: [1, 126, 71, 255],
|
|
||||||
192: [1, 126, 71, 255],
|
|
||||||
193: [1, 126, 71, 255],
|
|
||||||
194: [1, 126, 71, 255],
|
|
||||||
195: [1, 126, 71, 255],
|
|
||||||
196: [1, 126, 71, 255],
|
|
||||||
197: [1, 126, 71, 255],
|
|
||||||
198: [1, 126, 71, 255],
|
|
||||||
199: [1, 126, 71, 255],
|
|
||||||
200: [1, 126, 71, 255],
|
|
||||||
201: [1, 126, 71, 255],
|
|
||||||
202: [1, 126, 71, 255],
|
|
||||||
203: [1, 126, 71, 255],
|
|
||||||
204: [1, 126, 71, 255],
|
|
||||||
205: [1, 126, 71, 255],
|
|
||||||
206: [1, 126, 71, 255],
|
|
||||||
207: [1, 126, 71, 255],
|
|
||||||
208: [1, 126, 71, 255],
|
|
||||||
209: [1, 126, 71, 255],
|
|
||||||
210: [1, 126, 71, 255],
|
|
||||||
211: [1, 126, 71, 255],
|
|
||||||
212: [1, 126, 71, 255],
|
|
||||||
213: [1, 126, 71, 255],
|
|
||||||
214: [1, 126, 71, 255],
|
|
||||||
215: [1, 126, 71, 255],
|
|
||||||
216: [1, 126, 71, 255],
|
|
||||||
217: [1, 126, 71, 255],
|
|
||||||
218: [1, 126, 71, 255],
|
|
||||||
219: [1, 126, 71, 255],
|
|
||||||
220: [1, 126, 71, 255],
|
|
||||||
221: [1, 126, 71, 255],
|
|
||||||
222: [1, 126, 71, 255],
|
|
||||||
223: [1, 126, 71, 255],
|
|
||||||
224: [1, 126, 71, 255],
|
|
||||||
225: [1, 126, 71, 255],
|
|
||||||
226: [1, 126, 71, 255],
|
|
||||||
227: [1, 126, 71, 255],
|
|
||||||
228: [1, 126, 71, 255],
|
|
||||||
229: [1, 126, 71, 255],
|
|
||||||
230: [1, 126, 71, 255],
|
|
||||||
231: [1, 126, 71, 255],
|
|
||||||
232: [1, 126, 71, 255],
|
|
||||||
233: [1, 126, 71, 255],
|
|
||||||
234: [1, 126, 71, 255],
|
|
||||||
235: [1, 126, 71, 255],
|
|
||||||
236: [1, 126, 71, 255],
|
|
||||||
237: [1, 126, 71, 255],
|
|
||||||
238: [1, 126, 71, 255],
|
|
||||||
239: [1, 126, 71, 255],
|
|
||||||
240: [1, 126, 71, 255],
|
|
||||||
241: [1, 126, 71, 255],
|
|
||||||
242: [1, 126, 71, 255],
|
|
||||||
243: [1, 126, 71, 255],
|
|
||||||
244: [1, 126, 71, 255],
|
|
||||||
245: [1, 126, 71, 255],
|
|
||||||
246: [1, 126, 71, 255],
|
|
||||||
247: [1, 126, 71, 255],
|
|
||||||
248: [1, 126, 71, 255],
|
|
||||||
249: [1, 126, 71, 255],
|
|
||||||
250: [1, 126, 71, 255],
|
|
||||||
251: [1, 126, 71, 255],
|
|
||||||
252: [1, 126, 71, 255],
|
|
||||||
253: [1, 126, 71, 255],
|
|
||||||
254: [1, 126, 71, 255],
|
|
||||||
255: [1, 126, 71, 255]
|
|
||||||
}}, {"better_discrete_ndvi": ndvi_dict}]
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
import matplotlib
|
||||||
|
import numpy
|
||||||
|
|
||||||
|
def generate_discrete_color_map_from_list_of_hex(list_of_hex_colors):
|
||||||
|
colormap = matplotlib.colors.ListedColormap(list_of_hex_colors)
|
||||||
|
color_map_dict = extract_colormap_dict_from_arr(colormap)
|
||||||
|
return color_map_dict
|
||||||
|
def generate_linerar_segmented_color_map_from_list_of_hex(list_of_hex_colors, name_of_colormap="default_name", N=256):
|
||||||
|
colormap = matplotlib.colors.LinearSegmentedColormap.from_list(name_of_colormap, list_of_hex_colors, N)
|
||||||
|
color_map_dict = extract_colormap_dict_from_arr(colormap)
|
||||||
|
return color_map_dict
|
||||||
|
def extract_colormap_dict_from_arr(colormap):
|
||||||
|
x = numpy.linspace(0, 1, 256)
|
||||||
|
cmap_vals = colormap(x)[:, :]
|
||||||
|
cmap_uint8 = (cmap_vals * 255).astype('uint8')
|
||||||
|
ndvi_dict = {idx: value.tolist() for idx, value in enumerate(cmap_uint8)}
|
||||||
|
return ndvi_dict
|
||||||
|
ndvi_arr = [
|
||||||
|
'#AD0028',
|
||||||
|
'#C5142A',
|
||||||
|
'#E02D2C',
|
||||||
|
'#EF4C3A',
|
||||||
|
'#FE6C4A',
|
||||||
|
'#FF8D5A',
|
||||||
|
'#FFAB69',
|
||||||
|
'#FFC67D',
|
||||||
|
'#FFE093',
|
||||||
|
'#FFEFAB',
|
||||||
|
'#FDFEC2',
|
||||||
|
'#EAF7AC',
|
||||||
|
'#D5EF94',
|
||||||
|
'#B9E383',
|
||||||
|
'#9BD873',
|
||||||
|
'#77CA6F',
|
||||||
|
'#53BD6B',
|
||||||
|
'#14AA60',
|
||||||
|
'#009755',
|
||||||
|
'#007E47'
|
||||||
|
]
|
||||||
|
contrast_ndvi_arr = [
|
||||||
|
'#AD0028',
|
||||||
|
'#FFAB69',
|
||||||
|
'#FDFEC2',
|
||||||
|
'#77CA6F',
|
||||||
|
'#014729'
|
||||||
|
]
|
||||||
|
|
||||||
|
custom_colormaps = [
|
||||||
|
{"discrete_ndvi": generate_discrete_color_map_from_list_of_hex(contrast_ndvi_arr)},
|
||||||
|
{"better_discrete_ndvi": generate_discrete_color_map_from_list_of_hex(ndvi_arr)},
|
||||||
|
#add custom maps here
|
||||||
|
]
|
|
@ -14,7 +14,7 @@ from rio_tiler.profiles import img_profiles
|
||||||
from rio_tiler.colormap import cmap as colormap
|
from rio_tiler.colormap import cmap as colormap
|
||||||
from rio_tiler.io import COGReader
|
from rio_tiler.io import COGReader
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from custom_colormaps import custom_colormaps
|
from app.api.custom_colormaps_helper import custom_colormaps
|
||||||
from app.raster_utils import export_raster_index
|
from app.raster_utils import export_raster_index
|
||||||
from .hsvblend import hsv_blend
|
from .hsvblend import hsv_blend
|
||||||
from .hillshade import LightSource
|
from .hillshade import LightSource
|
||||||
|
|
Ładowanie…
Reference in New Issue