Sagar Bharadwaj commited on
Commit
a8828c1
·
1 Parent(s): 8cc93d2

Center aligning numbers

Browse files
colorbynumber/gen_islands.py CHANGED
@@ -85,7 +85,12 @@ class GenerateIslands:
85
  for cntr_id, contour in enumerate(contours):
86
  area_fraction_perc = (cv.contourArea(contour) / total_area) * 100
87
  if area_fraction_perc >= area_perc_threshold:
88
- cv.drawContours(contours_image, contours, cntr_id, (0,255,0), 1)
 
 
 
 
 
89
  contours_selected.append(contour)
90
  hierarchy_selected.append(hierarchy[0][cntr_id])
91
 
 
85
  for cntr_id, contour in enumerate(contours):
86
  area_fraction_perc = (cv.contourArea(contour) / total_area) * 100
87
  if area_fraction_perc >= area_perc_threshold:
88
+ cv.drawContours(
89
+ image = contours_image,
90
+ contours = [contour],
91
+ contourIdx = 0,
92
+ color = (0,255,0),
93
+ thickness = 1)
94
  contours_selected.append(contour)
95
  hierarchy_selected.append(hierarchy[0][cntr_id])
96
 
colorbynumber/numbered_islands.py CHANGED
@@ -23,6 +23,8 @@ def _add_text_to_image(image, text, position, font_size, font_color, font_thickn
23
  np.array: A new image with the text added.
24
  """
25
  font = cv2.FONT_HERSHEY_SIMPLEX
 
 
26
  return cv2.putText(
27
  image,
28
  text,
 
23
  np.array: A new image with the text added.
24
  """
25
  font = cv2.FONT_HERSHEY_SIMPLEX
26
+ text_size, _ = cv2.getTextSize(text, font, font_size, 1)
27
+ position = (position[0] - text_size[0]//2, position[1] + text_size[1]//2)
28
  return cv2.putText(
29
  image,
30
  text,