Spaces:
Sleeping
Sleeping
Update shadow_map.py
Browse files- shadow_map.py +4 -3
shadow_map.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
-
import cv2
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
import tempfile
|
| 4 |
|
| 5 |
def analyze_uv_exposure(image_path):
|
| 6 |
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
| 7 |
-
blur = cv2.GaussianBlur(img, (11,11), 0)
|
| 8 |
_, mask = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
|
| 9 |
coverage = np.count_nonzero(mask) / mask.size * 100
|
| 10 |
|
|
@@ -15,7 +16,7 @@ def analyze_uv_exposure(image_path):
|
|
| 15 |
if mask[y, x] == 0:
|
| 16 |
pixels[x, y] = (255, 0, 0, 125)
|
| 17 |
|
| 18 |
-
# Save
|
| 19 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
| 20 |
overlay.save(temp_file.name)
|
| 21 |
annotated_path = temp_file.name
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
from PIL import Image
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
def analyze_uv_exposure(image_path):
|
| 7 |
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
| 8 |
+
blur = cv2.GaussianBlur(img, (11, 11), 0)
|
| 9 |
_, mask = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
|
| 10 |
coverage = np.count_nonzero(mask) / mask.size * 100
|
| 11 |
|
|
|
|
| 16 |
if mask[y, x] == 0:
|
| 17 |
pixels[x, y] = (255, 0, 0, 125)
|
| 18 |
|
| 19 |
+
# Save annotated image to a temporary file
|
| 20 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
|
| 21 |
overlay.save(temp_file.name)
|
| 22 |
annotated_path = temp_file.name
|