Intersection points of lines in image and image border
Load and display an image.
I = imread('rice.png'); figure; imshow(I); hold on;
Define a line with the equation, 2 * x + y - 300 = 0.
aLine = [2,1,-300];
Compute the intersection points of the line and the image border.
points = lineToBorderPoints(aLine,size(I))
points = 1×4 149.7500 0.5000 21.7500 256.5000
lines— Line matrix
Line matrix, specified as an M-by-3 matrix, where each row must be in the format, [A,B,C]. This matrix corresponds to the definition of the line:
|A * x + B * y + C = 0.|
lines must be
points— Intersection points
Intersection points, returned as an M-by-4 matrix. The function
returns the matrix in the format of [x1,
y2]. In this matrix,
y2] are the two intersection points. When a
line in the image and the image border do not intersect, the function returns