@poupe/material-color-utilities
Version:
Algorithms and utilities that power the Material Design 3 (M3) color system, including choosing theme colors from images and creating tones of colors; all in a new color space.
43 lines (42 loc) • 1.88 kB
TypeScript
/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* An image quantizer that improves on the speed of a standard K-Means algorithm
* by implementing several optimizations, including deduping identical pixels
* and a triangle inequality rule that reduces the number of comparisons needed
* to identify which cluster a point should be moved to.
*
* Wsmeans stands for Weighted Square Means.
*
* This algorithm was designed by M. Emre Celebi, and was found in their 2011
* paper, Improving the Performance of K-Means for Color Quantization.
* https://arxiv.org/abs/1101.0395
*/
export declare class QuantizerWsmeans {
/**
* @param inputPixels Colors in ARGB format.
* @param startingClusters Defines the initial state of the quantizer. Passing
* an empty array is fine, the implementation will create its own initial
* state that leads to reproducible results for the same inputs.
* Passing an array that is the result of Wu quantization leads to higher
* quality results.
* @param maxColors The number of colors to divide the image into. A lower
* number of colors may be returned.
* @return Colors in ARGB format.
*/
static quantize(inputPixels: number[], startingClusters: number[], maxColors: number): Map<number, number>;
}