Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ This is the originall CLL Explorer application that allows users to upload, proc
|
|
| 4 |
The application provides the following functionalities:
|
| 5 |
- Upload microscope images.
|
| 6 |
- Adjust image view with zoom and enhancement controls.
|
| 7 |
-
- Detect and measure cells
|
| 8 |
- Save analysis results and annotations.
|
| 9 |
|
| 10 |
The application is divided into the following sections:
|
|
@@ -96,11 +96,11 @@ def apply_enhancements(img, x, y, zoom, contrast, brightness, sharpness):
|
|
| 96 |
return enhanced_sharpness
|
| 97 |
|
| 98 |
st.set_page_config(page_title="CLL Explorer", layout="wide")
|
| 99 |
-
st.title("CLL Explorer
|
| 100 |
|
| 101 |
st.markdown("""
|
| 102 |
### About This Application
|
| 103 |
-
This tool assists researchers in analyzing microscope images of any cell type.
|
| 104 |
- **Upload** microscope images.
|
| 105 |
- **Adjust** image view with zoom and enhancement controls.
|
| 106 |
- **Detect** and measure cells automatically.
|
|
@@ -118,9 +118,18 @@ if uploaded_files:
|
|
| 118 |
img_data = uploaded_files[img_index].read()
|
| 119 |
img = Image.open(io.BytesIO(img_data)).resize((500, 500))
|
| 120 |
|
| 121 |
-
#
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
x = st.slider("X Coordinate", 0, 500, 250)
|
| 125 |
y = st.slider("Y Coordinate", 0, 500, 250)
|
| 126 |
zoom = st.slider("Zoom", 1, 10, 5)
|
|
@@ -133,18 +142,12 @@ if uploaded_files:
|
|
| 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
|
| 141 |
-
st.subheader("Processed Image")
|
| 142 |
-
if 'processed_img' in st.session_state:
|
| 143 |
-
st.image(st.session_state.processed_img, use_column_width=True, caption="Processed Image")
|
| 144 |
-
else:
|
| 145 |
-
st.image(processed_img, use_column_width=True, caption="Processed Image")
|
| 146 |
-
|
| 147 |
-
# Display Original Image
|
| 148 |
st.subheader("Original Image")
|
| 149 |
st.image(img, use_column_width=True, caption="Original Image")
|
| 150 |
|
|
|
|
| 4 |
The application provides the following functionalities:
|
| 5 |
- Upload microscope images.
|
| 6 |
- Adjust image view with zoom and enhancement controls.
|
| 7 |
+
- Detect and measure cells automatically.
|
| 8 |
- Save analysis results and annotations.
|
| 9 |
|
| 10 |
The application is divided into the following sections:
|
|
|
|
| 96 |
return enhanced_sharpness
|
| 97 |
|
| 98 |
st.set_page_config(page_title="CLL Explorer", layout="wide")
|
| 99 |
+
st.title("CLL Explorer: Cell Image Analysis Prep Tool")
|
| 100 |
|
| 101 |
st.markdown("""
|
| 102 |
### About This Application
|
| 103 |
+
This tool assists researchers in analyzing microscope images of any cell type.
|
| 104 |
- **Upload** microscope images.
|
| 105 |
- **Adjust** image view with zoom and enhancement controls.
|
| 106 |
- **Detect** and measure cells automatically.
|
|
|
|
| 118 |
img_data = uploaded_files[img_index].read()
|
| 119 |
img = Image.open(io.BytesIO(img_data)).resize((500, 500))
|
| 120 |
|
| 121 |
+
# Create columns with image on the left and controls on the right
|
| 122 |
+
image_col, controls_col = st.columns([3, 1])
|
| 123 |
+
|
| 124 |
+
with image_col:
|
| 125 |
+
st.subheader("Processed Image")
|
| 126 |
+
if 'processed_img' in st.session_state:
|
| 127 |
+
st.image(st.session_state.processed_img, use_column_width=True, caption="Processed Image")
|
| 128 |
+
else:
|
| 129 |
+
st.image(img, use_column_width=True, caption="Processed Image")
|
| 130 |
+
|
| 131 |
+
with controls_col:
|
| 132 |
+
st.subheader("Image Controls")
|
| 133 |
x = st.slider("X Coordinate", 0, 500, 250)
|
| 134 |
y = st.slider("Y Coordinate", 0, 500, 250)
|
| 135 |
zoom = st.slider("Zoom", 1, 10, 5)
|
|
|
|
| 142 |
if st.button("Apply Adjustments"):
|
| 143 |
processed_img = apply_enhancements(img, x, y, zoom, contrast, brightness, sharpness)
|
| 144 |
st.session_state.processed_img = processed_img
|
| 145 |
+
st.experimental_rerun()
|
| 146 |
else:
|
| 147 |
processed_img = apply_enhancements(img, x, y, zoom, contrast, brightness, sharpness)
|
| 148 |
st.session_state.processed_img = processed_img
|
| 149 |
|
| 150 |
+
# Display Original Image Below
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
st.subheader("Original Image")
|
| 152 |
st.image(img, use_column_width=True, caption="Original Image")
|
| 153 |
|