필터 지우기
필터 지우기

can I equation of a curve from an image?

조회 수: 4 (최근 30일)
Dekel Mashiach
Dekel Mashiach 2022년 4월 25일
댓글: Matt J 2022년 4월 25일
Is it possible to find the equation of a curve from an image?
I want to find the equation of the line in green:
  댓글 수: 3
Dekel Mashiach
Dekel Mashiach 2022년 4월 25일
They are supposed to be parallel, and the green line is the middle (centerline). Simulate a route of a road that a vehicle should drive on the middle line.
Matt J
Matt J 2022년 4월 25일
Note that even if your lines are parallel in the 3D world, they will geneally not be parallel in the 2D camera image, depending on the camera perspective. Likewise, the centerline in the 2D image will not correspond to the centerline in 3D.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2022년 4월 25일
편집: Matt J 2022년 4월 25일
This assumes your Image is already cast to type logical. The slope and intercept are for the center-line in matrix (row,column) coordinates.
reg=regionprops(Image,'PixelList');
x1=reg(1).PixelList(:,2);
y1=reg(1).PixelList(:,1);
x2=reg(2).PixelList(:,2);
y2=reg(2).PixelList(:,1);
A=[x1,x1.^0,0*x1;
x2,0*x2,x2.^0];
b=[y1;y2];
c=A\y;
slope=c(1);
intercept=mean(c(2:3));
  댓글 수: 7
Matt J
Matt J 2022년 4월 25일
편집: Matt J 2022년 4월 25일
If you are fitting a single polynomial of known order, N, the generalization of my answer to N>1 is
reg=regionprops(Image,'PixelList');
x1=reg(1).PixelList(:,2);
y1=reg(1).PixelList(:,1);
x2=reg(2).PixelList(:,2);
y2=reg(2).PixelList(:,1);
e=N:-1:1;
A=[x1.^e, x1.^0, 0*x1;
x2.^e, 0*x2, x2.^0];
b=[y1;y2];
c=A\y;
coefficients=[c(1:N-2)',mean(c(N-1:1))]; %polynomial coefficients
Matt J
Matt J 2022년 4월 25일
편집: Matt J 2022년 4월 25일
I identify the lines by the camera and then create the green line in the middle of the lines. I want to find the green line equation. Here is the code for finding the green line:
If you already have the points on the green line, what prevents you from using fit(), lsqcurvefit(), or similar? Also, you have articulated that you want to model this as a polynomial, but of what order? Are you sure you don't need a piecewise polynomial? In any case, fit() offers all of these.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by