Ignore more yellows and greens

Updated palettes to ignore a broader range or yellows, greens
and adjacent colors.

Change-Id: Ied6c3ea0cb917a19548483a42d66f1f4b4fee4f7
Fixes: 68683213
Test: atest tests/Internal/src/com/android/internal/colorextraction/types/TonalTest.java
This commit is contained in:
Lucas Dupin
2018-02-05 16:53:28 -08:00
parent 7b2354ece2
commit 47e7cfd8b5
3 changed files with 40 additions and 18 deletions

View File

@@ -405,12 +405,13 @@ public class Tonal implements ExtractionType {
return v - (float) Math.floor(v);
}
static class TonalPalette {
final float[] h;
final float[] s;
final float[] l;
final float minHue;
final float maxHue;
@VisibleForTesting
public static class TonalPalette {
public final float[] h;
public final float[] s;
public final float[] l;
public final float minHue;
public final float maxHue;
TonalPalette(float[] h, float[] s, float[] l) {
if (h.length != s.length || s.length != l.length) {

View File

@@ -257,52 +257,58 @@
<!-- Red Orange -->
<range h="20, 40"
s="0.7, 1"
l="0.28, 0.643"/>
l="0.2, 0.643"/>
<range h="20, 40"
s="0.3, 0.7"
l="0.414, 0.561"/>
<range h="20, 40"
s="0, 3"
s="0, 0.3"
l="0.343, 0.584"/>
<!-- Orange -->
<range h="40, 60"
s="0.7, 1"
l="0.173, 0.349"/>
l="0.173, 0.38"/>
<range h="40, 60"
s="0.3, 0.7"
l="0.233, 0.427"/>
<range h="40, 60"
s="0, 0.3"
l="0.231, 0.484"/>
l="0.231, 0.48"/>
<!-- Yellow 60 -->
<range h="60, 80"
s="0.7, 1"
l="0.488, 0.737"/>
l="0.15, 0.40"/>
<range h="60, 80"
s="0.3, 0.7"
l="0.673, 0.837"/>
l="0.15, 0.42"/>
<range h="60, 80"
s="0, 0.3"
l="0.35, 0.57"/>
<!-- Yellow Green 80 -->
<range h="80, 100"
s="0.7, 1"
l="0.469, 0.61"/>
l="0.36, 0.65"/>
<range h="80, 100"
s="0.3, 0.7"
l="0.48, 0.57"/>
<!-- Yellow green 100 -->
<range h="100, 120"
s="0.7, 1"
l="0.388, 0.612"/>
l="0.388, 0.67"/>
<range h="100, 120"
s="0.3, 0.7"
l="0.424, 0.541"/>
l="0.424, 0.58"/>
<!-- Green -->
<range h="120, 140"
s="0.7, 1"
l="0.375, 0.52"/>
l="0.37, 0.65"/>
<range h="120, 140"
s="0.3, 0.7"
l="0.435, 0.524"/>
l="0.435, 0.58"/>
<!-- Green Blue 140 -->
<range h="140, 160"
s="0.7, 1"
l="0.496, 0.641"/>
l="0.43, 0.641"/>
<!-- Seaoam -->
<range h="160, 180"
s="0.7, 1"

View File

@@ -98,6 +98,21 @@ public class TonalTest {
assertTrue("Blacklisted colors are empty", config.getBlacklistedColors().size() > 1);
}
@Test
public void tonal_rangeTest() {
Tonal.ConfigParser config = new Tonal.ConfigParser(InstrumentationRegistry.getContext());
for (Tonal.TonalPalette palette : config.getTonalPalettes()) {
assertTrue("minHue should be >= to 0.", palette.minHue >= 0);
assertTrue("maxHue should be <= to 360.", palette.maxHue <= 360);
assertTrue("S should be >= to 0.", palette.s[0] >= 0);
assertTrue("S should be <= to 1.", palette.s[1] <= 1);
assertTrue("L should be >= to 0.", palette.l[0] >= 0);
assertTrue("L should be <= to 1.", palette.l[1] <= 1);
}
}
@Test
public void tonal_blacklistTest() {
// Make sure that palette generation will fail.