-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracingScript.py
More file actions
34 lines (26 loc) · 969 Bytes
/
tracingScript.py
File metadata and controls
34 lines (26 loc) · 969 Bytes
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
import matplotlib.pyplot as plt
import numpy as np
# Step 1: Load the glacier image
#image_path = "images/1918-GlacierImage.png"
image_path = "images/2018-GlacierImage.png" #Change which line is commented out based on which image you want to analyze
img = plt.imread(image_path)
# Display the image
plt.imshow(img)
plt.title("Trace the Glacier Outline")
plt.xlabel("Width (pixels)")
plt.ylabel("Height (pixels)")
plt.show()
# Step 2: User traces the glacier's outline
glacier_outline = plt.ginput(n=-1, timeout=0, show_clicks=True)
glacier_outline = np.array(glacier_outline)
# Separate the points into x (horizontal) and y (vertical)
x_points = glacier_outline[:, 0]
y_points = glacier_outline[:, 1]
# Step 3: Plot the traced outline
plt.imshow(img)
plt.plot(x_points, img.shape[0] - glacier_outline[:, 1], 'r-', label="Glacier Outline")
plt.legend()
plt.title("Traced Glacier Outline")
plt.xlabel("Width (pixels)")
plt.ylabel("Height (pixels)")
plt.show()