I don't have time to write your code for you, but I can explain a little more.
From your line profile, you should be able to generate a series of X and Y values. X is position and Y is intensity. Split this array in half, and use curve fitting to generate a straight line through the points. A min-max fit would actually be better than a least squares, but that is more difficult to program. Once you have an equation for each half, you should be able to solve for the intersection point and also evaluate each endpoint.
Another interesting way to do it would be to use non-linear Lev-Mar fitting. You could write an equation that has four unknowns - the Y coordinates at the beginning and end, and the X and Y coordinates in the middle. You c
ould supply some good guesses to begin with, and it would iterate until the best fit was found. Take a look at the Lev-Mar vi supplied with LabVIEW. It would also give you a good idea of how much deviation there is from the straight line fit.
Bruce
Bruce Ammons
Ammons Engineering