I'm looking for help doing a (simple?) least squares line fit to a set of points in Matlab.
I have an image with a set of points that I'm trying to fit a line to, minimizing the distance from each point to the line (least squares fit). Seems to work fine with openCV/fitline
, but we're doing our research on two platforms - the other being Matlab, and Matlab/polyfit
doesn't do the same thing as opencv/fitline
.
Per Fitting a line - MatLab disagrees with OpenCV, it seems that Polyfit
minimizes the Y distance to the line, not the least squares (perpendicular) distance.