Try the camera calibrator: https://www.mathworks.com/products/computer-vision.html
Otherwise try to find the left, right, top, and bottom coordinates and use polyfit to fit a line through them.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!