Fix smooth edges
Browse files
app.py
CHANGED
|
@@ -226,12 +226,12 @@ def smooth_edges(mask):
|
|
| 226 |
|
| 227 |
# Resize the image to a smaller size, then back to the original size
|
| 228 |
small_size = (pil_mask.width // 2, pil_mask.height // 2)
|
| 229 |
-
pil_mask_small = pil_mask.resize(small_size, Image.
|
| 230 |
-
pil_mask_smooth = pil_mask_small.resize(pil_mask.size, Image.
|
| 231 |
|
| 232 |
# Convert back to a numpy array
|
| 233 |
smoothed_mask = np.array(pil_mask_smooth)
|
| 234 |
-
final_mask = cv2.bilateralFilter(
|
| 235 |
|
| 236 |
return final_mask
|
| 237 |
|
|
|
|
| 226 |
|
| 227 |
# Resize the image to a smaller size, then back to the original size
|
| 228 |
small_size = (pil_mask.width // 2, pil_mask.height // 2)
|
| 229 |
+
pil_mask_small = pil_mask.resize(small_size, Image.Resampling.LANCZOS)
|
| 230 |
+
pil_mask_smooth = pil_mask_small.resize(pil_mask.size, Image.Resampling.LANCZOS)
|
| 231 |
|
| 232 |
# Convert back to a numpy array
|
| 233 |
smoothed_mask = np.array(pil_mask_smooth)
|
| 234 |
+
final_mask = cv2.bilateralFilter(smoothed_mask, d=9, sigmaColor=75, sigmaSpace=75)
|
| 235 |
|
| 236 |
return final_mask
|
| 237 |
|