Skip to content

Instantly share code, notes, and snippets.

@aialenti
Created February 14, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aialenti/41071139ac320bc76154759a8f884788 to your computer and use it in GitHub Desktop.
Save aialenti/41071139ac320bc76154759a8f884788 to your computer and use it in GitHub Desktop.
#import pandas as pd
#import matplotlib
cluster_centers = clust.cluster_centers_
cluster_centers_rgb = cluster_centers * 255
# Save the prototypes in HSV color space for sorting
cluster_centers_hsv = matplotlib.colors.rgb_to_hsv(cluster_centers)
clusters_centers_df = pd.DataFrame()
# Save HSV
clusters_centers_df['H'] = cluster_centers_hsv[:, 0]
clusters_centers_df['S'] = cluster_centers_hsv[:, 1]
clusters_centers_df['V'] = cluster_centers_hsv[:, 2]
# Save RGB
clusters_centers_df['R'] = cluster_centers_rgb[:, 0].astype(np.int)
clusters_centers_df['G'] = cluster_centers_rgb[:, 1].astype(np.int)
clusters_centers_df['B'] = cluster_centers_rgb[:, 2].astype(np.int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment