Kims12 commited on
Commit
8c4ce03
โ€ข
1 Parent(s): 42691c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -13,17 +13,19 @@ def apply_filter(image, filter_type, intensity):
13
  soft_glow = cv2.addWeighted(image, 1 - normalized_intensity, gaussian, normalized_intensity, 0)
14
  return soft_glow
15
  elif filter_type == "Portrait Enhancer":
16
- # ๋ถ€๋“œ๋Ÿฌ์šด ํ”ผ๋ถ€ ํ‘œํ˜„์„ ์œ„ํ•œ ํ•„ํ„ฐ ์กฐํ•ฉ
17
- # Step 1: Detail Enhance ์‚ฌ์šฉ ์ตœ์†Œํ™”
18
- enhanced = cv2.detailEnhance(image, sigma_s=5, sigma_r=0.05 + 0.05 * normalized_intensity)
19
 
20
- # Step 2: Gaussian Blur ์ ์šฉ (์ ๋‹นํ•œ ๊ฐ•๋„๋กœ)
21
- blurred = cv2.GaussianBlur(enhanced, (15, 15), 0)
22
 
23
- # Step 3: Bilateral Filter ์ ์šฉ (๊ฒฝ๊ณ„ ๋ณด์กดํ•˜๋ฉด์„œ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ)
24
- smoothed = cv2.bilateralFilter(blurred, d=9, sigmaColor=75, sigmaSpace=75)
25
 
26
- return smoothed
 
 
 
27
  elif filter_type == "Warm Tone":
28
  increase_red = np.array([[1.0 + 0.2 * normalized_intensity, 0.0, 0.0],
29
  [0.0, 1.0, 0.0],
 
13
  soft_glow = cv2.addWeighted(image, 1 - normalized_intensity, gaussian, normalized_intensity, 0)
14
  return soft_glow
15
  elif filter_type == "Portrait Enhancer":
16
+ # Step 1: Detail Enhance ์ ์šฉ (๋‹ค์†Œ ๊ฐ•ํ•˜๊ฒŒ)
17
+ enhanced = cv2.detailEnhance(image, sigma_s=10, sigma_r=0.1 + 0.1 * normalized_intensity)
 
18
 
19
+ # Step 2: Gaussian Blur ์ ์šฉ (๊ฐ•๋„ ์กฐ์ •)
20
+ blurred = cv2.GaussianBlur(enhanced, (5, 5), 0)
21
 
22
+ # Step 3: Bilateral Filter ์ ์šฉ (์•ฝํ•˜๊ฒŒ, ๊ฒฝ๊ณ„ ๋ณด์กด)
23
+ smoothed = cv2.bilateralFilter(blurred, d=5, sigmaColor=50, sigmaSpace=50)
24
 
25
+ # Step 4: ์›๋ณธ ์ด๋ฏธ์ง€์™€ ํ˜ผํ•ฉํ•˜์—ฌ ์„ ๋ช…ํ•จ ์œ ์ง€
26
+ final_image = cv2.addWeighted(enhanced, 0.7, smoothed, 0.3, 0)
27
+
28
+ return final_image
29
  elif filter_type == "Warm Tone":
30
  increase_red = np.array([[1.0 + 0.2 * normalized_intensity, 0.0, 0.0],
31
  [0.0, 1.0, 0.0],