ColorFinder
It just gets to all the pixels in the image and store their color value as a key in a hash map. The value is then the number of pixels of the same color encountered. However, this gives poor results so here are the improvements I wrote: I treat at most 5000 pixels so if the image is bigger I start undersampling. This is an order of magnitude, not a certain rule. To avoid noise due to flat areas (text, borders, ...) I start by right shifting all the RGB values by 6. So all the values are now between 0 and 3, allowing to encompass large areas of almost-the-same color. Then I perform another pass of the same algorithm (with a shift of 4) on all the pixels falling in the previous winning color group. And so on until I reach zero. When trying to find the group that has the most pixels, I use a callback to weight the score. This allows customization and tell the algorithm you wand a rather dark color, you wan to exclude black, you want only highly saturated color excluding the greys or anything else you might think of.
Install
dotnet add package ColorFinder --version 1.1.0
Install-Package ColorFinder -Version 1.1.0
<PackageReference Include="ColorFinder" Version="1.1.0" />
Frameworks
No framework metadata available.
Dependencies
No declared dependencies.
Adoption guide
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.
No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.
How to read this guidance
Sources: published NuGet v3 registry metadata and explicit NuBrowse editorial guides. Refresh: package metadata is refreshed from NuGet when the page loads. Limit: this is not a security, legal or compatibility guarantee; validate the selected version in your project.
Useful next steps
Move from package metadata to a concrete selection or review workflow.