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