Open
Description
Hi,
thanks for your interest!
You can refer to the code below for visual analysis.
def plot_seg_result(img, mask, type=None, size=500, alpha=0.5, anns='mask'):
assert type in ['red', 'blue', 'yellow']
if type == 'red':
color = (255, 50, 50) # red (255, 50, 50) (255, 90, 90) (252, 60, 60)
elif type == 'blue':
color = (90, 90, 218) # blue (102, 140, 255) (90, 90, 218) (90, 154, 218)
elif type == 'yellow':
color = (255, 218, 90) # yellow
color_scribble = (255, 218, 90) # (255, 218, 90) (0, 0, 255)
img_pre = img.copy()
if anns == 'mask':
for c in range(3):
img_pre[:, :, c] = np.where(mask[:,:,0] == 1,
img[:, :, c] * (1 - alpha) + alpha * color[c],
img[:, :, c])
elif anns == 'scribble':
mask[mask==255]=0
mask = mask[:,:,0]
dilated_size = 5
Scribble_Expert = ScribblesRobot()
scribble_mask = Scribble_Expert.generate_scribbles(mask)
scribble_mask = ndimage.maximum_filter(scribble_mask, size=dilated_size) #
for c in range(3):
img_pre[:, :, c] = np.where(scribble_mask == 1,
color_scribble[c],
img[:, :, c])
elif anns == 'bbox':
mask[mask==255]=0
mask = mask[:,:,0]
bboxs = find_bbox(mask)
for j in bboxs:
cv2.rectangle(img_pre, (j[0], j[1]), (j[0] + j[2], j[1] + j[3]), (255, 0, 0), 4) # -1->fill; 2->draw_rec
img_pre = cv2.cvtColor(img_pre, cv2.COLOR_RGB2BGR)
if size is not None:
img_pre = cv2.resize(img_pre, dsize=(size, size), interpolation=cv2.INTER_LINEAR)
return img_pre
Originally posted by @chunbolang in #13 (comment)
Metadata
Assignees
Labels
No labels