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)) line_styles = ['-.', '--', 'solid'] colors = ['blue', 'green', 'red'] for i, scan_line in enumerate(scan_lines): file_name = uploaded_files[i].name style = line_styles[i % len(line_styles)] color = colors[i % len(colors)] plt.plot(scan_line, label=file_name, linestyle=style, color=color, alpha=0.7, linewidth=1.5) plt.xlabel('Pixel Position') plt.ylabel('Pixel Value') plt.title('Comparison of Scan Lines Across Images') handles, labels = plt.gca().get_legend_handles_labels() by_label = dict(zip(labels, handles)) plt.legend(by_label.values(), by_label.keys(), loc='upper left') st.pyplot(plt)