Update app.py
Browse files
app.py
CHANGED
@@ -51,11 +51,13 @@ def process_image(image: Image.Image):
|
|
51 |
|
52 |
# 5) vectorized depth-based blur
|
53 |
img_np = np.array(image).astype(np.float32)
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
59 |
lens_blur = Image.fromarray(np.clip(combined,0,255).astype(np.uint8))
|
60 |
|
61 |
return image, output_blur, lens_blur
|
|
|
51 |
|
52 |
# 5) vectorized depth-based blur
|
53 |
img_np = np.array(image).astype(np.float32)
|
54 |
+
near_blur = img_np
|
55 |
+
far_blur = cv2.GaussianBlur(img_np, (81,81), 20)
|
56 |
+
|
57 |
+
# high=foreground, low=background
|
58 |
+
alpha = depth_norm[...,None]
|
59 |
+
combined = near_blur * alpha + far_blur * (1.0 - alpha)
|
60 |
+
|
61 |
lens_blur = Image.fromarray(np.clip(combined,0,255).astype(np.uint8))
|
62 |
|
63 |
return image, output_blur, lens_blur
|