LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear fit not working as expected?

Solved!
Go to solution

If only I knew...

I marked the blob coordinates (i.e. their center of mass) with yellow dots in the image to better illustrate that it clearly doesn't work. One would expect the fitted line to be tilted to the left, i.e. to be almost perfectly vertical.

 

fit without rotation_new.PNG

0 Kudos
Message 11 of 22
(1,855 Views)

Hi optimus,

 

it seems you zoomed in into your IMAQ image a lot…

 

With the coordinates you supplied in your last VI the blobs follow not a straight line, but rather a curve! The linear interpolation is correct (aka "quite ok") as said before - for the data you supplied before. Please show the full image in IMAQ - with the same range as is shown in my XY graph - for a fair comparison!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 22
(1,872 Views)

fit without rotation_complete image.PNG

 

This is the complete image. It seems clear to me that the middle column fit doesn't work as well as the first and last column fits. Yes, the blobs form a (very slight) curve, but not nearly enough to justify the tilt of the center fit line. Or am I wrong?

0 Kudos
Message 13 of 22
(1,863 Views)

Hi optimus,

 

please attach a VI with exactly the coordinates as you have trouble with in your last message!

 

The ones you attached before seems to be very different to your current data set…

 

Also there is a small green dot in the center of your image. Where does it come from? What is its meaning?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 22
(1,858 Views)

These are the coordinates I'm using. The image size is 1600x1200, the coordinates are measured from the top left corner (the origin).

For the VI I posted I just cut out the middle column and inserted it into a new black picture (also 1600x1200) using GIMP. So the coordinates should be absolutely the same.

 

I attached the complete VI with instructions in the code itself and the full blob picture I want to analyze.

 

I also included all needed subvis

0 Kudos
Message 15 of 22
(1,846 Views)

Just to chip in, I can't open your vi:s from where I am now, but are you are trying to do a linear fit in cartesian coordinates, where y=m*x+t, to a vertical line? You will have problems defining m and t in that case.



CLA
www.dvel.se
0 Kudos
Message 16 of 22
(1,837 Views)

Hi optimus,

 

please check the attached VI.

I removed all the IMAQ parts as I don't have this module installed.

 

Your points aren't always on a nice line, just play around with the "columns" control!

And as Peeker pointed out: having a nearly vertical line doesn't play well with linear interpolation!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 22
(1,837 Views)
Solution
Accepted by topic author joptimus

Maybe it would be better to transpose the data and fit for horizontal lines, then transform the result.

Message 18 of 22
(1,808 Views)

But why is it working with the left column, then? That is a almost a perfect vertical line...

I'll try to transpose, though. How do I do that if I want both - horizontal and vertical fit lines in my blob image?

 

Btw thanks all for your input so far! 🙂

0 Kudos
Message 19 of 22
(1,799 Views)
Well, I guess it's a numerical algoritm like least squared or something in the linear fit, and if the line is poorly defined as with a vertical line, it fails to get really close sometimes. It could be pure luck. Can you check the residuals from the algorithm?


CLA
www.dvel.se
0 Kudos
Message 20 of 22
(1,791 Views)