'*************************centers() subroutine*********************** ' ' purpose: calls findedge for each point in the history array to find ' the right and left edges and then computes the average midpoint ' ' input: SobelData array ' history array ' ' output: updated history array ' '******************************************************************** Sub centers(hcenter As Integer, wcenter As Integer, hisloc As Integer) Dim below As Integer 'how far below center to look Dim above As Integer 'how far above center to look Dim i As Integer 'counter Dim middle As Integer 'the middle of the object Dim right As Integer ' sum of pixel locations for right edge Dim left As Integer 'sum of pixel locations for left edge right = 0 left = 0 below = hcenter - 10 above = hcenter + 10 For i = below To above right = right + (findedge(wcenter, i, True)) left = left + (findedge(wcenter, i, False)) Next i middle = ((right / (above - below)) - (left / (above - below))) / 2 + (left / (above - below)) 'prevents the points from getting "stuck" at the edge of the image If middle > picWIDTH - 15 Then middle = picWIDTH - 15 If middle < 15 Then middle = 15 history(hisloc, 1) = middle End Sub