Skier8402 commited on
Commit
d450846
·
verified ·
1 Parent(s): 07dd5b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -23
app.py CHANGED
@@ -68,6 +68,7 @@ st.title("CLL Explorer - Malaria Cell Detection")
68
 
69
  st.markdown("""
70
  ### About This Application
 
71
  - **Upload** microscope images.
72
  - **Adjust** image view with zoom and enhancement controls.
73
  - **Detect** and measure cells automatically.
@@ -85,35 +86,40 @@ if uploaded_files:
85
  img_data = uploaded_files[img_index].read()
86
  img = Image.open(io.BytesIO(img_data)).resize((500, 500))
87
 
88
- # Display Processed Image first
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  st.subheader("Processed Image")
90
- x = st.slider("X Coordinate", 0, 500, 250)
91
- y = st.slider("Y Coordinate", 0, 500, 250)
92
- zoom = st.slider("Zoom", 1, 10, 5)
93
-
94
- with st.expander("Enhancement Settings", expanded=True):
95
- contrast = st.slider("Contrast", 0.0, 5.0, 1.0)
96
- brightness = st.slider("Brightness", 0.0, 5.0, 1.0)
97
- sharpness = st.slider("Sharpness", 0.0, 2.0, 1.0)
98
-
99
- def apply_enhancements(image):
100
- zoomed = zoom_at(image, x, y, zoom)
101
- enhanced_contrast = ImageEnhance.Contrast(zoomed).enhance(contrast)
102
- enhanced_bright = ImageEnhance.Brightness(enhanced_contrast).enhance(brightness)
103
- enhanced_sharp = ImageEnhance.Sharpness(enhanced_bright).enhance(sharpness)
104
- return enhanced_sharp
105
-
106
- processed_img = apply_enhancements(img)
107
- st.image(processed_img, caption="Processed Image")
108
-
109
- # Show Original Image next
110
  st.subheader("Original Image")
111
- st.image(img, caption="Original Image")
112
 
113
  # Save Options
114
  save_image = st.checkbox("Save Processed Image")
115
  if save_image:
116
- processed_img.save("image-processed.jpg")
117
  st.success("Image saved as `image-processed.jpg`")
118
 
119
  with st.expander("Save Options"):
 
68
 
69
  st.markdown("""
70
  ### About This Application
71
+ This tool assists researchers in analyzing microscope images of any cell type. Or something else entirely.
72
  - **Upload** microscope images.
73
  - **Adjust** image view with zoom and enhancement controls.
74
  - **Detect** and measure cells automatically.
 
86
  img_data = uploaded_files[img_index].read()
87
  img = Image.open(io.BytesIO(img_data)).resize((500, 500))
88
 
89
+ # Sidebar for Image Controls
90
+ with st.sidebar:
91
+ st.header("Image Controls")
92
+ x = st.slider("X Coordinate", 0, 500, 250)
93
+ y = st.slider("Y Coordinate", 0, 500, 250)
94
+ zoom = st.slider("Zoom", 1, 10, 5)
95
+
96
+ with st.expander("Enhancement Settings", expanded=True):
97
+ contrast = st.slider("Contrast", 0.0, 5.0, 1.0)
98
+ brightness = st.slider("Brightness", 0.0, 5.0, 1.0)
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
109
  st.subheader("Processed Image")
110
+ if 'processed_img' in st.session_state:
111
+ st.image(st.session_state.processed_img, use_column_width=True, caption="Processed Image")
112
+ else:
113
+ st.image(processed_img, use_column_width=True, caption="Processed Image")
114
+
115
+ # Display Original Image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  st.subheader("Original Image")
117
+ st.image(img, use_column_width=True, caption="Original Image")
118
 
119
  # Save Options
120
  save_image = st.checkbox("Save Processed Image")
121
  if save_image:
122
+ st.session_state.processed_img.save("image-processed.jpg")
123
  st.success("Image saved as `image-processed.jpg`")
124
 
125
  with st.expander("Save Options"):