Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thanks for this project! #45

Open
alexwlchan opened this issue Nov 27, 2021 · 3 comments
Open

Thanks for this project! #45

alexwlchan opened this issue Nov 27, 2021 · 3 comments

Comments

@alexwlchan
Copy link

I couldn't find a better way to contact you, so have an issue.

Thanks for this project – I've had a Python implementation of kmeans on images for a while, but I wanted to switch to Rust to make it go faster. I thought I might have to implement it myself, then I found your library and decided to try that. It was super easy to get working and saved me a ton of work, thanks!

If you're interested, this is where I'm using it: https://github.com/alexwlchan/dominant_colours

@okaneco
Copy link
Owner

okaneco commented Feb 27, 2022

That's great to hear. Sorry for the late response, somehow I missed a notification.

Your blogs were fun to read because I went down a very relatable path trying to solve a problem. Similar to the PDF problem, I wanted to extract a background color and foreground text color from music cover art. I started with a histogram but the results weren't appealing, and then wrote a simple median-cut implementation. Both had similar issues of favoring the uglier compression artifact pixels over what we see as dominant colors.

I settled on k-means which resulted in this library. I used CIELAB color for the brightest and darkest k-means results, adding/subtracting from their luma component until the sRGB colors reached a suitable WCAG ratio (and ended up adding convenience functions to palette at https://docs.rs/palette/latest/palette/trait.RelativeContrast.html).

To the last point of the dominant colors blog, I completely agree about making tools small enough that you can finish them. Doing one thing and doing it well is something I try to abide by but sometimes features creep in that are convenient for the developer possibly at the expense of the user. 😅

@shkr
Copy link

shkr commented Mar 3, 2022

@alexwlchan Thank you so much for sharing the message. As someone who is also trying to do more ai stuff on rust, your example repo was a savior

@29decibel
Copy link

@okaneco I am here to say thank you as well! ❤️ I was able to create a Elixir wrapper on top of it and using it in Livebook. https://github.com/29decibel/dominant_colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants