line_compare / app.py
ce-dric
fixed intentation
ba13ba3
raw
history blame
1.09 kB
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)