Update app.py
Browse files
app.py
CHANGED
|
@@ -31,13 +31,21 @@ def inpaint_background(image, mask):
|
|
| 31 |
# Ensure the mask is binary (0 and 255)
|
| 32 |
mask_binary = (mask * 255).astype(np.uint8)
|
| 33 |
|
| 34 |
-
# Resize the mask to match the
|
| 35 |
mask_binary_resized = cv2.resize(mask_binary, (image.shape[1], image.shape[0]), interpolation=cv2.INTER_NEAREST)
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Inpaint the image using the resized mask
|
| 38 |
inpainted_image = cv2.inpaint(image.astype(np.uint8), mask_binary_resized, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
|
| 39 |
|
| 40 |
return inpainted_image
|
|
|
|
| 41 |
# Normalization function
|
| 42 |
def normalize_depth_image(depth_image):
|
| 43 |
# Ensure depth_image is of type float32
|
|
|
|
| 31 |
# Ensure the mask is binary (0 and 255)
|
| 32 |
mask_binary = (mask * 255).astype(np.uint8)
|
| 33 |
|
| 34 |
+
# Resize the mask to match the dimensions of the image
|
| 35 |
mask_binary_resized = cv2.resize(mask_binary, (image.shape[1], image.shape[0]), interpolation=cv2.INTER_NEAREST)
|
| 36 |
+
|
| 37 |
+
# Debugging: Check dimensions
|
| 38 |
+
print(f"Image shape: {image.shape}")
|
| 39 |
+
print(f"Mask shape: {mask_binary_resized.shape}")
|
| 40 |
+
|
| 41 |
+
# Assert that the dimensions match
|
| 42 |
+
assert image.shape[:2] == mask_binary_resized.shape[:2], "Image and mask dimensions do not match!"
|
| 43 |
+
|
| 44 |
# Inpaint the image using the resized mask
|
| 45 |
inpainted_image = cv2.inpaint(image.astype(np.uint8), mask_binary_resized, inpaintRadius=3, flags=cv2.INPAINT_TELEA)
|
| 46 |
|
| 47 |
return inpainted_image
|
| 48 |
+
|
| 49 |
# Normalization function
|
| 50 |
def normalize_depth_image(depth_image):
|
| 51 |
# Ensure depth_image is of type float32
|