freealise commited on
Commit
71f861a
1 Parent(s): 63f6d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -387,9 +387,10 @@ def apply_mask(d, b):
387
  global frame_selected
388
  global masks
389
 
 
390
  dilation = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
391
- d["layers"][0] = cv2.dilate(d["layers"][0], dilation)
392
- d["background"][d["layers"][0]==(255,255,255,255)] = (255,255,255,255)
393
 
394
  masks[frame_selected] = d["background"]
395
  cv2.imwrite(f"f{frame_selected}_dmap.png", masks[frame_selected])
 
387
  global frame_selected
388
  global masks
389
 
390
+ mask = cv2.cvtColor(d["layers"][0], cv2.COLOR_RGBA2GRAY)
391
  dilation = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
392
+ mask = cv2.dilate(mask, dilation)
393
+ d["background"][mask==255] = (255,255,255,255)
394
 
395
  masks[frame_selected] = d["background"]
396
  cv2.imwrite(f"f{frame_selected}_dmap.png", masks[frame_selected])