I am trying to pick straight lines out of a photographic image to track deflections of a structure under loading.
The idea is to mark certain structural elements with straight lines, as they deflect I can then extract the vectors from the image, find the centre point and measure how much the vector has displaced and rotated since the previous image.
I have used the second answer to this question to get the bones of a process up and running, code below. Using a generic vector image from web as a test image until my rig is up and running.
i = ColorNegate@Import["http://goo.gl/5R4MAl"]
p = Closing[Binarize@ImageTake[i, 480], 1];
Show[p, Graphics[{Thick, Orange, Line /@ ImageLines[p, Segmented -> True]}]]
This seems to pick out the main vectors quite nicely.
Whilst the length of results returned is 9 which is what I expected, on closer inspection there are additional points that are very close together. I'm guessing that these are rogue parts of the arrowheads being picked up.
foo = ImageLines[p, Segmented -> True]
foo // Length
Gives the length to be 9, which is what I would have expected given there are nine primary lines, but if displayed in matrixform I'm getting additional rogue points.
foo // MatrixForm
I've tried to tinker about with limiting the MaxFeatures->9 and using DeleteSmallComponents with mixed success. I'm struggling to find any helpful guidance too on what t (threshold) and d (distinctness) actually do with regards the image recognition.
What methods exist to extract the primary straight lines from images like the one used in the above example that gives a start and and end co-ordinate of the line that can then be used in subsequent calculations please? I'd also prefer to not set the number of lines I'm expecting Mathematica to discover.