Skip to content

Extract the dominant color or a representative color palette from an image

License

Notifications You must be signed in to change notification settings

thomas-bouvier/palette-extractor

Repository files navigation

palette-extractor

Go Report Card GoDoc

This program extracts the dominant color or a representative color palette from an image.

Usage

Here's a simple example, where we build a 5 color palette:

package main

import (
	"fmt"
	"github.com/thomas-bouvier/palette-extractor"
)

func main() {
	// Creating the extractor object
	extractor := extractor.NewExtractor("image.png", 10)

	// Displaying the top 5 dominant colors of the image
	fmt.Println(extractor.GetPalette(5))
}

You can find the complete documentation on GoDoc.

Example

The following image has been used for this example:

Example

The program will give the following output when used with the image above:

[[234 231 230] [208 24 44] [59 41 37] [158 149 145] [145 126 114]]

Thanks

Many thanks to Lokesh Dhakar for his original work and Shipeng Feng for his implementation.

About

Extract the dominant color or a representative color palette from an image

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages