Update app.py
Browse files
app.py
CHANGED
|
@@ -35,8 +35,12 @@ def segment_and_count(image):
|
|
| 35 |
cell_count = len(np.unique(masks)) - 1 # subtract 1 for background
|
| 36 |
|
| 37 |
# Overlay mask for display
|
|
|
|
| 38 |
overlay = image_np.copy()
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
# Convert result to PIL Image for output
|
| 42 |
overlay_image = Image.fromarray(overlay)
|
|
|
|
| 35 |
cell_count = len(np.unique(masks)) - 1 # subtract 1 for background
|
| 36 |
|
| 37 |
# Overlay mask for display
|
| 38 |
+
|
| 39 |
overlay = image_np.copy()
|
| 40 |
+
alpha = 0.3 # Transparency factor (0.0 - 1.0, where 1.0 is fully opaque)
|
| 41 |
+
|
| 42 |
+
# Blend the red color with the original image where mask > 0
|
| 43 |
+
overlay[masks > 0] = (1 - alpha) * overlay[masks > 0] + alpha * np.array([255, 0, 0])
|
| 44 |
|
| 45 |
# Convert result to PIL Image for output
|
| 46 |
overlay_image = Image.fromarray(overlay)
|