@@ -1915,10 +1915,10 @@ def _do_phasecong(tempIm, low_t=0, hi_t=0, norient=6, nscale=6, sigma=2):#, ske
19151915# hArray = orientIm[h]>=hT
19161916# return vArray, hArray
19171917
1918- def hough2line (inRas , outShp , edge = 'canny' , sigma = 2 , low_t = None ,
1919- hi_t = None , n_orient = 6 , n_scale = 5 , hArray = True , vArray = True ,
1918+ def hough2line (inRas , outShp , edge = 'canny' , sigma = 2 ,
1919+ thresh = None , ratio = 2 , n_orient = 6 , n_scale = 5 , hArray = True , vArray = True ,
19201920 prob = False , line_length = 100 ,
1921- line_gap = 200 , valrange = 1 , interval = 50 , band = 2 ,
1921+ line_gap = 200 , valrange = 1 , interval = 10 , band = 2 ,
19221922 min_area = None ):
19231923
19241924 """
@@ -2057,7 +2057,8 @@ def hough2line(inRas, outShp, edge='canny', sigma=2, low_t=None,
20572057
20582058
20592059
2060-
2060+ hi_t = thresh
2061+ low_t = np .round ((thresh / ratio ), decimals = 1 )
20612062
20622063 if edge == 'phase' :
20632064 ph = _do_phasecong (tempIm , low_t , hi_t , norient = n_orient ,
@@ -2198,7 +2199,8 @@ def cv_hough2line(inRas, outShp, edge='canny', sigma=2, low_t=0,
21982199
21992200
22002201 # This returns an array of r and theta values
2201- lines1 = cv2 .HoughLines (np .uint8 (edges ),1 , np .pi / increment , thresh , min_theta = angles .min ()- np .deg2rad (bounds ),
2202+ lines1 = cv2 .HoughLines (np .uint8 (edges ),1 , np .pi / increment , thresh ,
2203+ min_theta = angles .min ()- np .deg2rad (bounds ),
22022204 max_theta = angles .min ()+ np .deg2rad (bounds ))
22032205
22042206
@@ -2225,23 +2227,24 @@ def cv_hough2line(inRas, outShp, edge='canny', sigma=2, low_t=0,
22252227 y0 = b * r
22262228
22272229 # x1 stores the rounded off value of (rcos(theta)-1000sin(theta))
2228- x1 = int (x0 + 1000 * (- b ))
2230+ x1 = int (x0 + img . shape [ 1 ] * (- b ))
22292231
22302232 # y1 stores the rounded off value of (rsin(theta)+1000cos(theta))
2231- y1 = int (y0 + 1000 * (a ))
2233+ y1 = int (y0 + img . shape [ 0 ] * (a ))
22322234
22332235 # x2 stores the rounded off value of (rcos(theta)+1000sin(theta))
2234- x2 = int (x0 - 1000 * (- b ))
2236+ x2 = int (x0 - img . shape [ 0 ] * (- b ))
22352237
22362238 # y2 stores the rounded off value of (rsin(theta)-1000cos(theta))
2237- y2 = int (y0 - 1000 * (a ))
2239+ y2 = int (y0 - img . shape [ 0 ] * (a ))
22382240
22392241 # cv2.line draws a line in img from the point(x1,y1) to (x2,y2).
22402242 # (0,0,255) denotes the colour of the line to be
22412243 #drawn. In this case, it is red.
22422244 cv2 .line (img ,(x1 ,y1 ), (x2 ,y2 ), (0 ,0 ,255 ),1 )
22432245
2244- lines2 = cv2 .HoughLines (np .uint8 (edges ),1 , np .pi / increment , thresh , min_theta = angles .max ()- np .deg2rad (bounds ),
2246+ lines2 = cv2 .HoughLines (np .uint8 (edges ),1 , np .pi / increment , thresh ,
2247+ min_theta = angles .max ()- np .deg2rad (bounds ),
22452248 max_theta = angles .max ()+ np .deg2rad (bounds ))
22462249 for l in tqdm (lines2 ):
22472250
@@ -2264,16 +2267,20 @@ def cv_hough2line(inRas, outShp, edge='canny', sigma=2, low_t=0,
22642267 y0 = b * r
22652268
22662269 # x1 stores the rounded off value of (rcos(theta)-1000sin(theta))
2267- x1 = int (x0 + 1000 * (- b ))
2270+
2271+
2272+
2273+
2274+ x1 = int (x0 + img .shape [1 ]* (- b ))
22682275
22692276 # y1 stores the rounded off value of (rsin(theta)+1000cos(theta))
2270- y1 = int (y0 + 1000 * (a ))
2277+ y1 = int (y0 + img . shape [ 0 ] * (a ))
22712278
22722279 # x2 stores the rounded off value of (rcos(theta)+1000sin(theta))
2273- x2 = int (x0 - 1000 * (- b ))
2280+ x2 = int (x0 - img . shape [ 1 ] * (- b ))
22742281
22752282 # y2 stores the rounded off value of (rsin(theta)-1000cos(theta))
2276- y2 = int (y0 - 1000 * (a ))
2283+ y2 = int (y0 - img . shape [ 0 ] * (a ))
22772284
22782285 # cv2.line draws a line in img from the point(x1,y1) to (x2,y2).
22792286 # (0,0,255) denotes the colour of the line to be
0 commit comments