Last active
January 26, 2018 21:12
-
-
Save skt7/3a660ae2b4478349f13b6af6c3e862b8 to your computer and use it in GitHub Desktop.
Python code to see which cluster each pixel belong to.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
class DominantColors: | |
def rgb_to_hex(self, rgb): | |
return '#%02x%02x%02x' % (int(rgb[0]), int(rgb[1]), int(rgb[2])) | |
def plotClusters(self): | |
#plotting | |
fig = plt.figure() | |
ax = Axes3D(fig) | |
for label, pix in zip(self.LABELS, self.IMAGE): | |
ax.scatter(pix[0], pix[1], pix[2], color = self.rgb_to_hex(self.COLORS[label])) | |
plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment