def getEnergy(tl, t, tr, l, r, dl, d, dr):
    """helper for getEnergyMap that returns the energy of a single pixel given its neighbors"""
    vertEnergy = tl + 2 * t + tr - dl - 2 * d - dr
    horizEnergy = tl + 2 * l + dl - tr - 2 * r - dr
    return (vertEnergy ** 2 + horizEnergy ** 2) ** 0.5