added heatmap
This commit is contained in:
parent
21f66c740a
commit
5272dc99d9
|
|
@ -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()
|
||||||
5
main.py
5
main.py
|
|
@ -5,6 +5,7 @@ from Application.Classifiers import *
|
||||||
from Application.Config import Config
|
from Application.Config import Config
|
||||||
from Application.ContourExctractor import ContourExtractor
|
from Application.ContourExctractor import ContourExtractor
|
||||||
from Application.Exporter import Exporter
|
from Application.Exporter import Exporter
|
||||||
|
from Application.HeatMap import HeatMap
|
||||||
from Application.Importer import Importer
|
from Application.Importer import Importer
|
||||||
from Application.LayerFactory import LayerFactory
|
from Application.LayerFactory import LayerFactory
|
||||||
from Application.LayerManager import LayerManager
|
from Application.LayerManager import LayerManager
|
||||||
|
|
@ -37,11 +38,15 @@ def main():
|
||||||
layerManager = LayerManager(config, layers)
|
layerManager = LayerManager(config, layers)
|
||||||
layerManager.transformLayers()
|
layerManager.transformLayers()
|
||||||
|
|
||||||
|
|
||||||
#layerManager.tagLayers()
|
#layerManager.tagLayers()
|
||||||
layers = layerManager.layers
|
layers = layerManager.layers
|
||||||
if len(layers) == 0:
|
if len(layers) == 0:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
heatmap = HeatMap(1920, 1088, [contour for layer in layers for contour in layer.bounds], 1920/config["resizeWidth"])
|
||||||
|
heatmap.showImage()
|
||||||
|
|
||||||
exporter = Exporter(config)
|
exporter = Exporter(config)
|
||||||
print(f"Exporting {len(contours)} Contours and {len(layers)} Layers")
|
print(f"Exporting {len(contours)} Contours and {len(layers)} Layers")
|
||||||
exporter.export(layers, contours, masks, raw=True, overlayed=True)
|
exporter.export(layers, contours, masks, raw=True, overlayed=True)
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
Loading…
Reference in New Issue