redwarp / kmeans-gpu Goto Github PK
View Code? Open in Web Editor NEWK-means clustering for image color quantization running on GPU
License: MIT License
K-means clustering for image color quantization running on GPU
License: MIT License
Let's see if k-mean++ improves convergence!
Currently, we do as many pass as there are centroids to calculate each new centroid.
The reason is buffer size: we create a buffer (colour buffer) that holds the aggregate and the full prefix, so 8 info, times 4 bits, per workgroup.
The max size of a buffer is defined by the limit max_storage_buffer_binding_size
, defaults to 128MB.
Let's calculate how many colour buffer can fit in 128MB dynamically, and modify the shader so it can calculate multiple centroids at once.
This should speed things dramatically.
A random image with a lot of random colours would be good way to test, as we can't expect fast convergence.
We currently call several block_on() using pollster, let's make them async, and let the cli part actually handle how async code is called.
Out of curiosity, edit shader so that the buffers have fixed size, to see if it impacts performance.
Refactor with strict like struct InputTexture(texture)
Currently, the cpu has the responsability for doing rbgu8 to rbgu32f or rbgu8 to lab. This should be gpu-i-fied, should make stuff faster.
Hello!
I'm writing lulezojne. It's a WIP pywal clone heavily inspierd by lule with templating support and some additional goodies. I'd like it if this was a crate I could use as a color extraction backend.
I'm currently using kmeans-colors and color-thief-rs for backends (which the user can select as is the case with pywal). The kmeans cpu implementation is slow (maybe im setting wrong arguments on it) and the colorthief backend only generates 16 colors max. I'd like to see how much performance I could get with this backend.
I could make a PR for it and all that's needed - I'm just asking to see if you are interested in something like that.
The dispatch size is rounded down, meaning some pixels will be omitted.
The size of the colour buffer is also wrong, the same way.
I should first calculate the proper dispatch size, then create the colour buffer accordingly.
Yup, let's create a dithering shader!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.