freealise commited on
Commit
b8f02e1
1 Parent(s): 7efd13c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -343,18 +343,18 @@ def draw_mask(v, d, evt: gr.EventData):
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
 
 
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