Intersection points of lines in image and image border
points = lineToBorderPoints(lines,imageSize)
Code Generation Support:
Compile-time constant input: No restrictions
Supports MATLAB Function block: Yes
Code Generation Support, Usage Notes, and Limitations
Line matrix. 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:
M represents the number of lines.
Image size. This input must be in the format returned by the
Output intersection points. An M-by-4 matrix.
The function returns the matrix in the format of [x1, y1, x2, y2].
In this matrix, [x1 y1]
and [x2 y2]
are the two intersection points. When a line in the image and the
image border do not intersect, the function returns [
Find the intersection points of a line in an image and the image border.
% Load and display an image. I = imread('rice.png'); figure; imshow(I); hold on; % Define a line: 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)); line(points([1,3]), points([2,4]));