Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -343,18 +343,18 @@ def draw_mask(v, d, evt: gr.EventData):
|
|
343 |
|
344 |
scale = 1
|
345 |
delta = 0
|
346 |
-
ddepth =
|
347 |
|
348 |
-
gray =
|
349 |
-
grad_x =
|
350 |
# Gradient-Y
|
351 |
-
# grad_y =
|
352 |
-
grad_y =
|
353 |
-
abs_grad_x =
|
354 |
-
abs_grad_y =
|
355 |
|
356 |
-
grad =
|
357 |
-
d["composite"] =
|
358 |
|
359 |
return gr.ImageEditor(value=d)
|
360 |
|
|
|
343 |
|
344 |
scale = 1
|
345 |
delta = 0
|
346 |
+
ddepth = cv2.CV_16S
|
347 |
|
348 |
+
gray = cv2.cvtColor(d["background"], cv2.COLOR_BGR2GRAY)
|
349 |
+
grad_x = cv2.Sobel(gray, ddepth, 1, 0, ksize=5, scale=scale, delta=delta, borderType=cv2.BORDER_DEFAULT)
|
350 |
# Gradient-Y
|
351 |
+
# grad_y = cv2.Scharr(gray,ddepth,0,1)
|
352 |
+
grad_y = cv2.Sobel(gray, ddepth, 0, 1, ksize=5, scale=scale, delta=delta, borderType=cv2.BORDER_DEFAULT)
|
353 |
+
abs_grad_x = cv2.convertScaleAbs(grad_x)
|
354 |
+
abs_grad_y = cv2.convertScaleAbs(grad_y)
|
355 |
|
356 |
+
grad = cv2.addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0)
|
357 |
+
d["composite"] = cv2.cvtColor(255-grad, cv2.COLOR_GRAY2RGB)
|
358 |
|
359 |
return gr.ImageEditor(value=d)
|
360 |
|