alexh110
March 14th, 2008, 07:34 PM
Does anyone know of a C++ library function that can regularise an irregular waveform?
I need to equalise the width of each pulse, whilst preserving it's amplitude.
Ideally I'd like some source code that can apply this to an image file, and regularise the dominant waveform frequency in each row, such that the waveform maintains a constant frequency across the frame.
JVene
March 17th, 2008, 04:50 PM
I don't think I've ever heard the term regularize (but then I don't get out enough anyway); your definition makes your meaning clear enough.
From your description it sounds like you have square waves of varying amplitudes and pulse widths, and your goal is to process this signal into a fixed pulse width while preserving the amplitude.
If you're not processing square waves then this will be a tad more involved, but I'll assume square waves for the moment.
This also begs the question of how one determines the output pulse width, and your question is a bit vague on the source of the data. Is the source information an image file? I suppose that could be reduced to a minor complication if there's good contrast in the source image, and a clear measurement of the extents of scale.
I'm quite vague on the understanding of rows. This suggests multiple channels of input, but we're left guessing somewhat.
Let's start with the target pulse width. You would need to arrive at some target destination pulse width, perhaps by averaging the various input widths, perhaps by choosing the shortest pulse width in the incoming data, or perhaps you have some arbitrary user selection of the target. Ideally this will be a multiple of the output sample rate (it's more difficult if this isn't strictly applicable). So, I must assume a target sample rate is selected by some such means, let's say it represents a pulse width of 10 samples, whatever a sample length might be.
Now the real shape of your pulse comes to mind - just a positive pulse? Zero, then some value, then zero again? No negative swing typical of audio style signals?
If that assumption is true, then you're simply interested in counting the transitions your source data goes through relative to zero. Any non-zero transition, lasting for various durations, eventually transit back to zero, and remain at zero for some short time before another transit to some non-zero value. You simply count the number of transits of these pulses in the source data, and format the output for the same number of transits for the fixed output duration of your target, dropping the target amplitude to each one, in order.
I'm not aware of this being a typical, useful standard algorithm, but it does 'sound' like an asynchronous data acquisition problem, yet you seem interested in preserving amplitudes, which doesn't support the notion of digital data acquisition. If you're measuring, say, voltage changes, temperature changes or anything else that alters over time, why loose the time index?
Anyway, the problem is actually fairly simple if I've not been to erratic in my description.