fixed triangle position calculation for the gradient/lbp programs

Triangles are being calculated inside an unnecessary loop.