Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Symmetronic committed Apr 7, 2023
1 parent d2abdbe commit 7dcdc8a
Showing 1 changed file with 42 additions and 59 deletions.
101 changes: 42 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Build Status](https://github.com/Symmetronic/discrete-wavelets/workflows/build/badge.svg?branch=main)](https://github.com/Symmetronic/discrete-wavelets/actions?query=workflow%3Abuild+branch%3Amain) [![Coverage Status](https://coveralls.io/repos/github/Symmetronic/discrete-wavelets/badge.svg?branch=main)](https://coveralls.io/github/Symmetronic/discrete-wavelets?branch=main) [![GitHub License](https://img.shields.io/github/license/Symmetronic/discrete-wavelets)](https://github.com/Symmetronic/discrete-wavelets/blob/main/LICENSE) [![NPM Version](https://img.shields.io/npm/v/discrete-wavelets)](https://www.npmjs.com/package/discrete-wavelets) [![Monthly Downloads](https://img.shields.io/npm/dm/discrete-wavelets)](https://npmcharts.com/compare/discrete-wavelets?minimal=true)

**This library is no longer actively maintained. This means that no new functionality or documentation is added.**

# Discrete Wavelets

A [Discrete Wavelet Transform (DWT)](https://en.wikipedia.org/wiki/Discrete_wavelet_transform) library for the web.
Expand Down Expand Up @@ -30,15 +32,15 @@ The library uses the following types:

The following values for `PaddingMode` are supported at the moment:

Name | Value | Description
----------------------|-------------------|------------------------------------
Zero Padding | `'zero'` | Adding zeros.
Constant Padding | `'constant'` | Replication of border values.
Symmetric Padding | `'symmetric'` | Mirroring of samples.
Reflect Padding | `'reflect'` | Reflecting of samples.
Periodic Padding | `'periodic'` | Treating signal as a periodic one.
Smooth Padding | `'smooth'` | Signal extended as a straight line.
Antisymmetric Padding | `'antisymmetric'` | Mirroring and negation of samples.
| Name | Value | Description |
| --------------------- | ----------------- | ----------------------------------- |
| Zero Padding | `'zero'` | Adding zeros. |
| Constant Padding | `'constant'` | Replication of border values. |
| Symmetric Padding | `'symmetric'` | Mirroring of samples. |
| Reflect Padding | `'reflect'` | Reflecting of samples. |
| Periodic Padding | `'periodic'` | Treating signal as a periodic one. |
| Smooth Padding | `'smooth'` | Signal extended as a straight line. |
| Antisymmetric Padding | `'antisymmetric'` | Mirroring and negation of samples. |

You can get a list of the supported signal extension modes:

Expand All @@ -51,33 +53,33 @@ console.log(wt.Modes.modes);

The following `Wavelet` types are supported at the moment:

Wavelet | Aliases
------------------------------------------------------------------|---------------------------
Daubechies 1 / [Haar](https://de.wikipedia.org/wiki/Haar-Wavelet) | `'db1'`, `'D2'`, `'haar'`
Daubechies 2 | `'db2'`, `'D4'`
Daubechies 3 | `'db3'`, `'D6'`
Daubechies 4 | `'db4'`, `'D8'`
Daubechies 5 | `'db5'`, `'D10'`
Daubechies 6 | `'db6'`, `'D12'`
Daubechies 7 | `'db7'`, `'D14'`
Daubechies 8 | `'db8'`, `'D16'`
Daubechies 9 | `'db9'`, `'D18'`
Daubechies 10 | `'db10'`, `'D20'`
| Wavelet | Aliases |
| ----------------------------------------------------------------- | ------------------------- |
| Daubechies 1 / [Haar](https://de.wikipedia.org/wiki/Haar-Wavelet) | `'db1'`, `'D2'`, `'haar'` |
| Daubechies 2 | `'db2'`, `'D4'` |
| Daubechies 3 | `'db3'`, `'D6'` |
| Daubechies 4 | `'db4'`, `'D8'` |
| Daubechies 5 | `'db5'`, `'D10'` |
| Daubechies 6 | `'db6'`, `'D12'` |
| Daubechies 7 | `'db7'`, `'D14'` |
| Daubechies 8 | `'db8'`, `'D16'` |
| Daubechies 9 | `'db9'`, `'D18'` |
| Daubechies 10 | `'db10'`, `'D20'` |

## API

The library offers the following functions:

- Discrete Wavelet Transform (DWT)
- [dwt](#dwt): Single level Discrete Wavelet Transform.
- [wavedec](#wavedec): 1D wavelet decomposition. Transforms data by calculating coefficients from input data.
- [dwt](#dwt): Single level Discrete Wavelet Transform.
- [wavedec](#wavedec): 1D wavelet decomposition. Transforms data by calculating coefficients from input data.
- Inverse Discrete Wavelet Transform (IDWT)
- [idwt](#idwt): Single level inverse Discrete Wavelet Transform.
- [waverec](#waverec): 1D wavelet reconstruction. Inverses a transform by calculating input data from coefficients.
- [idwt](#idwt): Single level inverse Discrete Wavelet Transform.
- [waverec](#waverec): 1D wavelet reconstruction. Inverses a transform by calculating input data from coefficients.
- Other
- [energy](#energy): Calculates the energy as sum of squares of an array of data or coefficients.
- [maxLevel](#maxLevel): Determines the maximum level of useful decomposition.
- [pad](#pad): Extends a signal with a given padding mode.
- [energy](#energy): Calculates the energy as sum of squares of an array of data or coefficients.
- [maxLevel](#maxLevel): Determines the maximum level of useful decomposition.
- [pad](#pad): Extends a signal with a given padding mode.

### dwt

Expand All @@ -96,7 +98,7 @@ Single level Discrete Wavelet Transform.
#### Example

```javascript
var coeffs = wt.dwt([1, 2, 3, 4], 'haar');
var coeffs = wt.dwt([1, 2, 3, 4], "haar");

console.log(coeffs);
// expected output: Array [[2.1213203435596425, 4.9497474683058326], [-0.7071067811865475, -0.7071067811865475]]
Expand All @@ -120,13 +122,13 @@ console.log(coeffs);
#### Example

```javascript
var coeffs = wt.wavedec([1, 2, 3, 4], 'haar');
var coeffs = wt.wavedec([1, 2, 3, 4], "haar");

console.log(coeffs);
// expected output: Array [[4.999999999999999], [-1.9999999999999993], [-0.7071067811865475, -0.7071067811865475]]
```

*Be aware that due to floating point imprecision the result diverges slightly from the analytical solution `[[5], [-2], [-0.7071067811865475, -0.7071067811865475]]`*
_Be aware that due to floating point imprecision the result diverges slightly from the analytical solution `[[5], [-2], [-0.7071067811865475, -0.7071067811865475]]`_

### idwt

Expand All @@ -148,14 +150,14 @@ Single level inverse Discrete Wavelet Transform.
var rec = wt.idwt(
[(1 + 2) / Math.SQRT2, (3 + 4) / Math.SQRT2],
[(1 - 2) / Math.SQRT2, (3 - 4) / Math.SQRT2],
'haar'
"haar"
);

console.log(rec);
// expected output: Array [0.9999999999999999, 1.9999999999999996, 2.9999999999999996, 3.9999999999999996]
```

*Be aware that due to floating point imprecision the result diverges slightly from the analytical solution `[1, 2, 3, 4]`*
_Be aware that due to floating point imprecision the result diverges slightly from the analytical solution `[1, 2, 3, 4]`_

### waverec

Expand All @@ -173,16 +175,13 @@ console.log(rec);
#### Example

```javascript
var data = wt.waverec(
[[5], [-2], [-1 / Math.SQRT2, -1 / Math.SQRT2]],
'haar'
);
var data = wt.waverec([[5], [-2], [-1 / Math.SQRT2, -1 / Math.SQRT2]], "haar");

console.log(data);
// expected output: Array [0.9999999999999999, 1.9999999999999996, 2.999999999999999, 3.999999999999999]
```

*Be aware that due to floating point imprecision the result diverges slightly from the analytical solution `[1, 2, 3, 4]`*
_Be aware that due to floating point imprecision the result diverges slightly from the analytical solution `[1, 2, 3, 4]`_

### energy

Expand All @@ -199,14 +198,10 @@ Calculates the energy as sum of squares of an array of data or coefficients.
#### Examples

```javascript
console.log(
wt.energy([-1, 2, 6, 1])
);
console.log(wt.energy([-1, 2, 6, 1]));
// expected output: 42

console.log(
wt.energy([[5], [-2], [-1 / Math.SQRT2, -1 / Math.SQRT2]])
);
console.log(wt.energy([[5], [-2], [-1 / Math.SQRT2, -1 / Math.SQRT2]]));
// expected output: 30
```

Expand All @@ -226,14 +221,14 @@ Determines the maximum level of useful decomposition.
#### Examples

```javascript
var maxLevel = wt.maxLevel(4, 'haar');
var maxLevel = wt.maxLevel(4, "haar");

console.log(maxLevel);
// expected output: 2
```

```javascript
var maxLevel = wt.maxLevel(1024, 'haar');
var maxLevel = wt.maxLevel(1024, "haar");

console.log(maxLevel);
// expected output: 10
Expand All @@ -256,7 +251,7 @@ Extends a signal with a given padding mode.
#### Example

```javascript
var pad = wt.pad([42, 51], [2, 1], 'zero');
var pad = wt.pad([42, 51], [2, 1], "zero");

console.log(pad);
// expected output: Array [0, 0, 42, 51, 0]
Expand All @@ -271,15 +266,3 @@ console.log(pad);
- `npm run test:prod`: Run linting and generate coverage
- `npm run build`: Generate bundles and typings, create docs
- `npm run lint`: Lints code

## This library in action

An exemplary application with code using this library can be found at [https://symmetronic.github.io/covid-19-dwt-analysis/](https://symmetronic.github.io/covid-19-dwt-analysis/)

## Related project

[Symmetronic Scaleogram](https://github.com/Symmetronic/strc-scaleogram) is a web component that allows to easily create a [scaleogram visualization](https://en.wikipedia.org/wiki/Spectrogram) from wavelet coefficients.

## Contributing

Pull requests are welcome! Please include new tests for your code and make sure that all tests succeed running `npm test`.

0 comments on commit 7dcdc8a

Please sign in to comment.