File size: 3,804 Bytes
8c20033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90dfd54
8c20033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90dfd54
8c20033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90dfd54
8c20033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90dfd54
8c20033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90dfd54
8c20033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90dfd54
8c20033
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import json
import os
import pickle
import random
from glob import glob

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import streamlit as st
from PIL import Image


@st.cache(allow_output_mutation=True, max_entries=10, ttl=3600)
def load_query(image_path):
    image = Image.open(image_path)
    width, height = image.size

    new_width = width
    new_height = height

    left = (width - new_width) / 2
    top = (height - new_height) / 2
    right = (width + new_width) / 2
    bottom = (height + new_height) / 2

    # Crop the center of the image
    cropped_image = image.crop(
        (left + 5, top + 40, right - 2125, bottom - (2805))
    ).resize((300, 300))

    return cropped_image


# CHM ############################################################################
@st.cache(allow_output_mutation=True, max_entries=10, ttl=3600)
def load_chm_nns(image_path):
    image = Image.open(image_path)
    width, height = image.size

    new_width = width
    new_height = height

    left = (width - new_width) / 2
    top = (height - new_height) / 2
    right = (width + new_width) / 2
    bottom = (height + new_height) / 2

    # Crop the center of the image
    cropped_image = image.crop((left + 525, top + 2830, right - 0, bottom - (10)))
    return cropped_image


@st.cache(allow_output_mutation=True, max_entries=10, ttl=3600)
def load_chm_corrs(image_path):
    image = Image.open(image_path)
    width, height = image.size

    new_width = width
    new_height = height

    left = (width - new_width) / 2
    top = (height - new_height) / 2
    right = (width + new_width) / 2
    bottom = (height + new_height) / 2

    # Crop the center of the image
    cropped_image = image.crop((left + 15, top + 1835, right - 45, bottom - 445))
    return cropped_image


# CHM ############################################################################

# KNN ############################################################################
@st.cache(allow_output_mutation=True, max_entries=10, ttl=3600)
def load_knn_nns(image_path):
    image = Image.open(image_path)
    width, height = image.size

    new_width = width
    new_height = height

    left = (width - new_width) / 2
    top = (height - new_height) / 2
    right = (width + new_width) / 2
    bottom = (height + new_height) / 2

    # Crop the center of the image
    cropped_image = image.crop((left + 525, top + 40, right - 10, bottom - (2805)))
    return cropped_image


# KNN ############################################################################

# EMD ############################################################################
@st.cache(allow_output_mutation=True, max_entries=10, ttl=3600)
def load_emd_nns(image_path):
    image = Image.open(image_path)
    width, height = image.size

    new_width = width
    new_height = height

    left = (width - new_width) / 2
    top = (height - new_height) / 2
    right = (width + new_width) / 2
    bottom = (height + new_height) / 2

    # Crop the center of the image
    cropped_image = image.crop((left + 525, top + 480, right - 5, bottom - (2365)))
    return cropped_image


@st.cache(allow_output_mutation=True, max_entries=10, ttl=3600)
def load_emd_corrs(image_path):
    image = Image.open(image_path)
    width, height = image.size

    new_width = width
    new_height = height

    left = (width - new_width) / 2
    top = (height - new_height) / 2
    right = (width + new_width) / 2
    bottom = (height + new_height) / 2

    # Crop the center of the image
    cropped_image = image.crop((left + 90, top + 880, right - 75, bottom - 1438))
    return cropped_image


# EMD ############################################################################


@st.cache()
def convert_df(df):
    return df.to_csv().encode("utf-8")