Update app.py
Browse files
app.py
CHANGED
@@ -51,12 +51,17 @@ def process_image(image: Image.Image):
|
|
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 =
|
60 |
|
61 |
lens_blur = Image.fromarray(np.clip(combined,0,255).astype(np.uint8))
|
62 |
|
|
|
51 |
|
52 |
# 5) vectorized depth-based blur
|
53 |
img_np = np.array(image).astype(np.float32)
|
54 |
+
|
55 |
+
# apply an Unsharp Mask to sharpen the whole image
|
56 |
+
sharp = image.filter(ImageFilter.UnsharpMask(radius=2, percent=150, threshold=3))
|
57 |
+
sharp_np = np.array(sharp).astype(np.float32)
|
58 |
+
|
59 |
near_blur = img_np
|
60 |
far_blur = cv2.GaussianBlur(img_np, (81,81), 20)
|
61 |
|
62 |
# high=foreground, low=background
|
63 |
alpha = depth_norm[...,None]
|
64 |
+
combined = sharp_np * alpha + far_blur * (1.0 - alpha)
|
65 |
|
66 |
lens_blur = Image.fromarray(np.clip(combined,0,255).astype(np.uint8))
|
67 |
|