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 characters
import cv2 | |
import numpy as np | |
from heapq import heappush, heappop | |
def find_pixels_in_window(img, x, y, window_size): | |
d = window_size//2 | |
y_start = max(y-d,0) | |
x_start = max(x-d,0) | |
window = img[y_start:y+d+1, x_start:x+d+1] | |
ay, ax = np.where(window > 0) |
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 characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.stats import multivariate_normal | |
def points_to_gaussian_heatmap(centers, height, width, scale): | |
gaussians = [] | |
for y,x in centers: | |
s = np.eye(2)*scale | |
g = multivariate_normal(mean=(x,y), cov=s) | |
gaussians.append(g) |