kmeg

package module
v0.0.0-...-152b127 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: MIT Imports: 6 Imported by: 0

README

KMEG

An image format based on K-Means algorithm color quantization to compress images.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToRGBA

func ConvertToRGBA(rgb *RGBImage) *image.RGBA

ConvertToRGBA converts from RGB (Red Green Blue ) format to RGB (Red Green Blue Alpha Format) In RGBA format,all Pixels are stored in a single sequence. Each slice of 4 consecutive elements represent a single pixel RGBA values. A constant alpha level of 255 is appended to each pixel's RGB value

func Encode

func Encode(w io.Writer, kmg *Kmeg) error

Encode : Serialize kmeg representation into kmeg binary format

func MakeTrainingSet

func MakeTrainingSet(data [][]uint8) [][]float32

MakeTrainingSet create a training set (samples) from the image pixel array

Types

type Kmeg

type Kmeg struct {
	Quantlevels [][]uint8
	Labels      []int
	Dx          int
	Dy          int
}

Kmeg Struct to hold the Kmeg information

func Decode

func Decode(r io.Reader) (*Kmeg, error)

Decode : Deserialize the kmeg binary format to in-memory Kmeg structure

func Deflate

func Deflate(km *kmeans.KMeans, dx int) (*Kmeg, error)

Deflate Take in the kmeans object (Which has image information as the training samples) and return Kmeg representation

type RGBImage

type RGBImage struct {
	Pix [][]uint8
	Dx  int
	Dy  int
}

RGBImage :holds data for pixels of image in RGB format Pixels is in matrix form - each row holds color levels of a single pixel

func ConvertToRGB

func ConvertToRGB(img image.Image) *RGBImage

ConvertToRGB :converts from RGBA (Red Green Blue Alpha ) format to RGB (Red Green Blue Format) Drops Alpha value from the color vector (color vector is of length 3 for RGB vs 4 in RGBA)

func Inflate

func Inflate(kmeg *Kmeg) *RGBImage

Inflate returns RGBImage representation from the kmeg representation

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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