Siromanec commited on
Commit
0d51758
1 Parent(s): dcd3aa9

included flashing

Browse files
Files changed (1) hide show
  1. handcrafted_solution.py +2 -28
handcrafted_solution.py CHANGED
@@ -58,8 +58,8 @@ def get_vertices(image_gestalt, *, color_range=4., dialations=3, erosions=1, ker
58
 
59
  apex_mask = cv2.inRange(image_gestalt, apex_color - color_range, apex_color + color_range)
60
  eave_end_point_mask = cv2.inRange(image_gestalt, eave_end_point - color_range, eave_end_point + color_range)
61
- # flashing_end_point_mask = cv2.inRange(image_gestalt, flashing_end_point - color_range, flashing_end_point + color_range)
62
- # eave_end_point_mask = cv2.bitwise_or(eave_end_point_mask, flashing_end_point_mask)
63
 
64
  kernel = np.ones((kernel_size, kernel_size), np.uint8)
65
 
@@ -96,36 +96,10 @@ def convert_entry_to_human_readable(entry):
96
 
97
  def get_vertices_and_edges_from_segmentation(gest_seg_np, edge_th = 50.0):
98
  '''Get the vertices and edges from the gestalt segmentation mask of the house'''
99
- vertices = []
100
  connections = []
101
  # Apex
102
  gest_seg_np = clean_image(gest_seg_np)
103
  apex_centroids, eave_end_point_centroids = get_vertices(gest_seg_np)
104
- # apex_color = np.array(gestalt_color_mapping['apex'])
105
- # apex_mask = cv2.inRange(gest_seg_np, apex_color-0.5, apex_color+0.5)
106
- # if apex_mask.sum() > 0:
107
- # output = cv2.connectedComponentsWithStats(apex_mask, 8, cv2.CV_32S)
108
- # (numLabels, labels, stats, centroids) = output
109
- # stats, centroids = stats[1:], centroids[1:]
110
- #
111
- # for i in range(numLabels-1):
112
- # vert = {"xy": centroids[i], "type": "apex"}
113
- # vertices.append(vert)
114
- #
115
- # eave_end_color = np.array(gestalt_color_mapping['eave_end_point'])
116
- # eave_end_mask = cv2.inRange(gest_seg_np, eave_end_color-0.5, eave_end_color+0.5)
117
- # if eave_end_mask.sum() > 0:
118
- # output = cv2.connectedComponentsWithStats(eave_end_mask, 8, cv2.CV_32S)
119
- # (numLabels, labels, stats, centroids) = output
120
- # stats, centroids = stats[1:], centroids[1:]
121
- #
122
- # for i in range(numLabels-1):
123
- # vert = {"xy": centroids[i], "type": "eave_end_point"}
124
- # vertices.append(vert)
125
- # Connectivity
126
- # apex_pts = []
127
- # for j, v in enumerate(vertices):
128
- # apex_pts.append(v['xy'])
129
  apex_pts = np.concatenate([apex_centroids, eave_end_point_centroids])
130
 
131
  # Ridge connects two apex points
 
58
 
59
  apex_mask = cv2.inRange(image_gestalt, apex_color - color_range, apex_color + color_range)
60
  eave_end_point_mask = cv2.inRange(image_gestalt, eave_end_point - color_range, eave_end_point + color_range)
61
+ flashing_end_point_mask = cv2.inRange(image_gestalt, flashing_end_point - color_range, flashing_end_point + color_range)
62
+ eave_end_point_mask = cv2.bitwise_or(eave_end_point_mask, flashing_end_point_mask)
63
 
64
  kernel = np.ones((kernel_size, kernel_size), np.uint8)
65
 
 
96
 
97
  def get_vertices_and_edges_from_segmentation(gest_seg_np, edge_th = 50.0):
98
  '''Get the vertices and edges from the gestalt segmentation mask of the house'''
 
99
  connections = []
100
  # Apex
101
  gest_seg_np = clean_image(gest_seg_np)
102
  apex_centroids, eave_end_point_centroids = get_vertices(gest_seg_np)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  apex_pts = np.concatenate([apex_centroids, eave_end_point_centroids])
104
 
105
  # Ridge connects two apex points