Templatizing the findWeightedCentroids function by the data type in the image.
Using min/max of the centroid's points for the x,y axis of the image to scan only the section known to have data we're interested in.
Passing arguments by constant reference as opposed to just const (which copies them).