NeuQuant | Image Quantization Library (image-q)

### Hierarchy

- NeuQuant

### Implements

- IPaletteQuantizer

## Index

### Constructors

- constructor

### Properties

- _bias
- _distance
- _freq
- _network
- _networkSize
- _pointArray
- _radPower
- _sampleFactor
- _alphaBiasShift
- _alphaRadBias
- _alphaRadBiasShift
- _beta
- _betaGamma
- _betaShift
- _gamma
- _gammaShift
- _initAlpha
- _initialBias
- _initialBiasShift
- _minpicturebytes
- _nCycles
- _prime1
- _prime2
- _prime3
- _prime4
- _radBias
- _radBiasShift
- _radiusBias
- _radiusBiasShift
- _radiusDecrease

### Methods

- _alterNeighbour
- _alterSingle
- _buildPalette
- _contest
- _init
- _learn
- quantize
- sample

## Constructors

### constructor

- new NeuQuant(colorDistanceCalculator: IDistanceCalculator, colors?: number): NeuQuant

- - Defined in palette/neuquant/neuquant.ts:150

  #### Parameters

  - ##### colorDistanceCalculator: IDistanceCalculator

  - ##### Default value colors: number = 256

  #### Returns NeuQuant

## Properties

### Private _bias

_bias: number[]

- Defined in palette/neuquant/neuquant.ts:149

### Private _distance

_distance: IDistanceCalculator

- Defined in palette/neuquant/neuquant.ts:150

### Private _freq

_freq: number[]

- Defined in palette/neuquant/neuquant.ts:146

### Private _network

_network: Neuron[]

- Defined in palette/neuquant/neuquant.ts:139

### Private _networkSize

_networkSize: number

- Defined in palette/neuquant/neuquant.ts:138

### Private _pointArray

_pointArray: Point[]

- Defined in palette/neuquant/neuquant.ts:137

### Private _radPower

_radPower: number[]

- Defined in palette/neuquant/neuquant.ts:143

### Private _sampleFactor

_sampleFactor: number

- Defined in palette/neuquant/neuquant.ts:142

sampling factor 1..30

### Static Private _alphaBiasShift

_alphaBiasShift: number

- Defined in palette/neuquant/neuquant.ts:126

### Static Private _alphaRadBias

_alphaRadBias: number

- Defined in palette/neuquant/neuquant.ts:135

### Static Private _alphaRadBiasShift

_alphaRadBiasShift: number

- Defined in palette/neuquant/neuquant.ts:134

### Static Private _beta

_beta: number

- Defined in palette/neuquant/neuquant.ts:107

### Static Private _betaGamma

_betaGamma: number

- Defined in palette/neuquant/neuquant.ts:110

### Static Private _betaShift

_betaShift: number

- Defined in palette/neuquant/neuquant.ts:106

### Static Private _gamma

_gamma: number

- Defined in palette/neuquant/neuquant.ts:105

### Static Private _gammaShift

_gammaShift: number

- Defined in palette/neuquant/neuquant.ts:102

### Static Private _initAlpha

_initAlpha: number

- Defined in palette/neuquant/neuquant.ts:129

### Static Private _initialBias

_initialBias: number

- Defined in palette/neuquant/neuquant.ts:101

### Static Private _initialBiasShift

_initialBiasShift: number

- Defined in palette/neuquant/neuquant.ts:98

### Static Private _minpicturebytes

_minpicturebytes: number

- Defined in palette/neuquant/neuquant.ts:92

### Static Private _nCycles

_nCycles: number

- Defined in palette/neuquant/neuquant.ts:95

### Static Private _prime1

_prime1: number

- Defined in palette/neuquant/neuquant.ts:88

### Static Private _prime2

_prime2: number

- Defined in palette/neuquant/neuquant.ts:89

### Static Private _prime3

_prime3: number

- Defined in palette/neuquant/neuquant.ts:90

### Static Private _prime4

_prime4: number

- Defined in palette/neuquant/neuquant.ts:91

### Static Private _radBias

_radBias: number

- Defined in palette/neuquant/neuquant.ts:133

### Static Private _radBiasShift

_radBiasShift: number

- Defined in palette/neuquant/neuquant.ts:132

### Static Private _radiusBias

_radiusBias: number

- Defined in palette/neuquant/neuquant.ts:118

### Static Private _radiusBiasShift

_radiusBiasShift: number

- Defined in palette/neuquant/neuquant.ts:115

### Static Private _radiusDecrease

_radiusDecrease: number

- Defined in palette/neuquant/neuquant.ts:121

## Methods

### Private _alterNeighbour

- _alterNeighbour(rad: any, i: any, b: any, g: any, r: any, al: any): void

- - Defined in palette/neuquant/neuquant.ts:267

  Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|]

  #### Parameters

  - ##### rad: any

  - ##### i: any

  - ##### b: any

  - ##### g: any

  - ##### r: any

  - ##### al: any

  #### Returns void

### Private _alterSingle

- _alterSingle(alpha: any, i: any, b: any, g: any, r: any, a: any): void

- - Defined in palette/neuquant/neuquant.ts:309

  Move neuron i towards biased (b,g,r) by factor alpha

  #### Parameters

  - ##### alpha: any

  - ##### i: any

  - ##### b: any

  - ##### g: any

  - ##### r: any

  - ##### a: any

  #### Returns void

### Private _buildPalette

- _buildPalette(): Palette

- - Defined in palette/neuquant/neuquant.ts:253

  #### Returns Palette

### Private _contest

- _contest(b: any, g: any, r: any, al: any): number

- - Defined in palette/neuquant/neuquant.ts:333

  Search for biased BGR values description: finds closest neuron (min dist) and updates freq finds best neuron (min dist-bias) and returns position for frequently chosen neurons, freq[i] is high and bias[i] is negative bias[i] = _gamma*((1/this._networkSize)-freq[i])

  Original distance equation: dist = abs(dR) + abs(dG) + abs(dB)

  #### Parameters

  - ##### b: any

  - ##### g: any

  - ##### r: any

  - ##### al: any

  #### Returns number

### Private _init

- _init(): void

- - Defined in palette/neuquant/neuquant.ts:172

  #### Returns void

### Private _learn

- _learn(): void

- - Defined in palette/neuquant/neuquant.ts:189

  Main Learning Loop

  #### Returns void

### quantize

- quantize(): Palette

- - Defined in palette/neuquant/neuquant.ts:165

  #### Returns Palette

### sample

- sample(pointBuffer: PointContainer): void

- - Defined in palette/neuquant/neuquant.ts:161

  #### Parameters

  - ##### pointBuffer: PointContainer

  #### Returns void

Generated using TypeDoc