Reputation: 3
I'm trying to generate grid line segments by grid points.I have 34 points like this:
The picture size is 720*480 with 34 grid points and the coordinates are here:
323.708 205.925
382.585 206.75
320.296 216.596
381.729 217.499
271.118 227.4
286.04 227.643
301.208 227.631
316.538 228.165
332.195 228.323
348.114 228.828
364.194 229.139
380.893 229.356
397.731 230.219
414.795 230.634
432.307 231.407
312.507 241.026
379.886 242.892
307.735 254.944
378.838 257.705
251.514 268.437
268.271 269.035
285.124 269.701
302.801 270.563
320.684 271.637
339.107 272.332
358.067 273.122
377.46 274.347
397.01 275.033
416.814 276.199
437.558 277.354
297.437 288.028
375.766 292.266
291.296 307.268
374.233 313.316
I have tried the Hough Transform to detect grid lines. But I just need a picture that the gaps between points were filled (like this):
so that I could do the next work. Using Hough Transform is a little bit wasted.
I have tried to use linear interpolation to fill the gap,but I need to find endpoints manually. Therefore,I want to know how to generate the grid line segments just by these grid points automatically.
Upvotes: 0
Views: 362
Reputation: 51845
for each point find closest point in N,S,E,W
directions and add line to a list if not already present in the list. If n
is number of points I see it like:
i = <0,n-2>
j = <i+1,n-1>
for each axis direction
add any line that has size |pnt[i1]-pnt[i1]|
less or equal then grid size and at the same time direction of the line is similar to actual direction NS
or WE
so:
abs(dot(direction/|direction|,(pnt[i1]-pnt[i1])/|pnt[i1]-pnt[i1]|))
is close to 1
or at least bigger then 0.75
if the direction vectors are not exact. As directions you can start with:
NS = ( 0.0, 1.0 )
WE = ( 1.0. 0.0 )
The NS direction is more deviated so you probably should use bigger margin for comparison for them.
You can get rid of the normalizations inside dot product for unit vectors
Upvotes: 1
Reputation: 80197
You already know important points, so Hough transform is quite overhead.
If there are only 34 (or even hundreds) points, they form about 1000 pairs, and you can build line for every pair, then cluster these lines in rho-theta space without any complex algorithms (this approach is quadratic). You'll have got 4 big clusters, and it not hard to find what line segments (points) from these clusters are ending ones.
For larger datasets you can form initial clusters in a random manner for small random point subset, then add every point to the best line it fits (linear approach)
Upvotes: 0