Update app.py
Browse files
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 |
-
|
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, (
|
22 |
|
23 |
-
# Step 3: Bilateral Filter ์ ์ฉ (๊ฒฝ๊ณ
|
24 |
-
smoothed = cv2.bilateralFilter(blurred, d=
|
25 |
|
26 |
-
|
|
|
|
|
|
|
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],
|