zhiweili commited on
Commit
b988a20
1 Parent(s): 84b8fcc

blend gray image

Browse files
Files changed (1) hide show
  1. segment_utils.py +3 -1
segment_utils.py CHANGED
@@ -116,7 +116,9 @@ def segment_image_with_color(input_image, color, alpha, category, input_size, ma
116
  cv2_target_hsv[..., 1] = targetHsv[1]
117
 
118
  cv2_target_bgr = cv2.cvtColor(cv2_target_hsv, cv2.COLOR_HSV2BGR)
119
- cv2_image_w = cv2.addWeighted(cv2_target_bgr, alpha, cv2_image, 1 - alpha, 0)
 
 
120
  cv2_image[target_mask] = cv2_image_w[target_mask]
121
 
122
  input_image = Image.fromarray(cv2.cvtColor(cv2_image, cv2.COLOR_BGR2RGB))
 
116
  cv2_target_hsv[..., 1] = targetHsv[1]
117
 
118
  cv2_target_bgr = cv2.cvtColor(cv2_target_hsv, cv2.COLOR_HSV2BGR)
119
+ gray_image = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2GRAY)
120
+ gray_image_3d = cv2.merge([gray_image] * 3)
121
+ cv2_image_w = cv2.addWeighted(cv2_target_bgr, alpha, gray_image_3d, 1 - alpha, 0)
122
  cv2_image[target_mask] = cv2_image_w[target_mask]
123
 
124
  input_image = Image.fromarray(cv2.cvtColor(cv2_image, cv2.COLOR_BGR2RGB))