Skip to content

Commit ac32cb3

Browse files
committed
yp
1 parent 3433fe4 commit ac32cb3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

geospatial_learn/utilities.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,47 @@ def temp_match(vector_path, raster_path, band, nodata_value=0, ind=None):
10171017

10181018
return outList
10191019

1020+
def imangle(im):
1021+
1022+
"""
1023+
Determine the orientation of non-zero vals in an image
1024+
----------
1025+
1026+
im : np array
1027+
input image
1028+
Returns
1029+
-------
1030+
1031+
axes : tuple
1032+
orientations of each side and binary array
1033+
1034+
"""
1035+
1036+
# if the the binary box is pointing negatively along maj axis
1037+
bw = im > 0
1038+
props = regionprops(bw*1)
1039+
orient = props[0]['Orientation']
1040+
1041+
# we will need these.....
1042+
perim = mh.bwperim(bw)
1043+
# bkgrnd = invert(bw)
1044+
1045+
1046+
bw[perim==1]=0
1047+
if orient < 0:
1048+
orient += np.pi
1049+
1050+
if orient < np.pi:
1051+
axis1 = np.pi - orient
1052+
axis2 = axis1 - np.deg2rad(90)
1053+
else:
1054+
# if the the binary box is pointing positively along maj axis
1055+
axis1 = np.pi + orient
1056+
axis2 = axis1 + np.deg2rad(90)
1057+
1058+
return (axis1, axis2, bw)
1059+
1060+
10201061
def test_gabor(im, size=9, freq=0.1, angle=None, funct='cos', plot=True,
10211062
smooth=True, interp='none'):
10221063
"""

0 commit comments

Comments
 (0)