Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ashlinrichardson committed Dec 18, 2024
1 parent 082315c commit 86add3f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions data/ubc/embedding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
python3 embedding_test.py small/G80223_20230513.bin_scale.bin
'''

import os
import sys
import umap
Expand Down Expand Up @@ -78,16 +79,16 @@ def get_model(model_type='tsne'):
rgb_values[:, i][np.where(rgb_values[:, i] < 0.)] = 0.
rgb_values[:, i][np.where(rgb_values[:, i] > 1.)] = 1.

# Create a figure with two subplots (for UMAP/t-SNE and RGB values)
fig, axs = plt.subplots(1, 2, figsize=(16, 6)) # 1 row, 2 columns
# Create a figure with three subplots (for UMAP/t-SNE, RGB values with masks, and original image)
fig, axs = plt.subplots(1, 3, figsize=(18, 6)) # 1 row, 3 columns

# First subplot: UMAP or t-SNE projection colored by RGB values
scatter = axs[0].scatter(embedding[:, 0], embedding[:, 1], c=rgb_values, s=1, alpha=0.5) # Scatter plot with RGB coloring
axs[0].set_title(f'{model_type.upper()} Projection of Raster Data')
axs[0].set_xlabel(f'{model_type.upper()} Component 1')
axs[0].set_ylabel(f'{model_type.upper()} Component 2')

# Second subplot: Display RGB values using imshow
# Second subplot: Display RGB values using imshow with the mask applied
# Reshape the RGB values back to (height, width, 3) for imshow
rgb_image = rgb_values.reshape(height, width, 3) # Recreate the RGB image

Expand All @@ -96,6 +97,15 @@ def get_model(model_type='tsne'):
axs[1].axis('off') # Hide axes for better visualization
axs[1].set_title('RGB Values of Raster')

# Third subplot: Original image (without any modifications)
# Display the original image (in this case, we are using RGB bands for visualization)
original_image = np.moveaxis(data[:3, :, :], 0, -1) # First 3 bands for the original image

# Display the original image
axs[2].imshow(original_image)
axs[2].axis('off') # Hide axes for better visualization
axs[2].set_title('Original Image')

# Initialize variables for polygon drawing
polygon_points = []
polygon_path = None
Expand Down Expand Up @@ -170,3 +180,4 @@ def mask_polygon():
plt.tight_layout()
plt.show()


0 comments on commit 86add3f

Please sign in to comment.