Skip to content
Commit 1439c86f authored by Aurélien Pomini's avatar Aurélien Pomini
Browse files

Use less clusters for color extraction for small bitmaps

The color extraction in WallpaperColors uses a K-Mean algorithm.
Currently, it uses 128 clusters, so it generates 128 colors, and then select the most important ones.

But for most widgets this method is called with highly downscaled bitmaps (as small as 20x20 px), so we're trying to k-mean 128 clusters with only a couple hundreds of datapoints, which is most likely instable.

This CL changes the number of cluster to be max(5, min(nPixels / 16, 128)). Thus, image with less than 2048 px (about 45x45) will use less than 128 clusters, but always at least 5 clusters.

Bug: 273505854
Bug: 268180548
Test: perfetto trace
Test: manual: observe the result on widget colors
Change-Id: I34c13cfca392bb64bae4e7bf0adc1933c0eeb67c
parent fbba5e15
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment