|
12 | 12 | import time
|
13 | 13 | import csv
|
14 | 14 | import cv2
|
| 15 | +import re |
15 | 16 | import os
|
16 | 17 |
|
17 | 18 | from pathlib import Path
|
@@ -96,14 +97,31 @@ def make_gifs(self):
|
96 | 97 | plt.imshow(map_image, extent=[xmin, xmax, ymin, ymax]) # Display the screenshot as the background
|
97 | 98 | plt.axis('off')
|
98 | 99 |
|
99 |
| - plt.imshow(density.T, origin='lower', cmap='viridis', extent=[xmin, xmax, ymin, ymax],alpha=0.5) |
| 100 | + # get colormap |
| 101 | + ncolors = 256 |
| 102 | + color_array = plt.get_cmap('hot')(range(ncolors)) |
| 103 | + |
| 104 | + # change alpha values |
| 105 | + color_array[:,-1] = np.linspace(1.0,0.0,ncolors) |
| 106 | + |
| 107 | + # create a colormap object |
| 108 | + map_object = LinearSegmentedColormap.from_list(name='hot',colors=color_array) |
| 109 | + |
| 110 | + plt.imshow(density.T, origin='lower', cmap=map_object, extent=[xmin, xmax, ymin, ymax],alpha=0.5) |
100 | 111 | plt.axis('off')
|
101 | 112 | # Save the combined image with heatmap overlay
|
102 |
| - plt.savefig(f"{self.directory_raw}/heatmap_{number}_{int(prev_timestamp)}.png", bbox_inches='tight') |
| 113 | + plt.savefig(f"{self.directory_raw}/heatmap_{number}.png", bbox_inches='tight') |
103 | 114 | number+=1
|
104 | 115 |
|
| 116 | + def numerical_sort(value): |
| 117 | + parts = re.findall(r'\d+', value) |
| 118 | + return list(map(int, parts)) |
| 119 | + |
105 | 120 | images = []
|
106 |
| - for filename in glob.glob(f"{self.directory_raw}/heatmap_*.png"): |
| 121 | + file_list = glob.glob(f"{self.directory_raw}/heatmap_*.png") |
| 122 | + file_list_sorted = sorted(file_list, key=numerical_sort) |
| 123 | + for filename in file_list_sorted: |
| 124 | + print(filename) |
107 | 125 | img = cv2.imread(filename)
|
108 | 126 | img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
109 | 127 | images.append(img)
|
|
0 commit comments