Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Find end points of line

Hi All,

I have a binary image which has a single line obtained after some processing done on a grayscale input image as seen in the attached image. How can I find the end points of this line? 

Thanks

Regards

Aveo

0 Kudos
Message 1 of 11
(4,459 Views)

You can use edge detection where you can get end point of a line

One more method, you can use IMAGE to Array where you can get array of pixels you can filter using some operations with offset above certain value to get the line pixel and find the end points of a line from an array.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 11
(4,438 Views)

Hi,

The line can be oriented in any direction, not just the horizontal plane. As far as I remember, the first approach to detect edge might not work because of the search direction parameter. Am I right?

The second solution is good, however with increase in image size, the number of iterations will increase in order to check for end points.

 

Another method that I have been working on is to find the max feret start XY and end XY using IMAQ particle analysis. This takes care of the rotation of the line too. I have been testing it with my image sets. So far it has worked. 😉 I will update if it fails. 

0 Kudos
Message 3 of 11
(4,436 Views)
Curious Why does the Bounding rectangle doesn't help to give the end points?
Thanks
uday
0 Kudos
Message 4 of 11
(4,432 Views)

Interesting thought!  Yes we can use bounding box to get the point coordinates.

However suppose we have two lines as shown in the attached image. Both will give the same bounding box. It will be difficult to interpret whether the line start point is at the top left corner or bottom left corner. 

One way around would be to use first pixel XY along with bounding rectangle to find the points.

0 Kudos
Message 5 of 11
(4,425 Views)

In the initial post i had an impression that it is single line hence my suggestion was to use Bounding Box.

-If there are multiple lines like in the latest, it doesn't work becasue particle analysis works on binary particle and here it is single particle since there is no disconnection hence it gives as single bounding box.

-You can try shape detection(grayscale not binary) for lines. Still the problem is in your image it would be 8 lines with edge detection.

-Could there be more lines in next posts? I'm out of ideas unless full problem is known 🙂

Thanks
uday
0 Kudos
Message 6 of 11
(4,405 Views)

Well actually, I think I was not clear enough. Pardon me.

I will always be having only a single line per image. What I wanted to show using the previous image is that- assume there are two images of same height and width and each image had one of the lines in them. In first image the line starts at top right corner and ends at bottom left corner(lets call this line 1). In second image the line starts at top left corner and ends at bottom right corner(lets call this line 2). Now when you apply particle analysis to each image, the bounding box of both these lines will be same if

1) Both the lines are of same length

2) The X coordinate of end point of line 1 is same as X coordinate of start point of line 2

3) The X coordinate of start point of line 1 is same as X coordinate of end point of line 2.

So in this case I cannot figure out whether the line starts at top right or top left.

This is a boundary condition that will fail if we use only bounding box. Now instead if I also compute the start pixel XY along with bounding box then it can be solved.

 

Regards

Aveo

 

0 Kudos
Message 7 of 11
(4,400 Views)
Did you check First Pixel X and First Pixel Y measurements?
Thanks
uday
0 Kudos
Message 8 of 11
(4,394 Views)

I was referring the first pixel XY as start pixel XY until now 😛

 

Regards

Aveo

0 Kudos
Message 9 of 11
(4,388 Views)

you can use this vi and serach for max and min inside the  image for colum and row 
 in this case you have 4 number that relate to end of the line x and y 
max min.png

Message 10 of 11
(4,367 Views)