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