LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PolyFit to fit a curve through an Image

Hello,

 

I have a grayscale image that needs to be analysed. You can think of a banana horizontally, banana is brighter, background is almost black. The curvature of the banana should be calculated.

I thresholded it to get binary. Cropped the sides away so that the edges of the image start within the outer parts of the banana. I mulitplied the binary values so that each value in the array represent the row number. So I get a dataset/cloud through which i could do a PolyFit.

 

The problem is: The dark areas below the threshold are zero, thus a large number of the dataset is interpreted as a line on the x-Axis, which changes the expected result of the polyfit.

 

What can I do, to only fit through the actual datapoints?

0 Kudos
Message 1 of 2
(2,168 Views)

I found the solution myself. You just have to rearrange the datasets, so that only the datapoints of interest are in them.

X_in={0,1,2 , 0,1 , 2,3,4 , ...}

Y_in={4,5,6 , 4,5 , 6,7,9 , ...}

 

I thought the datasets should contain the whole dimension of the searched dataset, like this.

X_in={0,1,2,3,4 , 0,1,2,3,4 , 0,1,2,3,4 , ...}

Y_in={4,5,6,-,-  , 4,5,-,-,   , -,-,6,7,9}

 

Hope this might help someone.

0 Kudos
Message 2 of 2
(2,130 Views)