File size: 1,463 Bytes
2205216
17228a6
 
 
2205216
17228a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba13ba3
9e8586d
 
776951a
 
 
 
 
 
 
 
ba13ba3
 
 
9e8586d
 
 
 
ba13ba3
776951a
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
33
34
35
36
37
38
39
40
41
42
43
44
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)