YongchengYAO commited on
Commit
9d3bfcb
·
1 Parent(s): 87a5738

[src] chore: pass line and point color to add_landmarks_and_line_overlay()

Browse files
src/medvision_ds/utils/doc_to_visual_utils.py CHANGED
@@ -26,7 +26,7 @@ def _get_text_dimensions(draw, text, font):
26
  return width, height
27
 
28
 
29
- def add_landmarks_and_line_overlay(pil_img, p1_coords, p2_coords):
30
  """
31
  Add landmarks (points) and a line connecting them to an image.
32
 
@@ -47,7 +47,7 @@ def add_landmarks_and_line_overlay(pil_img, p1_coords, p2_coords):
47
  x2, y2 = p2_coords[1], p2_coords[0]
48
 
49
  # Draw the line connecting the points (green)
50
- draw.line([(x1, y1), (x2, y2)], fill="#00FF00", width=2)
51
 
52
  # Draw the points (red)
53
  point_radius = 3
@@ -56,14 +56,14 @@ def add_landmarks_and_line_overlay(pil_img, p1_coords, p2_coords):
56
  (x1 - point_radius, y1 - point_radius),
57
  (x1 + point_radius, y1 + point_radius),
58
  ],
59
- fill="#FF0000",
60
  )
61
  draw.ellipse(
62
  [
63
  (x2 - point_radius, y2 - point_radius),
64
  (x2 + point_radius, y2 + point_radius),
65
  ],
66
- fill="#FF0000",
67
  )
68
 
69
  return pil_img
 
26
  return width, height
27
 
28
 
29
+ def add_landmarks_and_line_overlay(pil_img, p1_coords, p2_coords, line_color="#00FF00", point_color="#FF0000"):
30
  """
31
  Add landmarks (points) and a line connecting them to an image.
32
 
 
47
  x2, y2 = p2_coords[1], p2_coords[0]
48
 
49
  # Draw the line connecting the points (green)
50
+ draw.line([(x1, y1), (x2, y2)], fill=line_color, width=2)
51
 
52
  # Draw the points (red)
53
  point_radius = 3
 
56
  (x1 - point_radius, y1 - point_radius),
57
  (x1 + point_radius, y1 + point_radius),
58
  ],
59
+ fill=point_color,
60
  )
61
  draw.ellipse(
62
  [
63
  (x2 - point_radius, y2 - point_radius),
64
  (x2 + point_radius, y2 + point_radius),
65
  ],
66
+ fill=point_color,
67
  )
68
 
69
  return pil_img