Spaces:
Paused
Paused
GitHub Actions commited on
Commit ·
407c891
1
Parent(s): 3c84d3b
Deploy from GitHub commit 9ea40055df1444189c87e54a990237f41e397404
Browse files
app.py
CHANGED
|
@@ -832,8 +832,16 @@ def build_floor_surface_mask(
|
|
| 832 |
surface[occ_dilated > 0] = 0
|
| 833 |
surface[reject_dilated > 0] = 0
|
| 834 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 835 |
boundary_kern = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|
| 836 |
-
surface = cv2.
|
|
|
|
|
|
|
| 837 |
surface[occ_dilated > 0] = 0
|
| 838 |
surface[reject_dilated > 0] = 0
|
| 839 |
|
|
@@ -862,7 +870,10 @@ def build_confidence_map(surface_mask: np.ndarray) -> np.ndarray | None:
|
|
| 862 |
if not surface_mask.any():
|
| 863 |
return None
|
| 864 |
dist = cv2.distanceTransform(surface_mask.astype(np.uint8), cv2.DIST_L2, 5)
|
| 865 |
-
feather
|
|
|
|
|
|
|
|
|
|
| 866 |
confidence = np.clip(dist / feather, 0.0, 1.0)
|
| 867 |
return (confidence * 255).astype(np.uint8)
|
| 868 |
|
|
|
|
| 832 |
surface[occ_dilated > 0] = 0
|
| 833 |
surface[reject_dilated > 0] = 0
|
| 834 |
|
| 835 |
+
# Pull the outer boundary slightly INWARD instead of dilating it outward.
|
| 836 |
+
# The previous outward dilation grew the mask onto adjacent wall/baseboard/
|
| 837 |
+
# rug pixels that segmentation didn't reject; combined with the confidence
|
| 838 |
+
# feather those overshoot pixels turned semi-transparent and let the bright
|
| 839 |
+
# background bleed through as a white halo. Eroding keeps the tile just
|
| 840 |
+
# short of the true floor edge so the feather only ever blends tile->floor.
|
| 841 |
boundary_kern = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|
| 842 |
+
surface = cv2.erode(surface, boundary_kern, iterations=1)
|
| 843 |
+
# Hard-clamp to the segmented floor so the surface never tiles outside it.
|
| 844 |
+
surface[floor_mask == 0] = 0
|
| 845 |
surface[occ_dilated > 0] = 0
|
| 846 |
surface[reject_dilated > 0] = 0
|
| 847 |
|
|
|
|
| 870 |
if not surface_mask.any():
|
| 871 |
return None
|
| 872 |
dist = cv2.distanceTransform(surface_mask.astype(np.uint8), cv2.DIST_L2, 5)
|
| 873 |
+
# Narrow feather: a ~6px transition instead of ~26px. The wide feather made
|
| 874 |
+
# a thick translucent ring at every boundary, which is what let the bright
|
| 875 |
+
# background show through as a halo. Keep the blend confined to a thin edge.
|
| 876 |
+
feather = max(4.0, min(surface_mask.shape[:2]) / 200.0)
|
| 877 |
confidence = np.clip(dist / feather, 0.0, 1.0)
|
| 878 |
return (confidence * 255).astype(np.uint8)
|
| 879 |
|