Skip to content

dy/multiscale-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multiscale-array unstable

Create multiple scales representation for an array (see scale-space for the concept). It is simplest form of convolution with resampling, where the upper level is perfectly 2 times less than the lower level, with each value made up of two values from the previous level. Similar to mipmaps, but 1d.

npm install multiscale-array

const multiscale = require('multiscale-array')

let data = Array(1e7)
let scales = multiscale(data, {
	//max group of samples
	maxScale: 65536,

	//how to form upper level from two samples of lower level
	reduce: (left, right, i, level) => .5*left + .5*right
})

//recalculate scales for the data range, this is O(2N)
scales.update(from?, to?)

//replace old data with the new data and recalc scales for it
scales.update(newData, from?, to?)

//get data for the scale 2⁴
let scaleData = scales[4];

//subset scales, i.e. slice all scales, but mutable (!)
scales.subset(from, to)

About

Multiscale representation of an array

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages