Line fit between two curves.

조회 수: 10 (최근 30일)
Mazhar
Mazhar 2013년 8월 15일
Hey Guys,
I am trying to solve a problem regarding clearances and line fitting, around and through 2 curves.
The information I have is a coordinates of 2 parallel lines, resembling a pipe. Both these lines are not completely straight and bend at certain points.
The two line can be represented as so;
x1=[0 2 4.5 7 9];
y1=[0.7 2 4 5.5 7.5];
y2=y1+1;
plot(x1,y1,'-r')
hold on
plot(x1,y2,'-r')
grid on
I want the program to check whether a straight line of length 10 units will fit within these two line with out touching the edges. And if so how will this line sit within the two parallel lines.
The final image should look similar to this;
(add to end of previous code)
xb=[0.5 8.5];
yb=[1.5 7.5];
plot(xb,yb,'-b')
Please advice as to which commands, if any would be useful. Or what mathematical approach I should take to try and solve this.
Thanks,
  댓글 수: 6
Matt J
Matt J 2013년 8월 19일
Do you have the Optimization Toolbox? And will the pipe boundaries always be definable using a function y=f(x)? If the pipe were circular, for example, there would not be an f(x) defining its boundaries.
Mazhar
Mazhar 2013년 8월 19일
The pipe boundaries are only given by (x,y) coordinates. It will be possible to fit polygons to the coordinates I guess, but there is no given function for the pipe.

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

답변 (2개)

Image Analyst
Image Analyst 2013년 8월 15일
There may be simpler ways, but it looks like SVM (Support Vector Machine) would work. http://en.wikipedia.org/wiki/Support_vector_machine
  댓글 수: 10
Image Analyst
Image Analyst 2013년 8월 16일
I thought it was the same length. If it's not, you'd have to check for every x value just going up to the length of the stick. Like for x elements 1-10, 2-11, 3-12, and so on until you get within 10 of the end. Should be pretty fast though since we're only dealing with small arrays, not megabytes of data.
Mazhar
Mazhar 2013년 8월 19일
Yeah, the approach for calculating this will, carry out the test for a section of pipe the same length as the line/stick, if that test passes, it moves on to the next section (the sections will be tested with an overlap, as you said above: 1-10, 2-11, 3-12).
The "fit" is in most cases simple; usually the line of best-fit, between the coordinates of both sides of the pipe, will fit through nicely.
In the "no-fit" (best-fit line does not fit) case, however, there are infinitely number of ways to move the line (rotate at start, at end, in the middle, pan left to right etc.) And I'm just struggling to determine what testing the line should carry out!
I was thinking start with the best-fit line, if it fits, thats great and we can check the next section. If not, then the program will try to change the equation of the best-fit line (gradient and y-intercept) in an orderly manner, and should eventually find a solution.
The program will stop testing when the gradient (or y-intercept) lie outside the pipe mean gradient and y-intercepts.

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


Matt J
Matt J 2013년 8월 15일
편집: Matt J 2013년 8월 15일
I recommend that you make a binary image of the pipe (e.g., using ROIFILL) and then use HOUGHLINES with the 'MinLength' option to find a segment of (at least) length 10.
  댓글 수: 11
Mazhar
Mazhar 2013년 8월 22일
Sorry I meant to say earlier, no I don't have the optimization toolbox :(.
Am I able to add in my own constraints? eg. the position can be checked for it being with in the pipe, if not then it is re-adjusted.
Matt J
Matt J 2013년 8월 22일
You can set the value of your objective function to Inf for position parameters that put the stick outside the pipe.

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

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by