freealise commited on
Commit
3f9b3cb
1 Parent(s): 1c34e60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -474,8 +474,10 @@ def apply_mask(d, b):
474
  edge = []
475
  mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
476
  mask[mask<255] = 0
 
477
  dilation = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
478
  mask = cv2.dilate(mask, dilation)
 
479
  b = b*2+1
480
  dilation = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
481
  dmask = cv2.dilate(mask, dilation)
@@ -494,7 +496,7 @@ def apply_mask(d, b):
494
  cv2.imwrite(frames[k], frame)
495
 
496
  frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
497
- frame[:, :, 3] = 255 - dmask_b
498
  cv2.imwrite(frames[frame_selected], frame)
499
 
500
  masks[frame_selected] = d["background"]
 
474
  edge = []
475
  mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
476
  mask[mask<255] = 0
477
+ b = b*2+1
478
  dilation = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
479
  mask = cv2.dilate(mask, dilation)
480
+ mask_b = cv2.GaussianBlur(mask, (b,b), 0)
481
  b = b*2+1
482
  dilation = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
483
  dmask = cv2.dilate(mask, dilation)
 
496
  cv2.imwrite(frames[k], frame)
497
 
498
  frame = cv2.imread(frames[frame_selected], cv2.IMREAD_UNCHANGED).astype(np.uint8)
499
+ frame[:, :, 3] = 255 - mask_b
500
  cv2.imwrite(frames[frame_selected], frame)
501
 
502
  masks[frame_selected] = d["background"]