README
main-colors
Get the main colors of an image. The main colors are determined with the dbscan clustering algorithm.
Usage
Basic usage:
import mainColors from "main-colors";
const colors = await mainColors("image.jpg");
The computed colors are in RGB format as a tuple (array) type and are sorted by their percantage of the picture:
for (let color of mainColors) {
console.log("RGB: " + color[0] + ", " + color[1] + ", " + color[2]);
}
With options:
import mainColors from "main-colors";
const options = {
sensitivity: 95, // default: 90
minClusterSize: 15, // default: 10
distanceFunction: undefined,
};
const colors = await mainColors("home.png", options);
sensitivity indicates the accuracy with which colors are compared (0-100%).
minClusterSize indicates how large the percentage of a color must be in the image, to be included in the result (0-100%).
The default distanceFunction can be found here as delta C.