Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,6 +63,38 @@ def zoom_at(img, x, y, zoom):
|
|
63 |
x + w / zoom2, y + h / zoom2))
|
64 |
return img.resize((w, h), Image.LANCZOS)
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
st.set_page_config(page_title="CLL Explorer", layout="wide")
|
67 |
st.title("CLL Explorer - Malaria Cell Detection")
|
68 |
|
@@ -99,10 +131,10 @@ if uploaded_files:
|
|
99 |
sharpness = st.slider("Sharpness", 0.0, 2.0, 1.0)
|
100 |
|
101 |
if st.button("Apply Adjustments"):
|
102 |
-
processed_img = apply_enhancements(img)
|
103 |
st.session_state.processed_img = processed_img
|
104 |
else:
|
105 |
-
processed_img = apply_enhancements(img)
|
106 |
st.session_state.processed_img = processed_img
|
107 |
|
108 |
# Display Processed Image
|
|
|
63 |
x + w / zoom2, y + h / zoom2))
|
64 |
return img.resize((w, h), Image.LANCZOS)
|
65 |
|
66 |
+
def apply_enhancements(img, x, y, zoom, contrast, brightness, sharpness):
|
67 |
+
'''
|
68 |
+
Apply zoom and image enhancements to the input image.
|
69 |
+
|
70 |
+
Parameters:
|
71 |
+
----------
|
72 |
+
img : PIL.Image
|
73 |
+
Input image.
|
74 |
+
x : int
|
75 |
+
X-coordinate of the zoom center.
|
76 |
+
y : int
|
77 |
+
Y-coordinate of the zoom center.
|
78 |
+
zoom : float
|
79 |
+
Zoom factor.
|
80 |
+
contrast : float
|
81 |
+
Contrast adjustment factor.
|
82 |
+
brightness : float
|
83 |
+
Brightness adjustment factor.
|
84 |
+
sharpness : float
|
85 |
+
Sharpness adjustment factor.
|
86 |
+
|
87 |
+
Returns:
|
88 |
+
-------
|
89 |
+
PIL.Image
|
90 |
+
Enhanced image.
|
91 |
+
'''
|
92 |
+
zoomed = zoom_at(img, x, y, zoom)
|
93 |
+
enhanced_contrast = ImageEnhance.Contrast(zoomed).enhance(contrast)
|
94 |
+
enhanced_brightness = ImageEnhance.Brightness(enhanced_contrast).enhance(brightness)
|
95 |
+
enhanced_sharpness = ImageEnhance.Sharpness(enhanced_brightness).enhance(sharpness)
|
96 |
+
return enhanced_sharpness
|
97 |
+
|
98 |
st.set_page_config(page_title="CLL Explorer", layout="wide")
|
99 |
st.title("CLL Explorer - Malaria Cell Detection")
|
100 |
|
|
|
131 |
sharpness = st.slider("Sharpness", 0.0, 2.0, 1.0)
|
132 |
|
133 |
if st.button("Apply Adjustments"):
|
134 |
+
processed_img = apply_enhancements(img, x, y, zoom, contrast, brightness, sharpness)
|
135 |
st.session_state.processed_img = processed_img
|
136 |
else:
|
137 |
+
processed_img = apply_enhancements(img, x, y, zoom, contrast, brightness, sharpness)
|
138 |
st.session_state.processed_img = processed_img
|
139 |
|
140 |
# Display Processed Image
|