def find_peaks(heatmap):
    """
    Given a 2D heatmap, return a list of (x,y) positions of all local maxima (peaks)
    """
    # clean up heatmap by setting all values < 0.3 to 0
    heatmap[heatmap < 0.2] = 0
    
    # simple nested loop to check for peaks (boundary pixels are ignored)
    h,w = heatmap.shape
    peak_locations = []
    for i in range(h-2):
        i+=1
        for j in range(w-2):
            j+=1
            peak = (heatmap[i][j] > heatmap[i-1][j]) & (heatmap[i][j] > heatmap[i+1][j]) \
                    & (heatmap[i][j] > heatmap[i][j-1]) & (heatmap[i][j] > heatmap[i][j+1])
            if peak:
                peak_locations.append((i/h,j/w)) # positions are normalized from 0-1 so that it's not affected by changes in image size (for now it's fixed at 360*640)
    return peak_locations