top of page
Search

PYTHON CODING

  • Writer: waclaw_koscielniak
    waclaw_koscielniak
  • Oct 15, 2025
  • 1 min read

import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg from sklearn.cluster import KMeans image = mpimg.imread('Baby_dinosaur.jpg') w, h, d = image.shape pixels = image.reshape(w * h, d) n_colors = 16 kmeans = KMeans(n_clusters=n_colors, random_state=42).fit(pixels) palette = np.uint8(kmeans.cluster_centers_) plt.imshow([palette]) plt.axis('off') plt.show() #Python #PythonCoding #VSC

Baby_dinosaur.jpg
Baby_dinosaur.jpg
















Color strip.
Color strip.










 
 
 

Recent Posts

See All

1 Comment


Guest
Oct 15, 2025

Try to run it.

Like
bottom of page