Last active
July 29, 2025 11:45
-
-
Save chexov/1157499c429a7bcaca082787091f034a to your computer and use it in GitHub Desktop.
Revisions
-
chexov revised this gist
Sep 23, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ def gaussian_heatmap(sigma: int, spread: int): extent = int(spread * sigma) center = spread * sigma / 2 heatmap = numpy.zeros([extent, extent], dtype=numpy.float32) -
chexov created this gist
Sep 23, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import cv2 import numpy def gaussian_heatmap(sigma: int, spread: int): global heatmap extent = int(spread * sigma) center = spread * sigma / 2 heatmap = numpy.zeros([extent, extent], dtype=numpy.float32) for i_ in range(extent): for j_ in range(extent): heatmap[i_, j_] = 1 / 2 / numpy.pi / (sigma ** 2) * numpy.exp( -1 / 2 * ((i_ - center - 0.5) ** 2 + (j_ - center - 0.5) ** 2) / (sigma ** 2)) heatmap = (heatmap / numpy.max(heatmap) * 255).astype(numpy.uint8) return heatmap hm = gaussian_heatmap(sigma=10, spread=3) hm = cv2.applyColorMap(hm, cv2.COLORMAP_JET) cv2.imshow("hm", hm) cv2.waitKey(0)