From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the middle line of an image contour

Hello,

 

Can every body help me to find the center-line of an image contour such as one in the figure?

 

Thanks in advance, erfan_04.png

 

0 Kudos
Message 1 of 2
(692 Views)

This is not the way to ask questions. Provide more info.

 

What is the expected output? A curve? Polygonal chain? Pixelated 1 pixel thick line? Is it for this shape only? Then draw it by hand. Is it for different shape? What are the shapes like? Is it always curved like this? Does 4 piece polygonal chain satisfy your needs? Does a 100 piece one? If you have the formula and want to fill the coeficients, then google RANSAC. If you want e.g. spline, that you would have to code some iterative optimising algorithm. There are millions of ways.

 

I will answer for the case of 1 pixel thick line, I would try removing the edge white pixels by one layer at a time, only if the pixel removal does not split the area in half (every white 8-neighbor of removed pixel has a white path to each other leading through the removed pixel white 8-neighbors). When you acquire 1-pixel line, you might need to use a line-straightening technique.

 

Calculating the convex hull (envelope) from the white pixels first could lead to something useful.

0 Kudos
Message 2 of 2
(666 Views)