Skip to content

Commit 4d293b7

Browse files
committed
update cleanup
1 parent 99723d3 commit 4d293b7

File tree

5 files changed

+57
-998
lines changed

5 files changed

+57
-998
lines changed

geospatial_learn/handyplots.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import numpy as np
1919

20-
import matplotlib.pyplot as plt
20+
2121

2222
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix,jaccard_score, f1_score
2323
from sklearn.metrics import precision_recall_fscore_support as prf
@@ -26,9 +26,9 @@
2626
import seaborn as sns
2727

2828
import pandas as pd
29-
29+
import matplotlib.pyplot as plt
3030
def plot_classif_report(trueVals, predVals, labels=None, target_names=None,
31-
colmap=plt.cm.Spectral_r):
31+
colmap=plt.cm.Spectral_r, save=None):
3232

3333
"""
3434
Plot a classification report
@@ -52,10 +52,33 @@ def plot_classif_report(trueVals, predVals, labels=None, target_names=None,
5252

5353
clf_report = classification_report(trueVals, predVals, labels=labels,
5454
target_names=target_names, output_dict=True)
55-
55+
5656
dF = pd.DataFrame(clf_report).iloc[:-1, :].T
57+
58+
cbVl = dF.values
59+
mn = np.round(cbVl.min(), decimals=2)
60+
mx= np.round(cbVl.max(), decimals=2)
61+
del cbVl
62+
63+
64+
65+
f, ax = plt.subplots(figsize=(10, 10))
66+
67+
splot = sns.heatmap(dF, annot=True, linewidths=.5, fmt='.2f', cmap=colmap,
68+
ax=ax, vmin=mn,
69+
vmax=mx, annot_kws={"size": 20})
70+
71+
cbar = ax.collections[0].colorbar
72+
cbar.set_ticks([mn, mx])
73+
cbar.set_ticklabels([str(mn), str(mx)])
74+
75+
5776

58-
sns.heatmap(dF, annot=True, cmap=colmap)
77+
78+
if save != None:
79+
80+
fig = splot.get_figure()
81+
fig.savefig(save)
5982

6083
return dF
6184

geospatial_learn/setup.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

geospatial_learn/shape.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)