For below image, how to get the edge lines length and draw the fitting line of them. Any advice will be appreciated. Thanks.
Asked
Active
Viewed 428 times
1
-
This will be difficult because of the overlaps. Even on the (presumably) hand-drawn segments, it is unclear where they end. You must give a precise rule. – Feb 08 '17 at 10:14
-
Advising a good solution is not possible without more context on the possible configurations. Otherwise, the standard but poor answer is "Hough transform". – Feb 08 '17 at 10:16
-
If you want, we can discuss this privately, check my profile. – Feb 08 '17 at 10:31
-
Hi Daoust. Thanks a lot for your answer. OK. I will contact you. – QH. Zhu Feb 13 '17 at 09:28
-
any update on this solution. I am eager to know – Jeru Luke Feb 21 '17 at 17:39
1 Answers
1
Probably, i'm bit late, but anyway. Here is my solution to that problem. It is not very accurate, but it works. To reach better accuracy you need more than one image. Code for HDevelop:
read_image (Image, 'D:/exp/test/1')
access_channel (Image, Image1, 1)
*find vertical lines
derivate_gauss (Image1, DerivGauss2, 1, 'x')
threshold (DerivGauss2, Region1, -255, -2)
connection (Region1, ConnectedRegions1)
*filter out redundant features
select_shape (ConnectedRegions1, SelectedRegions, ['rect2_len1','rectangularity'], 'and', [100,0.5], [99999,1])
*select rightmost edge
*this would be our reference line
area_center (SelectedRegions, Area, Row, Column)
tuple_sort_index (Column, Indices)
select_obj (SelectedRegions, ObjectSelected, Indices[|Indices|-1]+1)
skeleton (ObjectSelected, Skeleton)
smallest_rectangle2 (Skeleton, Row1, Column1, Phi, Length1, Length2)
*hide right side of the image based on that edge
Shift:=200
Row1Shift:=Row1-(cos(Phi)*Shift)
Column1Shift:=Column1-(sin(Phi)*Shift)
gen_rectangle2 (Rectangle, Row1Shift, Column1Shift, Phi, 999, 200)
complement (Rectangle, InspectionArea)
*find horizontal lines
derivate_gauss (Image1, DerivGauss, 1, 'y')
threshold (DerivGauss, Region, 5, 255)
*find shifted edges
intersection (Region, InspectionArea, RegionIntersection)
connection (RegionIntersection, ConnectedRegions)
*filter out redundant features
select_shape (ConnectedRegions, SelectedRegions1, ['inner_radius','rectangularity'], 'and', [2,0.5], [99999,1])
*print length
smallest_rectangle2 (SelectedRegions1, Row2, Column2, Phi1, Length11, Length21)
Row2Shift:=Row2+(sin(Phi)*Length11)
Column2Shift:=Column2+(cos(Phi)*Length11)
count_obj (SelectedRegions1, Number)
tuple_gen_sequence (0, (Number-1)*20, 20, Sequence)
dev_disp_text (Length11, 'window', Sequence, 0, 'black', [], [])
dev_set_color ('red')
skeleton (SelectedRegions1, Skeleton1)
dev_display(Skeleton1)
The result:

MeelStorm
- 624
- 6
- 11