seed

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package seed provides utilities for deterministic seed generation for k-means clustering. This is used by input plugins that process images to ensure reproducible color extraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(img image.Image, imagePath string, config Config) (int64, error)

Calculate determines the seed value based on the seed mode. img: the image to extract seed from (required for ModeContent) imagePath: the path to the image file (required for ModeFilepath) config: seed configuration

func CalculateContentSeed

func CalculateContentSeed(img image.Image) (int64, error)

CalculateContentSeed generates a deterministic seed from image content. This hashes the pixel data to create a seed that's consistent for the same image content, regardless of filename or location.

func CalculateFilepathSeed

func CalculateFilepathSeed(imagePath string) (int64, error)

CalculateFilepathSeed generates a deterministic seed from the absolute file path. This creates a seed that's consistent for the same file path, allowing different images at the same location to produce different results.

func GenerateRandomSeed

func GenerateRandomSeed() int64

GenerateRandomSeed generates a non-deterministic random seed.

Types

type Config

type Config struct {
	Mode  Mode   // Seed mode
	Value *int64 // Seed value (only used when Mode is ModeManual)
}

Config holds configuration for seed generation.

type Mode

type Mode string

Mode determines how the random seed for k-means clustering is generated.

const (
	// ModeContent generates seed from image content hash (default, deterministic by content).
	ModeContent Mode = "content"
	// ModeFilepath generates seed from absolute file path hash (deterministic by path).
	ModeFilepath Mode = "filepath"
	// ModeManual uses a user-provided seed value.
	ModeManual Mode = "manual"
	// ModeRandom uses non-deterministic random seed (varies each run).
	ModeRandom Mode = "random"
)

func ParseMode

func ParseMode(s string) (Mode, error)

ParseMode converts a string to a Mode. Returns an error if the string is not a valid mode.

func ValidModes

func ValidModes() []Mode

ValidModes returns a list of valid seed modes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL