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