LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

B-spline curve: wrong interpolation

Solved!
Go to solution

Hello,

 

After some vision operation, I estimated some points which represent the middle line of an image contour as:

 

mid.jpg

 

After, applying B-spline algorithm, I expect a curve such as one :

 

exp.jpg

 

However, the output result is:

 

spline.jpg

 

Can anybody help me to solve this problem?

 

Thanks in advance

0 Kudos
Message 1 of 12
(2,129 Views)

Hello,

 

I need to develop a program to find the middle line for variety image contours (different shapes). I have already found a way to extract the middle line by using the distance transform, skeleton and some other morphology algorithms:

 

mid.jpg

 

Now, My problem is curve fitting. After applying B-spline algorithm, I obtained the following result:

 

spline.jpg

 

this is in the contrary of my expectoration as:

 

  • exp.jpg

Do you have any idea?

 

Thank you for your help in advance.

 

 

 

0 Kudos
Message 2 of 12
(2,108 Views)

Hi Erfan,

 


@Erfan_Persia wrote:

Can anybody help me to solve this problem?


Well, we would help much better once you attach a VI with your data embedded and the currently used algorithm so we can examine/run/debug/edit that VI…

 

Edit:

No need to post the same question twice in different threads. Keep related discussions in one place!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 12
(2,115 Views)

have you sorted those x,y point pairs ?

are you using all points  at once or are you using subsets eg. 4 points ?

 

 

long time ago, I posted this demo to calculate bezier curves natively in LabView:

https://forums.ni.com/t5/LabVIEW/fill-a-figure-in-a-xy-graph-with-equidistant-points/m-p/3178713#M91...

 

 

 

0 Kudos
Message 4 of 12
(2,074 Views)

Hi,

 

You may find the vi and data set files in the attachments.

 

After sorting the data, the outcome result is:

 

Erfan_Persia_0-1660939496035.png

 

 

 

Thanks,

Erfan

 

Download All
0 Kudos
Message 5 of 12
(2,044 Views)

I'm pretty sure that the problem is that the spline fit needs to get the points to fit in order, but when you say you "sorted the points" what you are actually saying is that you sorted them by one of their coordinate values... NOT the order the points should appear in.

 

If your data looks somewhat circular all the time, you could try something like this instead:

1. Start by doing a circle fit.  LabVIEW doesn't have one, but it has a sphere fit which works as a circle fit if you just use zero for all of the Z values.

2. Take the center of that circle.  From there, calculate the angle to each point.

3. Sort the points by that angle.

4. Pass the points using that sorting to the spline algorithm.

 

If your data doesn't always look circular you might have to get more creative with the sorting, but you need to put them in actual order, not just sort by one column of values and disregard the order of the other column.

Message 6 of 12
(2,028 Views)

My data could represent any shape !

What do you mean by "actual order" ?

0 Kudos
Message 7 of 12
(2,023 Views)
Solution
Accepted by topic author Erfan_Persia

@Erfan_Persia wrote:

My data could represent any shape !

What do you mean by "actual order" ?


Kyle97330_0-1660945249472.png

 

Message 8 of 12
(2,004 Views)

thank you for your reply !

Do you have any idea to develop the algorithm?

May I use complex numbers theory?

0 Kudos
Message 9 of 12
(1,999 Views)

Well the best I can think of is one where you start at one end somehow, then move to the point that's closest to that, and so on.  I don't know how you could reliably choose a good starting point for an arbitrary share though, and also it take a long time to run that algorithm if you add a lot of points (proportional to the square of the number of points).

0 Kudos
Message 10 of 12
(1,994 Views)