Update app.py
Browse files
app.py
CHANGED
@@ -37,17 +37,15 @@ def apply_filter(image, filter_type, intensity):
|
|
37 |
enhanced_image = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2BGR)
|
38 |
return enhanced_image
|
39 |
elif filter_type == "Warm Tone":
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
return warm_image
|
45 |
elif filter_type == "Cold Tone":
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
return cold_image
|
51 |
elif filter_type == "High-Key":
|
52 |
high_key = cv2.convertScaleAbs(image, alpha=1.0 + 0.2 * normalized_intensity, beta=30)
|
53 |
return high_key
|
@@ -62,14 +60,14 @@ def apply_filter(image, filter_type, intensity):
|
|
62 |
|
63 |
def convert_to_grayscale(image):
|
64 |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
65 |
-
return gray_image
|
66 |
|
67 |
def convert_and_save(image, filter_type, intensity):
|
68 |
filtered_image = apply_filter(image, filter_type, intensity)
|
69 |
|
70 |
# numpy array를 PIL 이미지로 변환
|
71 |
original_image_pil = Image.fromarray(cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR))
|
72 |
-
filtered_image_pil = Image.fromarray(
|
73 |
|
74 |
return original_image_pil, filtered_image_pil # 원본과 필터 적용된 이미지를 반환
|
75 |
|
|
|
37 |
enhanced_image = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2BGR)
|
38 |
return enhanced_image
|
39 |
elif filter_type == "Warm Tone":
|
40 |
+
# 따뜻한 톤 적용
|
41 |
+
warm_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
42 |
+
warm_image = cv2.applyColorMap(warm_image, cv2.COLORMAP_AUTUMN)
|
43 |
+
return cv2.cvtColor(warm_image, cv2.COLOR_RGB2BGR)
|
|
|
44 |
elif filter_type == "Cold Tone":
|
45 |
+
# 차가운 톤 적용
|
46 |
+
cold_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
47 |
+
cold_image = cv2.applyColorMap(cold_image, cv2.COLORMAP_WINTER)
|
48 |
+
return cv2.cvtColor(cold_image, cv2.COLOR_RGB2BGR)
|
|
|
49 |
elif filter_type == "High-Key":
|
50 |
high_key = cv2.convertScaleAbs(image, alpha=1.0 + 0.2 * normalized_intensity, beta=30)
|
51 |
return high_key
|
|
|
60 |
|
61 |
def convert_to_grayscale(image):
|
62 |
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
63 |
+
return cv2.cvtColor(gray_image, cv2.COLOR_GRAY2BGR) # 필터 적용 후 일관성을 위해 BGR로 변환
|
64 |
|
65 |
def convert_and_save(image, filter_type, intensity):
|
66 |
filtered_image = apply_filter(image, filter_type, intensity)
|
67 |
|
68 |
# numpy array를 PIL 이미지로 변환
|
69 |
original_image_pil = Image.fromarray(cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR))
|
70 |
+
filtered_image_pil = Image.fromarray(filtered_image)
|
71 |
|
72 |
return original_image_pil, filtered_image_pil # 원본과 필터 적용된 이미지를 반환
|
73 |
|