MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / draw_polygon

Method draw_polygon

utils/visualizer.py:1126–1156  ·  view source on GitHub ↗

Args: segment: numpy array of shape Nx2, containing all the points in the polygon. color: color of the polygon. Refer to `matplotlib.colors` for a full list of formats that are accepted. edge_color: color of the polygon edges. Refer to `ma

(self, segment, color, edge_color=None, alpha=0.5)

Source from the content-addressed store, hash-verified

1124 return self.output
1125
1126 def draw_polygon(self, segment, color, edge_color=None, alpha=0.5):
1127 """
1128 Args:
1129 segment: numpy array of shape Nx2, containing all the points in the polygon.
1130 color: color of the polygon. Refer to `matplotlib.colors` for a full list of
1131 formats that are accepted.
1132 edge_color: color of the polygon edges. Refer to `matplotlib.colors` for a
1133 full list of formats that are accepted. If not provided, a darker shade
1134 of the polygon color will be used instead.
1135 alpha (float): blending efficient. Smaller values lead to more transparent masks.
1136
1137 Returns:
1138 output (VisImage): image object with polygon drawn.
1139 """
1140 if edge_color is None:
1141 # make edge color darker than the polygon color
1142 if alpha > 0.8:
1143 edge_color = self._change_color_brightness(color, brightness_factor=-0.7)
1144 else:
1145 edge_color = color
1146 edge_color = mplc.to_rgb(edge_color) + (1,)
1147
1148 polygon = mpl.patches.Polygon(
1149 segment,
1150 fill=True,
1151 facecolor=mplc.to_rgb(color) + (alpha,),
1152 edgecolor=edge_color,
1153 linewidth=max(self._default_font_size // 15 * self.output.scale, 1),
1154 )
1155 self.output.ax.add_patch(polygon)
1156 return self.output
1157
1158 """
1159 Internal methods:

Callers 2

overlay_instancesMethod · 0.95
draw_binary_maskMethod · 0.95

Calls 1

Tested by

no test coverage detected