Spaces:
Sleeping
Sleeping
ce-dric
commited on
Commit
·
17228a6
1
Parent(s):
2205216
update line scanner
Browse files- app.py +29 -2
- requirements.txt +3 -0
app.py
CHANGED
@@ -1,4 +1,31 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
st.write(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
|
6 |
+
st.title("Image Scan Line Analyzer")
|
7 |
+
st.write("Upload three images and select a common scan line to analyze.")
|
8 |
+
|
9 |
+
uploaded_files = st.file_uploader("Upload Images", type=['png', 'jpg', 'jpeg', 'bmp'], accept_multiple_files=True)
|
10 |
+
|
11 |
+
if len(uploaded_files) == 3:
|
12 |
+
min_height = min(Image.open(file).size[1] for file in uploaded_files)
|
13 |
+
|
14 |
+
line_pos = st.slider("Select Common Scan Line", 0, min_height - 1, value=min_height // 2)
|
15 |
+
|
16 |
+
scan_lines = []
|
17 |
+
|
18 |
+
for i, uploaded_file in enumerate(uploaded_files):
|
19 |
+
image = Image.open(uploaded_file)
|
20 |
+
pixels = np.array(image)
|
21 |
+
scan_line = pixels[line_pos, :]
|
22 |
+
scan_lines.append(scan_line)
|
23 |
+
|
24 |
+
plt.figure()
|
25 |
+
for i, (line, file) in enumerate(zip(scan_lines, uploaded_files)):
|
26 |
+
plt.plot(line, label=f'{file.name}')
|
27 |
+
plt.xlabel('Pixel Position')
|
28 |
+
plt.ylabel('Pixel Value')
|
29 |
+
plt.title('Comparison of Scan Lines Across Images')
|
30 |
+
plt.legend()
|
31 |
+
st.pyplot(plt)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
matplotlib
|
2 |
+
numpy
|
3 |
+
Pillow
|