borakol commited on
Commit
b145bbf
·
verified ·
1 Parent(s): 9752c56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -6,8 +6,21 @@ import gradio as gr
6
  def apply_gaussian_blur(frame):
7
  return cv.GaussianBlur(frame, (15, 15), 0)
8
 
 
 
 
 
 
 
 
 
 
9
  def apply_sharpening_filter(frame):
10
- kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
 
 
 
 
11
  return cv.filter2D(frame, -1, kernel)
12
 
13
  def apply_edge_detection(frame):
@@ -35,6 +48,14 @@ def apply_filter(filter_type, input_image=None):
35
 
36
  if filter_type == "Gaussian Blur":
37
  return apply_gaussian_blur(frame)
 
 
 
 
 
 
 
 
38
  elif filter_type == "Sharpen":
39
  return apply_sharpening_filter(frame)
40
  elif filter_type == "Edge Detection":
@@ -53,7 +74,7 @@ with gr.Blocks() as demo:
53
  # Filtre seçenekleri
54
  filter_type = gr.Dropdown(
55
  label="Filtre Seçin",
56
- choices=["Gaussian Blur", "Sharpen", "Edge Detection", "Invert", "Brightness", "Grayscale"],
57
  value="Gaussian Blur"
58
  )
59
 
 
6
  def apply_gaussian_blur(frame):
7
  return cv.GaussianBlur(frame, (15, 15), 0)
8
 
9
+ def apply_box_blur(frame):
10
+ return cv.blur(frame, (5,5))
11
+
12
+ def apply_hsv(frame):
13
+ return cv.cvtColor(frame, cv.COLOR_BGR2HSV)
14
+
15
+ def apply_scale_contrast(frame):
16
+ return cv.convertScaleAbs(frame , alpha = 1.5 , beta = 0)
17
+
18
  def apply_sharpening_filter(frame):
19
+ kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, 1, 0]])
20
+ return cv.filter2D(frame, -1, kernel)
21
+
22
+ def apply_emboss_filter(frame):
23
+ kernel = np.array([[-2,-1,0],[-1,1,1],[0,1,2]])
24
  return cv.filter2D(frame, -1, kernel)
25
 
26
  def apply_edge_detection(frame):
 
48
 
49
  if filter_type == "Gaussian Blur":
50
  return apply_gaussian_blur(frame)
51
+ elif filter_type == "Box Blur":
52
+ return apply_box_blur(frame)
53
+ elif filter_type == "HSV":
54
+ return apply_hsv(frame)
55
+ elif filter_type == "Scale Contrast":
56
+ return apply_scale_contrast(frame)
57
+ elif filter_type == "Emboss Filter":
58
+ return apply_emboss_filter(frame)
59
  elif filter_type == "Sharpen":
60
  return apply_sharpening_filter(frame)
61
  elif filter_type == "Edge Detection":
 
74
  # Filtre seçenekleri
75
  filter_type = gr.Dropdown(
76
  label="Filtre Seçin",
77
+ choices=["Gaussian Blur", "Sharpen", "Edge Detection", "Invert", "Brightness", "Grayscale", "Box Blur", "HSV", "Scale Contrast", "Emboss Filter"],
78
  value="Gaussian Blur"
79
  )
80