Вот то, что я придумал, используя Hough Transform:
%# read and binarize image
I = imread('http://i.stack.imgur.com/XlxmL.jpg');
BW = im2bw(rgb2gray(I));
%# hough transform, detect peaks, then get lines segments
[H T R] = hough(BW, 'Theta',-10:10); %# specific theta range
P = houghpeaks(H, 5);
lines = houghlines(BW, T, R, P);
%# overlay detected lines over image
figure, imshow(BW), hold on
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1), xy(:,2), 'g.-', 'LineWidth',2);
end
%# find endpoints (intersections) and show them
xy = [vertcat(lines.point1);vertcat(lines.point2)];
[~,idx1] = min(xy(:,2));
[~,idx2] = max(xy(:,2));
xy = xy([idx1;idx2],:); %# intersection points
plot(xy(:,1),xy(:,2), 'ro', 'LineWidth',3, 'MarkerSize',12)
hold off