Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ashlinrichardson committed Jun 28, 2023
1 parent 4c9cb65 commit e78c95c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions py/raster_slic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,20 @@
plt.imshow(labels)
plt.tight_layout()
plt.savefig("labels.png")

# Calculate the mean color for each segment
segment_means = np.zeros_like(img)
for label in np.unique(labels):
segment_means[labels == label] = np.mean(img[labels == label], axis=0)

# Display the original image and the segmented image
fig, axs = plt.subplots(1, 2, figsize=(10, 5))
axs[0].imshow(img)
axs[0].set_title('Original Image')
axs[0].axis('off')
axs[1].imshow(segment_means)
axs[1].set_title('Segmented Image')
axs[1].axis('off')

plt.tight_layout()
plt.show()

0 comments on commit e78c95c

Please sign in to comment.