Documentation ¶
Index ¶
- Variables
- func CalculatePalette(obs clusters.Observations, nColors int) (clusters.Clusters, error)
- func ColorsFromClusters(cs clusters.Clusters) []colorful.Color
- func ImageToObservation(img image.Image) clusters.Observations
- func OpenImage(imgPath string) (image.Image, error)
- func WriteHTML(imgPath string, outFileName string, colors []colorful.Color) error
- func WriteImage(imgPath string, outFileName string, colors []colorful.Color) error
- type ColorLab
- type Palette
Constants ¶
This section is empty.
Variables ¶
var DeltaThreshold = 0.05
Controls delta threshold for k-means iterations (stops iterating when less than N percent points changed cluster assignment)
Functions ¶
func CalculatePalette ¶
Extracts a given number of colors (as cluster centers) from Observations through naive k-Means clustering
func ColorsFromClusters ¶
Converts Clusters centers to a color palette of a given number of colors. Each color gets 3 center values as floats (L*, a* and b* - the cluster space for an image is 3-dimensional)
func ImageToObservation ¶
func ImageToObservation(img image.Image) clusters.Observations
Extracts Observations from a given Image. Each pixel is converted to colorful.Color, then unpacked in its raw L*, a* and b* values as floats
func WriteHTML ¶
Creates an HTML document containing the original image and the color palette through a template with predefined layout
func WriteImage ¶
Serializes a list of colors (palette) into an image with a defined layout, containing the original image and the palette
Types ¶
type ColorLab ¶
type ColorLab struct {
L, A, B float64
}
Represent color as lightness (L), green (-) to red (+) (A) and blue (-) to yellow (+) (B). Using floats instead of converting to other color space makes computing distance much faster, while keeping the computations accurate as L*a*b* values are represented linearly. ColorLab implements clusters.Observation
func (ColorLab) Coordinates ¶
func (c ColorLab) Coordinates() clusters.Coordinates
Returns coordinates as a Coordinates object (slice of float64's)