From 1b54c4aefb6cceb478b0ce6b154347265f5ccbdc Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Fri, 8 Oct 2021 12:29:21 -0400 Subject: [PATCH] Ignore low chroma colors when calculating a hue's population MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We rank/score colors for suitability for theming choices, and the top 4 are presented to the user. The score has two components: the chroma, or colorfulness, of the color, and the hue population of the color — what percentage of the image has hues within 15 degrees of the color. A wallpaper that is mostly black, green leaves, and a light dash of low chroma red on a couple leaves, ends up ranking red as the highest choice because black has a red hue. Ignoring low chroma colors when calculating the hue population avoids this issue — the dash of low chroma reds no longer benefits from their hue being close to black, the majority of the image. Bug: 201980078 Test: Push wallpaper from bug comment #4 to device, check color options. Red is no longer offered as an option. To come: apply to Monet Studio, verify no ill effects Change-Id: Ib40a6646077e07c2cc85da339186d9a307709def --- .../monet/src/com/android/systemui/monet/ColorScheme.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt index e026012f9de8b..1844288796cc4 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt @@ -249,6 +249,9 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) { val population = populationByColor[entry.key]!! val cam = camByColor[entry.key]!! val hue = cam.hue.roundToInt() % 360 + if (cam.chroma <= MIN_CHROMA) { + continue + } huePopulation[hue] = huePopulation[hue] + population }