I think the following is a pretty decent way of getting an approximation of the tip’s locations:
W = 10
cols = [col for row in -W:W for col in -W:W]
rows = [row for row in -W:W for col in -W:W]
win = CartesianIndex.(rows, cols)
frame = img[p .+ win]
w = Float64.(frame)
w -= mean(w)
clamp!(w, 0, 1)
yx = Float64.([rows cols])
μ = mean(yx, StatsBase.Weights(w), 1)
p = CartesianIndex(round.(Int, μ)...) + p
So now I have a list of estimated locations. I should therefore be able to use a Kalman filter on that list in order to improve on these estimates. Since this next step is separate from acquiring the tip estimates, I’ll start a new topic just for that.