kmeans

package
v0.0.0-...-1ed8403 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Centroid

type Centroid struct {
	Color colorful.Color
}

Centroid type is a RGBA point

type Color

type Color struct {
	Color   colorful.Color
	Cluster *Centroid
}

Color type is a RGBA point (of a pixel) and the centroid nearest to the color

type Image

type Image struct {
	ImportedImage image.Image
	Colors        []Color
	Centroids     []*Centroid
}

Image type is a decomposed image

func Create

func Create(filename string, n int) (*Image, error)

Create returns a new image when provided with a filename and the number of centroids desired

func CreateAndRun

func CreateAndRun(filename string, centroids int, iterations int) (*Image, error)

CreateAndRun is a combination of the Create and Run functions. It runs k-means on the supplied image - provided by name in a relative to the executable when given the number of centroids and iterations desired

func (*Image) CreateColorImage

func (m *Image) CreateColorImage() error

CreateColorImage recolors the original image provided using each pixel's nearest centroid

func (*Image) CreateColorSwatch

func (m *Image) CreateColorSwatch() error

CreateColorSwatch creates a color swatch from the Image type provided the color swatch is a color list of the centroids (each centroid is 60px x 60px)

func (*Image) PrintCentroids

func (m *Image) PrintCentroids()

PrintCentroids prints out the current centroids to Standard Output

func (*Image) Run

func (m *Image) Run(maxIterations int)

Run runs the update function until convergence or max iterations is reached

func (*Image) Update

func (m *Image) Update()

Update is the main loop of the k-means algorithm

Jump to

Keyboard shortcuts

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