edlinorg / prominentcolor Goto Github PK
View Code? Open in Web Editor NEWgolang package to find the K most dominant/prominent colors in an image
License: BSD 3-Clause "New" or "Revised" License
golang package to find the K most dominant/prominent colors in an image
License: BSD 3-Clause "New" or "Revised" License
I want ignore some color in process, such as white, How do I go to do?
Hi,
I'm found a problem while i try to check dominant color on completely black image like the one below.
This is my code:
cols := prominentcolor.KmeansWithAll(3, img, prominentcolor.ArgumentNoCropping, 80, []prominentcolor.ColorBackgroundMask{})
col := cols[0].AsString()
fmt.Println("#"+col)
This is the output that i recive:
2018/01/21 16:31:05 Failed, k larger than len(allColors): 3 vs 0
panic: invalid argument to Intn
goroutine 1 [running]:
math/rand.(*Rand).Intn(0xc042072270, 0x0, 0x3)
{GO_PATH}/src/math/rand/rand.go:142 +0xa3
math/rand.Intn(0x0, 0x0)
{GO_PATH}/src/math/rand/rand.go:277 +0x3e
github.com/EdlinOrg/prominentcolor.kmeansPlusPlusSeed(0x3, 0x8, 0x614528, 0x0, 0x0, 0x0, 0x0, 0x0)
{GO_PATH}/src/github.com/EdlinOrg/prominentcolor/kmeans.go:387 +0xd7
github.com/EdlinOrg/prominentcolor.kmeansSeed(0x3, 0x614528, 0x0, 0x0, 0x8, 0x0, 0xc0429de3c0, 0x5e3700)
{GO_PATH}/src/github.com/EdlinOrg/prominentcolor/kmeans.go:357 +0x18e
github.com/EdlinOrg/prominentcolor.KmeansWithAll(0x3, 0x5e3700, 0xc0429de3c0, 0x8, 0x50, 0xc04296dec4, 0x3, 0x3, 0x501daa, 0xc042002020, ...)
{GO_PATH}/src/github.com/EdlinOrg/prominentcolor/kmeans.go:111 +0x104
github.com/EdlinOrg/prominentcolor.KmeansWithArgs(0x8, 0x5e3700, 0xc0429de3c0, 0xc0429de3c0, 0x0, 0x0)
{GO_PATH}/src/github.com/EdlinOrg/prominentcolor/kmeans.go:101 +0x104
main.main()
{PROJECT_PATH}/main.go:38 +0x1d1
At the moment i moved to jakekausler/prominentcolor@7583347 a fork of this project that return errors instead of panic, so i can handle exceptions.
How can i have #000000
instead of panic?
Hi,
Can you please make ColorRGB
to implement golang color.Color interface?
It would be great to get a v1 tagged release on this project :)
The following image produce the incorrect result:
Failed, no non-alpha pixels found (either fully transparent image, or the ColorBackgroundMask removed all pixels)
resizeSize := uint(prominentcolor.DefaultSize)
bgmasks := []prominentcolor.ColorBackgroundMask{prominentcolor.MaskWhite}
colours, err := prominentcolor.KmeansWithAll(
5, img, prominentcolor.ArgumentNoCropping|prominentcolor.ArgumentAverageMean|prominentcolor.ArgumentDebugImage,
resizeSize, bgmasks)
I believe all single color images have the same problem
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.