Overview
This page will discuss a simple algorithm to unwrap a noisy discrete real waveform transformed under a modulo operation. The algorithm can be implemented as a real-time algorithm on a waveform stream.
Setup
Let be a discrete real waveform sampled from a continuous waveform and for a fixed real constant
, consider its modulo-M waveform
such that
. The algorithm seeks to recover the unwrapped waveform
from the wrapped waveform
up to a constant offset.
Algorithm – (Noiseless Version)
For any given integer , define
. Note that
forms a disjoint partition of the entire real line. This means that for any given term
, there exist a unique modulo level
and the subdivision level
such that
. Furthermore, if
and
are known, the original
can be recovered via the equation
.
In the absence of noise, the modulo level can either change by one level, exactly when the subdivision levels corresponding to two contiguous terms change from between 0 and 2 across two modulo levels. And the continuity of the source waveform prevents the subdivision level from jumping up or down by two steps at once.
This observation allows the correct assignment of the modulo level for any given term up to a constant offset using the following recursive rule:
, if
and
, if
and
, otherwise
The rule can be compactly rewritten as:
In turn, this would allow the correct unwrapping of the modulo waveform up to a constant offset via the relationship .
Algorithm – (Noisy Version)
The level-recovery method presented above may be unsuitable in the presence of a high noise level. If the noise corresponding to a specific term is large enough to make the term jump multiple subdivision levels, the level-recovery method will fail by creating a discontinuity point in the recovered waveform. The modified algorithm described below can safeguard against this type of shortcoming.
Pick an integer-valued scanning window size and initialize the states as follows:
and define to be the majority subdivision level of
.
Then, recover the level sequences of the terms recursively as follows until the window is shifted all the way to the end ():
- Define
by removing the first element of
and appending
.
Once the window is shifted all the way to the right, , recover the level sequences of the terms by using the last window states:
The window size should be carefully chosen by weighing the following trade-off:
- It should be small enough that as the window is shifted from the beginning of the waveform (with the left edge of the window aligned with the first term) to the end of the waveform (with the right edge of the window aligned with the last term), the window correctly traces the general trajectory of the original waveform. If the window size is too wide, it may miss subdivision jumps of the original waveform.
- It should be chosen large enough that the windowed mean subdivision level prevents noisy terms from introducing discontinuity.
Leave a comment