From f154c27b1c17928cffcef18805c36518d294f4f5 Mon Sep 17 00:00:00 2001 From: Theresa Gresch Date: Sun, 12 May 2019 14:31:01 +0200 Subject: [PATCH] Change map and resampling for improved color indexing --- internal/photoprism/colors.go | 227 +++++++++++++++++------------ internal/photoprism/colors_test.go | 56 +++---- 2 files changed, 164 insertions(+), 119 deletions(-) diff --git a/internal/photoprism/colors.go b/internal/photoprism/colors.go index b1f10bea2..6f0b6d674 100644 --- a/internal/photoprism/colors.go +++ b/internal/photoprism/colors.go @@ -49,41 +49,41 @@ const ( ) var IndexedColorNames = map[IndexedColor]string{ - Black: "black", // 0 - Brown: "brown", // 1 - Grey: "grey", // 2 - White: "white", // 3 - Purple: "purple", // 4 - Gold: "gold", // 5 - Blue: "blue", // 6 - Cyan: "cyan", // 7 - Teal: "teal", // 8 - Green: "green", // 9 - Lime: "lime", // A - Yellow: "yellow", // B - Magenta: "magenta", // C - Orange: "orange", // D - Red: "red", // E - Pink: "pink", // F + Black: "black", // 0 + Brown: "brown", // 1 + Grey: "grey", // 2 + White: "white", // 3 + Purple: "purple", // 4 + Gold: "gold", // 5 + Blue: "blue", // 6 + Cyan: "cyan", // 7 + Teal: "teal", // 8 + Green: "green", // 9 + Lime: "lime", // A + Yellow: "yellow", // B + Magenta: "magenta", // C + Orange: "orange", // D + Red: "red", // E + Pink: "pink", // F } var IndexedColorWeight = map[IndexedColor]uint16{ - Black: 2, - Brown: 1, - Grey: 2, - White: 2, - Purple: 5, - Gold: 4, - Blue: 3, - Cyan: 4, - Teal: 4, - Green: 5, - Lime: 5, - Yellow: 5, - Magenta:5, - Orange: 4, - Red: 4, - Pink: 4, + Black: 2, + Brown: 2, + Grey: 1, + White: 2, + Purple: 4, + Gold: 4, + Blue: 3, + Cyan: 4, + Teal: 5, + Green: 4, + Lime: 5, + Yellow: 5, + Magenta: 5, + Orange: 4, + Red: 4, + Pink: 4, } func (c IndexedColor) Name() string { @@ -129,25 +129,19 @@ func (m LightMap) Hex() (result string) { var IndexedColorMap = map[color.RGBA]IndexedColor{ {0x00, 0x00, 0x00, 0xff}: Black, {0x79, 0x55, 0x48, 0xff}: Brown, - //{0xef, 0xeb, 0xe9, 0xff}: Brown, - //{0xd7, 0xcc, 0xc8, 0xff}: Brown, - //{0xbc, 0xaa, 0xa4, 0xff}: Brown, {0xa1, 0x88, 0x7f, 0xff}: Brown, {0x8d, 0x6e, 0x63, 0xff}: Brown, {0x6d, 0x4c, 0x41, 0xff}: Brown, {0x5d, 0x40, 0x37, 0xff}: Brown, - //{0x4e, 0x34, 0x2e, 0xff}: Brown, - //{0x3e, 0x27, 0x23, 0xff}: Brown, + {0xa0, 0x7f, 0x6c, 0xff}: Brown, + {0x17, 0x0f, 0x0c, 0xff}: Brown, + {0x9b, 0x7b, 0x5b, 0xff}: Brown, + {0x75, 0x64, 0x5b, 0xff}: Brown, {0x9E, 0x9E, 0x9E, 0xff}: Grey, - //{0xfa, 0xfa, 0xfa, 0xff}: Grey, - //{0xf5, 0xf5, 0xf5, 0xff}: Grey, - //{0xee, 0xee, 0xee, 0xff}: Grey, - //{0xe0, 0xe0, 0xe0, 0xff}: Grey, - //{0xbd, 0xbd, 0xbd, 0xff}: Grey, {0x75, 0x75, 0x75, 0xff}: Grey, {0x61, 0x61, 0x61, 0xff}: Grey, {0x42, 0x42, 0x42, 0xff}: Grey, - //{0x21, 0x21, 0x21, 0xff}: Grey, + {0xe0, 0xe0, 0xe0, 0xff}: Grey, {0xFF, 0xFF, 0xFF, 0xff}: White, {0x9c, 0x27, 0xb0, 0xff}: Purple, {0xf3, 0xe5, 0xf5, 0xff}: Purple, @@ -175,24 +169,22 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0x31, 0x1b, 0x92, 0xff}: Purple, {0xb3, 0x88, 0xff, 0xff}: Purple, {0x7c, 0x4d, 0xff, 0xff}: Purple, - //{0x65, 0x1f, 0xff, 0xff}: Purple, - //{0x62, 0x00, 0xea, 0xff}: Purple, + {0x5e, 0x3a, 0x5e, 0xff}: Purple, + {0x33, 0x13, 0x33, 0xff}: Purple, + {0x8e, 0x64, 0x93, 0xff}: Purple, + {0x9b, 0x31, 0x8f, 0xff}: Purple, + {0x86, 0x00, 0x7e, 0xff}: Purple, {0x3F, 0x51, 0xB5, 0xff}: Blue, - //{0xe8, 0xea, 0xf6, 0xff}: Blue, {0xc5, 0xca, 0xe9, 0xff}: Blue, - //{0x9f, 0xa8, 0xda, 0xff}: Blue, - //{0x79, 0x86, 0xcb, 0xff}: Blue, {0x5c, 0x6b, 0xc0, 0xff}: Blue, {0x39, 0x49, 0xab, 0xff}: Blue, {0x30, 0x3f, 0x9f, 0xff}: Blue, {0x28, 0x35, 0x93, 0xff}: Blue, {0x1a, 0x23, 0x7e, 0xff}: Blue, - //{0x8c, 0x9e, 0xff, 0xff}: Blue, {0x53, 0x6d, 0xfe, 0xff}: Blue, {0x3d, 0x5a, 0xfe, 0xff}: Blue, {0x30, 0x4f, 0xfe, 0xff}: Blue, {0x21, 0x96, 0xF3, 0xff}: Blue, - //{0xe3, 0xf2, 0xfd, 0xff}: Blue, {0xbb, 0xde, 0xfb, 0xff}: Blue, {0x90, 0xca, 0xf9, 0xff}: Blue, {0x64, 0xb5, 0xf6, 0xff}: Blue, @@ -206,7 +198,6 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0x29, 0x79, 0xff, 0xff}: Blue, {0x29, 0x62, 0xff, 0xff}: Blue, {0x03, 0xa9, 0xf6, 0xff}: Blue, - //{0xe1, 0xf5, 0xfe, 0xff}: Blue, {0xb3, 0xe5, 0xfc, 0xff}: Blue, {0x81, 0xd4, 0xfa, 0xff}: Blue, {0x4f, 0xc3, 0xf7, 0xff}: Blue, @@ -220,15 +211,18 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0x00, 0xb0, 0xff, 0xff}: Blue, {0x00, 0x91, 0xea, 0xff}: Blue, {0x60, 0x7d, 0x8b, 0xff}: Blue, - //{0xec, 0xef, 0xf1, 0xff}: Blue, - {0xcf, 0xd8, 0xdc, 0xff}: Blue, - {0xb0, 0xbe, 0xc5, 0xff}: Blue, - {0x90, 0xa4, 0xae, 0xff}: Blue, {0x78, 0x90, 0x9c, 0xff}: Blue, {0x54, 0x6e, 0x7a, 0xff}: Blue, {0x45, 0x5a, 0x64, 0xff}: Blue, {0x37, 0x47, 0x4f, 0xff}: Blue, - //{0x26, 0x32, 0x38, 0xff}: Blue, + {0xe4, 0xeb, 0xfd, 0xff}: Blue, + {0x08, 0x0f, 0x14, 0xff}: Blue, + {0x7d, 0xd3, 0xea, 0xff}: Blue, + {0x06, 0x1a, 0x2b, 0xff}: Blue, + {0x07, 0x63, 0x99, 0xff}: Blue, + {0x28, 0x44, 0x6b, 0xff}: Blue, + {0x4a, 0xc8, 0xf5, 0xff}: Blue, + {0x08, 0x00, 0xf4, 0xff}: Blue, {0x00, 0xBC, 0xD4, 0xff}: Cyan, {0xe0, 0xf7, 0xfa, 0xff}: Cyan, {0xb2, 0xeb, 0xf2, 0xff}: Cyan, @@ -244,19 +238,21 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0x00, 0xe5, 0xff, 0xff}: Cyan, {0x00, 0xb8, 0xd4, 0xff}: Cyan, {0x00, 0x96, 0x88, 0xff}: Teal, - {0xe0, 0xf2, 0xf1, 0xff}: Teal, - {0xb2, 0xdf, 0xdb, 0xff}: Teal, - {0x80, 0xcb, 0xc4, 0xff}: Teal, - {0x4d, 0xb6, 0xac, 0xff}: Teal, - {0x26, 0xa6, 0x9a, 0xff}: Teal, {0x00, 0x89, 0x7b, 0xff}: Teal, {0x00, 0x79, 0x6b, 0xff}: Teal, {0x00, 0x69, 0x5c, 0xff}: Teal, {0x00, 0x4d, 0x40, 0xff}: Teal, - {0xa7, 0xff, 0xeb, 0xff}: Teal, - {0x64, 0xff, 0xda, 0xff}: Teal, - {0x1d, 0xe9, 0xb6, 0xff}: Teal, - //{0x00, 0xbf, 0xa5, 0xff}: Teal, + {0x0a, 0x4e, 0x47, 0xff}: Teal, + {0x04, 0x5d, 0x5c, 0xff}: Teal, + {0x24, 0x5a, 0x5f, 0xff}: Teal, + {0x03, 0x45, 0x4f, 0xff}: Teal, + {0x2c, 0x54, 0x5e, 0xff}: Teal, + {0x07, 0x3c, 0x3d, 0xff}: Teal, + {0x11, 0x47, 0x41, 0xff}: Teal, + {0x17, 0x47, 0x41, 0xff}: Teal, + {0x18, 0x53, 0x61, 0xff}: Teal, + {0x2a, 0x46, 0x4c, 0xff}: Teal, + {0x01, 0x28, 0x2f, 0xff}: Teal, {0x4C, 0xAF, 0x50, 0xff}: Green, {0xe8, 0xf5, 0xe9, 0xff}: Green, {0xc8, 0xe6, 0xc9, 0xff}: Green, @@ -285,17 +281,17 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xb2, 0xff, 0x59, 0xff}: Green, {0x76, 0xff, 0x03, 0xff}: Green, {0x64, 0xdd, 0x17, 0xff}: Green, + {0xdd, 0xd5, 0x79, 0xff}: Green, + {0xee, 0xec, 0xa2, 0xff}: Green, + {0xab, 0xc7, 0xb0, 0xff}: Green, + {0x24, 0x4e, 0x3b, 0xff}: Green, {0xCD, 0xDC, 0x39, 0xff}: Lime, - //{0xf9, 0xfb, 0xe7, 0xff}: Lime, {0xf0, 0xf4, 0xc3, 0xff}: Lime, {0xe6, 0xee, 0x9c, 0xff}: Lime, {0xdc, 0xe7, 0x75, 0xff}: Lime, {0xd4, 0xe1, 0x57, 0xff}: Lime, {0xc0, 0xca, 0x33, 0xff}: Lime, {0xaf, 0xb4, 0x2b, 0xff}: Lime, - //{0x9e, 0x9d, 0x24, 0xff}: Lime, - //{0x82, 0x77, 0x17, 0xff}: Lime, - //{0xf4, 0xff, 0x81, 0xff}: Lime, {0xee, 0xff, 0x41, 0xff}: Lime, {0xc6, 0xff, 0x00, 0xff}: Lime, {0xae, 0xea, 0x00, 0xff}: Lime, @@ -308,7 +304,6 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xfd, 0xd8, 0x35, 0xff}: Yellow, {0xfb, 0xc0, 0x2d, 0xff}: Yellow, {0xf9, 0xa8, 0x25, 0xff}: Yellow, - //{0xf5, 0x7f, 0x17, 0xff}: Yellow, {0xff, 0xff, 0x8d, 0xff}: Yellow, {0xff, 0xff, 0x00, 0xff}: Yellow, {0xff, 0xea, 0x00, 0xff}: Yellow, @@ -319,14 +314,25 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xff, 0xe0, 0x82, 0xff}: Yellow, {0xff, 0xd5, 0x4f, 0xff}: Yellow, {0xff, 0xca, 0x28, 0xff}: Yellow, - //{0xff, 0xb3, 0x00, 0xff}: Yellow, - //{0xff, 0xa0, 0x00, 0xff}: Yellow, - //{0xff, 0x8f, 0x00, 0xff}: Yellow, - //{0xff, 0x6f, 0x00, 0xff}: Yellow, + {0xe3, 0xce, 0x81, 0xff}: Yellow, + {0xee, 0xbb, 0x2b, 0xff}: Yellow, + {0xfe, 0xe5, 0x44, 0xff}: Yellow, + {0xee, 0xb9, 0x2b, 0xff}: Yellow, + {0xe9, 0xc9, 0x4a, 0xff}: Yellow, + {0xd3, 0xa8, 0x3a, 0xff}: Yellow, + {0xe9, 0xb2, 0x4a, 0xff}: Yellow, + {0xd6, 0xb5, 0x4b, 0xff}: Yellow, + {0xfa, 0xca, 0x2f, 0xff}: Yellow, + {0xed, 0xd3, 0x88, 0xff}: Yellow, + {0xeb, 0xcf, 0x5a, 0xff}: Yellow, + {0xf9, 0xe5, 0x8f, 0xff}: Yellow, {0xff, 0xe5, 0x7f, 0xff}: Yellow, {0xff, 0xd7, 0x40, 0xff}: Yellow, {0xff, 0xc4, 0x00, 0xff}: Yellow, - //{0xff, 0xab, 0x00, 0xff}: Yellow, + {0xd1, 0xaf, 0x52, 0xff}: Yellow, + {0xfc, 0xe8, 0x9d, 0xff}: Yellow, + {0xd2, 0xa9, 0x3d, 0xff}: Yellow, + {0xea, 0xd2, 0x2c, 0xff}: Yellow, {0xFF, 0x98, 0x00, 0xff}: Orange, {0xff, 0xf3, 0xe0, 0xff}: Orange, {0xff, 0xe0, 0xb2, 0xff}: Orange, @@ -350,14 +356,29 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xf4, 0x51, 0x1e, 0xff}: Orange, {0xe6, 0x4a, 0x19, 0xff}: Orange, {0xd8, 0x43, 0x15, 0xff}: Orange, - //{0xbf, 0x36, 0x0c, 0xff}: Orange, + {0xfa, 0xbe, 0x76, 0xff}: Orange, {0xff, 0x9e, 0x80, 0xff}: Orange, {0xff, 0x6e, 0x40, 0xff}: Orange, {0xff, 0x3d, 0x00, 0xff}: Orange, - //{0xdd, 0x2c, 0x00, 0xff}: Orange, + {0xfd, 0x9a, 0x31, 0xff}: Orange, + {0xfe, 0x88, 0x49, 0xff}: Orange, + {0xfe, 0xc8, 0x3a, 0xff}: Orange, + {0xe0, 0x56, 0x0e, 0xff}: Orange, + {0x7d, 0x27, 0x04, 0xff}: Orange, + {0xfd, 0x57, 0x1f, 0xff}: Orange, + {0xf8, 0x67, 0x04, 0xff}: Orange, + {0xf3, 0xa0, 0x1c, 0xff}: Orange, + {0xd4, 0x51, 0x07, 0xff}: Orange, + {0xfb, 0xb0, 0x64, 0xff}: Orange, + {0xfe, 0xb9, 0x71, 0xff}: Orange, + {0xee, 0x91, 0x33, 0xff}: Orange, + {0xfc, 0xb4, 0x70, 0xff}: Orange, + {0xcf, 0x59, 0x11, 0xff}: Orange, + {0xef, 0x95, 0x4b, 0xff}: Orange, + {0xdf, 0x88, 0x12, 0xff}: Orange, + {0xfd, 0x9a, 0x00, 0xff}: Orange, + {0xfe, 0x8a, 0x00, 0xff}: Orange, {0xf4, 0x43, 0x36, 0xff}: Red, - //{0xff, 0xeb, 0xee, 0xff}: Red, - //{0xff, 0xcd, 0xd2, 0xff}: Red, {0xef, 0x9a, 0x9a, 0xff}: Red, {0x68, 0x0e, 0x19, 0xff}: Red, {0xe5, 0x73, 0x73, 0xff}: Red, @@ -366,10 +387,25 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xd3, 0x2f, 0x2f, 0xff}: Red, {0xc6, 0x28, 0x28, 0xff}: Red, {0xb7, 0x1c, 0x1c, 0xff}: Red, - //{0xff, 0x8a, 0x80, 0xff}: Red, {0xff, 0x52, 0x52, 0xff}: Red, - //{0xff, 0x17, 0x44, 0xff}: Red, {0xd5, 0x00, 0x00, 0xff}: Red, + {0xdb, 0x08, 0x06, 0xff}: Red, + {0x9b, 0x19, 0x29, 0xff}: Red, + {0xcf, 0x09, 0x04, 0xff}: Red, + {0xd8, 0x1a, 0x14, 0xff}: Red, + {0xcc, 0x17, 0x08, 0xff}: Red, + {0x51, 0x12, 0x18, 0xff}: Red, + {0xd8, 0x0a, 0x07, 0xff}: Red, + {0xde, 0x26, 0x16, 0xff}: Red, + {0xee, 0x24, 0x0f, 0xff}: Red, + {0xda, 0x20, 0x0e, 0xff}: Red, + {0xb7, 0x20, 0x40, 0xff}: Red, + {0xf6, 0x29, 0x2e, 0xff}: Red, + {0xa1, 0x21, 0x1f, 0xff}: Red, + {0xfc, 0x25, 0x2d, 0xff}: Red, + {0x49, 0x11, 0x14, 0xff}: Red, + {0x70, 0x12, 0x19, 0xff}: Red, + {0xba, 0x28, 0x30, 0xff}: Red, {0xe9, 0x1e, 0x63, 0xff}: Pink, {0xfc, 0xe4, 0xec, 0xff}: Pink, {0xf8, 0xbb, 0xd0, 0xff}: Pink, @@ -378,12 +414,13 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xec, 0x40, 0x7a, 0xff}: Pink, {0xd8, 0x1b, 0x60, 0xff}: Pink, {0xc2, 0x18, 0x5b, 0xff}: Pink, - //{0xad, 0x14, 0x57, 0xff}: Pink, - //{0x88, 0x0e, 0x4f, 0xff}: Pink, {0xff, 0x80, 0xab, 0xff}: Pink, {0xff, 0x40, 0x81, 0xff}: Pink, {0xf5, 0x00, 0x57, 0xff}: Pink, - //{0xc5, 0x11, 0x62, 0xff}: Pink, + {0xe7, 0x9f, 0xa6, 0xff}: Pink, + {0xe9, 0xdd, 0xdf, 0xff}: Pink, + {0xd5, 0xb4, 0xbf, 0xff}: Pink, + {0xfd, 0xc8, 0xeb, 0xff}: Pink, {0xff, 0x00, 0xff, 0xff}: Magenta, {0xe5, 0x00, 0xe5, 0xff}: Magenta, {0xcc, 0x00, 0xcc, 0xff}: Magenta, @@ -396,13 +433,16 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xb0, 0x00, 0x85, 0xff}: Magenta, {0xce, 0x00, 0x9b, 0xff}: Magenta, {0xf0, 0x00, 0xb5, 0xff}: Magenta, - // {0xff, 0xdf, 0x00, 0xff}: Gold, - {0xf3, 0xd0, 0x88, 0xff}: Gold, + {0x5b, 0x00, 0x2f, 0xff}: Magenta, + {0x4b, 0x01, 0x21, 0xff}: Magenta, + {0x86, 0x02, 0x25, 0xff}: Magenta, + {0xa8, 0x28, 0x63, 0xff}: Magenta, + {0xcb, 0x02, 0x3d, 0xff}: Magenta, + {0x64, 0x07, 0x1a, 0xff}: Magenta, + {0xc0, 0x05, 0x5b, 0xff}: Magenta, {0xa2, 0x7d, 0x4b, 0xff}: Gold, {0x75, 0x55, 0x31, 0xff}: Gold, {0xa6, 0x80, 0x40, 0xff}: Gold, - {0xdb, 0xa5, 0x15, 0xff}: Gold, - {0xb8, 0x91, 0x6e, 0xff}: Gold, {0xe1, 0xd1, 0x9e, 0xff}: Gold, {0xd4, 0xaf, 0x37, 0xff}: Gold, {0xdd, 0xbf, 0x5d, 0xff}: Gold, @@ -410,11 +450,16 @@ var IndexedColorMap = map[color.RGBA]IndexedColor{ {0xe9, 0xd6, 0x97, 0xff}: Gold, {0xe4, 0xcc, 0x7d, 0xff}: Gold, {0xd4, 0xaf, 0x34, 0xff}: Gold, - // {0xcf, 0xb5, 0x3b, 0xff}: Gold, - // {0xc5, 0xb3, 0x58, 0xff}: Gold, + {0xb4, 0x80, 0x12, 0xff}: Gold, {0xbf, 0x9b, 0x30, 0xff}: Gold, {0xe5, 0xc1, 0x00, 0xff}: Gold, {0xcc, 0xac, 0x00, 0xff}: Gold, + {0xc0, 0x8a, 0x3e, 0xff}: Gold, + {0xe8, 0xb4, 0x51, 0xff}: Gold, + {0xef, 0x9a, 0x1d, 0xff}: Gold, + {0xe5, 0xaa, 0x54, 0xff}: Gold, + {0xd5, 0xb9, 0x8a, 0xff}: Gold, + {0xc4, 0x90, 0x44, 0xff}: Gold, } func ColorfulToIndexedColor(actualColor colorful.Color) (result IndexedColor) { @@ -446,7 +491,7 @@ func (m *MediaFile) Resize(width, height int) (result *image.NRGBA, err error) { return nil, err } - return imaging.Resize(img, width, height, imaging.Box), nil + return imaging.Resize(img, width, height, imaging.NearestNeighbor), nil } // Colors returns color information for a media file. diff --git a/internal/photoprism/colors_test.go b/internal/photoprism/colors_test.go index c98d7f2ad..c404cce82 100644 --- a/internal/photoprism/colors_test.go +++ b/internal/photoprism/colors_test.go @@ -16,27 +16,27 @@ func TestMediaFile_Colors_Testdata(t *testing.T) { */ expected := map[string]ColorPerception{ "testdata/sharks_blue.jpg": { - Colors: IndexedColors{0x6, 0x6, 0x5, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4}, - MainColor: 4, - Luminance: LightMap{0x9, 0x8, 0x7, 0x6, 0x6, 0x6, 0x5, 0x5, 0x5}, - Saturation: 14, + Colors: IndexedColors{0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x4, 0x4, 0x6}, + MainColor: 6, + Luminance: LightMap{0x9, 0x7, 0x5, 0x6, 0x5, 0x6, 0x5, 0x5, 0x5}, + Saturation: 15, }, "testdata/cat_black.jpg": { - Colors: IndexedColors{0x1, 0x2, 0x2, 0x2, 0x1, 0x1, 0x3, 0x2, 0x2}, - MainColor: 2, - Luminance: LightMap{0x8, 0x8, 0x8, 0x8, 0x4, 0x6, 0xd, 0xc, 0x8}, + Colors: IndexedColors{0x2, 0x5, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2}, + MainColor: 1, + Luminance: LightMap{0x8, 0xb, 0x9, 0x4, 0x2, 0x6, 0xd, 0xc, 0x3}, Saturation: 2, }, "testdata/cat_brown.jpg": { - Colors: IndexedColors{0x1, 0x2, 0x2, 0x1, 0x2, 0x1, 0x1, 0x1, 0x1}, - MainColor: 2, - Luminance: LightMap{0x5, 0x9, 0x8, 0x7, 0xb, 0x7, 0x3, 0x6, 0x7}, - Saturation: 2, + Colors: IndexedColors{0x1, 0x5, 0x5, 0x2, 0x2, 0x1, 0x1, 0x6, 0x2}, + MainColor: 5, + Luminance: LightMap{0x3, 0x4, 0xa, 0x4, 0x7, 0x2, 0x1, 0x5, 0x6}, + Saturation: 4, }, "testdata/cat_yellow_grey.jpg": { - Colors: IndexedColors{0x1, 0x1, 0x2, 0x1, 0x2, 0x2, 0x1, 0x1, 0xa}, - MainColor: 2, - Luminance: LightMap{0x5, 0x6, 0x8, 0x6, 0x8, 0x8, 0x5, 0x5, 0x6}, + Colors: IndexedColors{0x2, 0x1, 0x2, 0x1, 0x1, 0x5, 0x5, 0x1, 0x5}, + MainColor: 5, + Luminance: LightMap{0x8, 0x5, 0xa, 0x5, 0x2, 0x5, 0x7, 0x1, 0x6}, Saturation: 4, }, } @@ -91,11 +91,11 @@ func TestMediaFile_Colors(t *testing.T) { t.Log(p, err) assert.Nil(t, err) - assert.Equal(t, 2, p.Saturation.Int()) + assert.Equal(t, 5, p.Saturation.Int()) assert.IsType(t, IndexedColors{}, p.Colors) - assert.Equal(t, "grey", p.MainColor.Name()) - assert.Equal(t, IndexedColors{0x1, 0x2, 0x1, 0x2, 0x2, 0x1, 0x1, 0x1, 0x0}, p.Colors) - assert.Equal(t, LightMap{0x5, 0x9, 0x7, 0xa, 0x8, 0x5, 0x5, 0x6, 0x2}, p.Luminance) + assert.Equal(t, "brown", p.MainColor.Name()) + assert.Equal(t, IndexedColors{0x1, 0x3, 0x1, 0x2, 0xe, 0x1, 0x2, 0x2, 0x0}, p.Colors) + assert.Equal(t, LightMap{0x4, 0xf, 0x7, 0xc, 0x4, 0x2, 0x4, 0x3, 0x0}, p.Luminance) } else { t.Error(err) } @@ -108,11 +108,11 @@ func TestMediaFile_Colors(t *testing.T) { t.Log(p, err) assert.Nil(t, err) - assert.Equal(t, 2, p.Saturation.Int()) + assert.Equal(t, 3, p.Saturation.Int()) assert.IsType(t, IndexedColors{}, p.Colors) - assert.Equal(t, "teal", p.MainColor.Name()) - assert.Equal(t, IndexedColors{0x8, 0x8, 0x2, 0x8, 0x2, 0x1, 0x8, 0x1, 0x2}, p.Colors) - assert.Equal(t, LightMap{0x7, 0x7, 0x6, 0x7, 0x7, 0x5, 0x7, 0x6, 0x8}, p.Luminance) + assert.Equal(t, "green", p.MainColor.Name()) + assert.Equal(t, IndexedColors{0x9, 0x9, 0x9, 0x8, 0x9, 0x2, 0x9, 0x2, 0x9}, p.Colors) + assert.Equal(t, LightMap{0x5, 0xa, 0x8, 0x5, 0x8, 0x5, 0x7, 0xa, 0xe}, p.Luminance) } else { t.Error(err) } @@ -125,10 +125,10 @@ func TestMediaFile_Colors(t *testing.T) { t.Log(p, err) assert.Nil(t, err) - assert.Equal(t, 2, p.Saturation.Int()) + assert.Equal(t, 4, p.Saturation.Int()) assert.IsType(t, IndexedColors{}, p.Colors) - assert.Equal(t, "grey", p.MainColor.Name()) - assert.Equal(t, IndexedColors{0x2, 0x1, 0x2, 0x1, 0x1, 0x1, 0x2, 0x1, 0x2}, p.Colors) + assert.Equal(t, "blue", p.MainColor.Name()) + assert.Equal(t, IndexedColors{0x6, 0x6, 0x5, 0x1, 0x1, 0x2, 0x1, 0xf, 0x6}, p.Colors) } else { t.Error(err) } @@ -141,11 +141,11 @@ func TestMediaFile_Colors(t *testing.T) { t.Log(p, err) assert.Nil(t, err) - assert.Equal(t, 2, p.Saturation.Int()) + assert.Equal(t, 5, p.Saturation.Int()) assert.IsType(t, IndexedColors{}, p.Colors) - assert.Equal(t, "grey", p.MainColor.Name()) + assert.Equal(t, "gold", p.MainColor.Name()) - assert.Equal(t, IndexedColors{0x3, 0x2, 0x2, 0x1, 0x2, 0x2, 0x2, 0x2, 0x1}, p.Colors) + assert.Equal(t, IndexedColors{0x3, 0x3, 0x6, 0x1, 0x2, 0x2, 0x5, 0x5, 0x1}, p.Colors) } else { t.Error(err) }