Skip to content

Multithreaded K-Means and K-Means++ clustering algorithms with multidimensional vectors. Charged with example of image palette extraction.

License

Notifications You must be signed in to change notification settings

nikvoronin/k-means-plus-plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multithreading K-Means++ algorithm

--with multidimensional vectors.

Vector-3 branch contains simple but more efficient version of image palette extraction. It is using System.Numerics.Vector3 type and applied in The Last Wallpaper project to make colored mosaic tray icons.

K-Means Processor

  • ProcessorOptions
    • ThreadCount
    • Number of iterations
  • VectorN<T>
  • KmCluster
    • Centroid
  • IKmInitializer
    • Simple
    • K++
  • IDistanceEstimator
    • Euclidean, +Root
    • Chebyshev
    • Manhattan

VectorN<T> where T is an any numeric C# type such as integer or floating point, byte, int, double, decimal, etc.

Im Palette Extractor

Example of console output: (the values are close to images above but not actual)

Vectors base type = Double
Number of threads = 8
Max iterations = 1000
Convergence epsilon = 0.1
Clusters initializer = KppInitializer`1
Distance estimator = EuclideanDistance`1

apod20240814.jpeg
  Size: 4855x3237px, downscaled to 400x266px.
  Found in 3.654s
  Cluster 0: 28077 points
  Cluster 1: 17226 points
  Cluster 2: 3737 points
  Cluster 3: 6950 points
  Cluster 4: 19334 points
  Cluster 5: 5607 points
  Cluster 6: 3494 points
  Cluster 7: 5331 points
  Cluster 8: 6046 points
  Cluster 9: 10598 points
  Colors: #322934; #493745; #7A5A4C; #81436C; #140F08; #815866; #B96788; #AD4A91; #BA8B87; #613C55
bing000.jpeg
  Size: 3840x2160px, downscaled to 400x225px.
  Found in 4.091s
  Cluster 0: 14070 points
  Cluster 1: 5400 points
  Cluster 2: 8556 points
  Cluster 3: 5607 points
  Cluster 4: 12713 points
  Cluster 5: 10196 points
  Cluster 6: 13601 points
  Cluster 7: 5211 points
  Cluster 8: 6117 points
  Cluster 9: 8529 points
  Colors: #2F2C4D; #B9532C; #504385; #733B36; #1C1A1E; #9088C8; #594C64; #8D824A; #CFCCEC; #474838
  ...
wikipedia20240814.jpeg
  Size: 8256x5504px, downscaled to 400x266px.
  Found in 2.088s
  Cluster 0: 1816 points
  Cluster 1: 46070 points
  Cluster 2: 7794 points
  Cluster 3: 5663 points
  Cluster 4: 2834 points
  Cluster 5: 8727 points
  Cluster 6: 14064 points
  Cluster 7: 2627 points
  Cluster 8: 15491 points
  Cluster 9: 1314 points
  Colors: #7A7328; #787873; #D7761D; #C1401A; #B0AA40; #CBB9A2; #A3A19B; #682814; #F9B139; #A18675

References

About

Multithreaded K-Means and K-Means++ clustering algorithms with multidimensional vectors. Charged with example of image palette extraction.

Topics

Resources

License

Stars

Watchers

Forks

Languages