added heatmap

This commit is contained in:
Askill 2022-01-09 12:25:22 +01:00
parent 21f66c740a
commit 5272dc99d9
3 changed files with 25 additions and 0 deletions

20
Application/HeatMap.py Normal file
View File

@ -0,0 +1,20 @@
import numpy as np
from matplotlib import pyplot as plt
class HeatMap:
def __init__(self, x, y, contours, resizeFactor = 1):
self.imageBW = np.zeros(shape=[y, x, 3], dtype=np.float64)
self._resizeFactor = resizeFactor
self._createImage(contours)
def _createImage(self, contours):
for contour in contours:
for x, y, w, h in contour:
x, y, w, h = x*self._resizeFactor, y*self._resizeFactor, w*self._resizeFactor, h*self._resizeFactor
self.imageBW[int(y):int(y+h), int(x):int(x+w)] += 1
self.imageBW = np.nan_to_num(self.imageBW/ self.imageBW.sum(axis=1)[:, np.newaxis], 0)
def showImage(self):
plt.imshow(self.imageBW*255)
plt.show()

View File

@ -5,6 +5,7 @@ from Application.Classifiers import *
from Application.Config import Config
from Application.ContourExctractor import ContourExtractor
from Application.Exporter import Exporter
from Application.HeatMap import HeatMap
from Application.Importer import Importer
from Application.LayerFactory import LayerFactory
from Application.LayerManager import LayerManager
@ -37,11 +38,15 @@ def main():
layerManager = LayerManager(config, layers)
layerManager.transformLayers()
#layerManager.tagLayers()
layers = layerManager.layers
if len(layers) == 0:
exit(1)
heatmap = HeatMap(1920, 1088, [contour for layer in layers for contour in layer.bounds], 1920/config["resizeWidth"])
heatmap.showImage()
exporter = Exporter(config)
print(f"Exporting {len(contours)} Contours and {len(layers)} Layers")
exporter.export(layers, contours, masks, raw=True, overlayed=True)

BIN
output/heatmap_x23.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB