{"id":15896188,"url":"https://github.com/numberoverzero/kmeans","last_synced_at":"2025-06-20T22:42:14.133Z","repository":{"id":10244538,"uuid":"12349846","full_name":"numberoverzero/kmeans","owner":"numberoverzero","description":"python wrapper for a basic c implementation of the k-means algorithm","archived":false,"fork":false,"pushed_at":"2015-03-26T16:36:40.000Z","size":308,"stargazers_count":24,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T07:53:20.844Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/numberoverzero.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-24T21:02:33.000Z","updated_at":"2024-07-24T23:17:44.000Z","dependencies_parsed_at":"2022-08-20T13:31:29.213Z","dependency_job_id":null,"html_url":"https://github.com/numberoverzero/kmeans","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/numberoverzero/kmeans","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fkmeans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fkmeans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fkmeans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fkmeans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numberoverzero","download_url":"https://codeload.github.com/numberoverzero/kmeans/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberoverzero%2Fkmeans/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261031433,"owners_count":23100014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T09:06:45.177Z","updated_at":"2025-06-20T22:42:09.120Z","avatar_url":"https://github.com/numberoverzero.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"kmeans\n===================\n.. image:: https://travis-ci.org/numberoverzero/kmeans.png?branch=master\n   :target: https://travis-ci.org/numberoverzero/kmeans\n\npython wrapper for a basic c implementation of the k-means algorithm.\n\n**Please review the limitations before using in any capacity where strict\naccuracy is required.  There is no overflow detection, and negatives are not\nsupported.  tuple values cannot exceed 255.**\n\nInstallation\n===================\n::\n\n    pip install kmeans\n\nUsage\n===================\n::\n\n    import kmeans\n    means = kmeans.kmeans(points, k)\n\n``points`` should be a list of tuples of the form ``(data, weight)`` where\n``data`` is a list with length 3.\n\nFor example, finding four mean colors for a group of pixels::\n\n    pixels = [\n        [(15, 20, 25), 1],  # [(r,g,b), count]\n        [(17, 31, 92), 5],\n        # ... Lots more ...\n    ]\n\n    centers = kmeans.kmeans(pixels, 4)\n\nIn this case, the weights passed in may be the frequency of the pixels occuring\nin an image, or some preference to pull the means towards a color.\n\nLimitations\n===================\n\nAll values must be **non-negative** **integers**, with the following\nrestrictions::\n\n    r, g, b        [0, 255]        (uint8_t)\n    count          [0, 4294967295] (uint32_t)\n    maximum points 4294967296      (uint32_t)\n    maximum means  256             (uint8_t)\n    max iterations 65536           (uint16_t)\n    max tolerance  65536           (uint16_t)\n\n\nInspiration\n===================\n\nhttp://charlesleifer.com/blog/using-python-to-generate-awesome-linux-desktop-themes/\n\nI wanted to apply the implementation there to images much larger than 200x200.\nRunning a 4k x 3k image was approaching 60 seconds on a nice computer, so I\ndecided to rewrite the kmeans implementation in c.\n\nContributors\n===================\n\n* chinatsu_ - 32bit compatibility\n\n.. _chinatsu: https://github.com/chinatsu\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberoverzero%2Fkmeans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumberoverzero%2Fkmeans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberoverzero%2Fkmeans/lists"}