This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Intersection points of lines in image and image border


points = lineToBorderPoints(lines,imageSize)


points = lineToBorderPoints(lines,imageSize) computes the intersection points between one or more lines in an image with the image border.

Input Arguments


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:

A * x + B * y + C = 0.

M represents the number of lines.

lines must be double or single.


Image size. This input must be in the format returned by the size function.

imageSize must be double, single, or integer.

Output Arguments


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 [-1,-1,-1,-1].


collapse all

Load and display an image.

I = imread('rice.png');
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 =

  149.7500    0.5000   21.7500  256.5000

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2011a

Was this topic helpful?