Update app.py
Browse files
app.py
CHANGED
|
@@ -205,22 +205,16 @@ def remove_bg(fl, count, mh, ms, md, lm):
|
|
| 205 |
|
| 206 |
cv2.imwrite(fl, fr)
|
| 207 |
|
| 208 |
-
b = 15
|
| 209 |
-
element = cv2.getStructuringElement(cv2.
|
| 210 |
-
mask_e = cv2.erode(mask, element) * 255
|
| 211 |
-
mask_d = cv2.dilate(mask, element) * 127
|
| 212 |
-
mask_d[mask_e>0] = 255
|
| 213 |
-
cv2.imwrite(f"{str(count)}_trimask.png", mask_d.astype(np.uint8))
|
| 214 |
-
|
| 215 |
-
cutout(
|
| 216 |
-
# input image path
|
| 217 |
-
fl,
|
| 218 |
-
# input trimap path
|
| 219 |
-
f"{str(count)}_trimask.png",
|
| 220 |
-
# output cutout path
|
| 221 |
-
f"{str(count)}_cutout.png")
|
| 222 |
|
| 223 |
-
return f"{str(count)}_cutout.png"
|
| 224 |
else: # even: with the flash
|
| 225 |
fl_ = fl.split(".")[0] + "_.png"
|
| 226 |
cv2.imwrite(fl_, fr_diff.astype(np.uint8))
|
|
|
|
| 205 |
|
| 206 |
cv2.imwrite(fl, fr)
|
| 207 |
|
| 208 |
+
#b = 15
|
| 209 |
+
#element = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * b + 1, 2 * b + 1), (b, b))
|
| 210 |
+
#mask_e = cv2.erode(mask, element) * 255
|
| 211 |
+
#mask_d = cv2.dilate(mask, element) * 127
|
| 212 |
+
#mask_d[mask_e>0] = 255
|
| 213 |
+
#cv2.imwrite(f"{str(count)}_trimask.png", mask_d.astype(np.uint8))
|
| 214 |
+
|
| 215 |
+
#cutout(fl, f"{str(count)}_trimask.png", f"{str(count)}_cutout.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
+
return fl #f"{str(count)}_cutout.png"
|
| 218 |
else: # even: with the flash
|
| 219 |
fl_ = fl.split(".")[0] + "_.png"
|
| 220 |
cv2.imwrite(fl_, fr_diff.astype(np.uint8))
|