texts: Some subtleties in the PSD of digitally generated noise with $S_X(f) = A(f)$

texts:
I understand that the title is not the most descriptive, but I didn't know how to describe my problem in a more literal way. The situation is as follows:

I wanted to digitally generate noise with an arbitrary power spectral density $S(f) = A(f)$. To do this, I generated a white noise series $X$ with $S_X(f) = 1$ by simply taking $n$ independent samples from a Gaussian distribution with $\sigma = 1$ and then digitally filter them with filter amplitudes $F(f) = \sqrt{A(f)}$. One can easily show that this leads to $S_Y(f) = A(f)$, where $Y$ is the series resulting from filtering $X$ with $F(f)$.

I have done this in practice using Mathematica's FrequencySamplingFilterKernel and ListConvolve. For this to work one needs to know the desired $A(f)$ of course, which in my example I wanted to be a Lorentzian of center frequency $f_0$ and full-width-at-full-maximum b given by
\begin{equation}
A(f) = \frac{1}{1+\left(\frac{f-f_0}{b}\right)^2}\end{equation}

So I took this equation, sampled it, created filter amplitudes and filtered the white noise. The resulting PSD $S_Y(f)$ looked as desired when analysed with Welch's Method.

But now I am interested in a subtlety in the above. As has been pointed out the me, the above Lorentzian is not a proper power spectral density of a real signal; $A(f) \neq A(-f)$. But the method still worked, in the sense that I did not get any complex valued data, and that the periodogram showed the correct spectrum at positive frequencies. So my question is, using this method, what happened at the negative frequencies? Did I essentially create a PSD for which
\begin{equation}
A(f) = \frac{1}{1+\left(\frac{f-f_0}{b}\right)^2} + \frac{1}{1+\left(\frac{f+f_0}{b}\right)^2}\end{equation}
or perhaps instead it is more like
\begin{equation}
A(f) = \frac{1}{1+\left(\frac{f-\textrm{sgn}[f]f_0}{b}\right)^2}\end{equation}
where $\mathrm{sgn}[\dots]$ is the sign function.

Those are the only reasonable scenario's I can think of, resulting from the above. They are very similar in behaviour, except around $f=0$, Here the second one has a discontinuous derivative at $f=0$; is that even physically possible?

My question is thus what PSD I ended up with; one of the two I mentioned above or even a third one?


texts: Spectrogram Time Resolution with Overlap

texts: I understand that the time resolution of a spectrogram with no overlap is the sampling frequency divided by the window length. How does this change with, say, 50% overlap? Does this double the time resolution? If so, why can't I just have a large overlap and window length to achieve both high time and frequency resolution?


texts: Using Neural Network for locating shifting resonant frequencies

texts:
I have multiple FFT's taken from a sample at different pressures, through different analysis I can see that the resonant frequencies are shifting in the spectrum for each FFT at a different pressure.
Using conventional peak tracking has been difficult as the peaks increase/decrease in magnitude within the FFT as well as shifting in the spectrum.
Is it possible for a neural network to 'detect'/'pick out' these frequency values?
Any help or guidance is appreciated :)
Thanks!


texts: Best way to measure effectiveness of discrete wavelet denoising?

texts:
I am using matlab wavelet toolbox to denoise physiological signals, I am plotting the denoised signal on top of the original noisy signal and making sure spikes were not removed as a measure of effectiveness as well as plotting the FFT of the two signals (original and denoised).
Is this a correct way to check my results of DWT denoising?
I saw some paper using mean squared error and SNR as a check.


texts: how to find sample rate of sum of 2 cos signals

texts:
I have an exercise to find a sample rate of that signal:

while the filter is:

while A << 1.
I need to set the sampling rate so that at the output of the filter I'll get s[n] and reduce v[n] according to A.
can someone give me a guidance?
thanks alot


texts: Change of bin magnitude when phase of signal changes when doing FFT?

texts:
I am working on an implementation in which I need to apply an FFT to determine which of 4 frequencies are present in a signal.

I am doing a 64 point FFT on a buffer which only is partly filled (the remainder of the buffer is zero-ed).

When looking at the screenshots of the signal in the time domain, you will notice that the signal is roughly the same in each screenshot, but it has different phase in each screenshot.

When looking at the screenshots of the FFT of the two versions of the signal, you will notice that the magnitude for bin 4, which corresponds to the signal frequency, is 874.83 in one of the screenshots but 366.94 in the other, even though the only difference between the two versions of the signal is a phase difference (?)

I don't understands why this happens and how to deal with this. I am generating the signal myself and want to make sure that phase doesn't play a role here. When the signals are more or less the same in amplitude, I would expect their magnitude after calculating the FFT to stay the same.

In case you need this information, the sampling frequency is 7800 Hz and the actual frequency involved is 487.5 Hz which is exactly 7800/64*4, or the start of bin 4.

In the screenshots of the FFT, the magnitude data is plotted upside down (i.e. zero is the top of the screenshot).

Can anyone please shed some light on this? Thanks for helping!
B


texts:
if i have some random signals (sampling rate = 10Hz, 0.1s per data)

Using python library i transformed it to power spectral density

power spectral density forms = f, psd (using mlab.psd)

I'm really curious about f....

If f is 0.01, is it really means 0.01Hz or 0.1Hz(10Hz * 0.01Hz) in signal??

I confused about this conception

Is it relevant to sampling rate and psd frequency?

I'm really thank you for your help!


texts: Simulating analog filter using convolution or converting with fft

texts:
My task is simple; I want to simulate analog low-pass filtering of an input signal, using Python. Note that the input signal is an array of values, not an analytical function.

My first question is if it simply is possible? If so, where is the line drawn between making a digital (FIR/IIR) filter and simulating an analog filter?

My second question is how I, in python, can make two equivalent simulations, using convolution in one, and converting the input signal to frequency domain in the other. Convolution is used in the link below, and it would help me a lot to see how exactly the same thing would be done by instead using fft (even though I think it's using an FIR filter, not simulating an analog filter).

http://glowingpython.blogspot.nl/2012/02/convolution-with-numpy.html

Thanks a lot in advance!


texts: Where is the mother wavelet defined in the Fast Wavelet Transform?

texts:
Referring to the Fast Wavelet Transform, this transform is implemented as a QMF filter bank. This algorithm consists of high/low pass filtering and subsampling. However, a wavelet transform is typically defined by the mother wavelet - the master basis function that is shifted and scaled.
How exactly does this fast wavelet transform define the mother wavelet? I don't see any mentioning of it.


texts: Confused over Stopband attenuation and stopband ripple

texts:
I have designed this bandstop filter to a desired specification:

Stopband attenuation = 40db
Passband ripple = 2db
etc ...

I understand that the stopband ripple can be given by the following:

Stopband ripple = −20log10(δs)
40 = −20log10(δs)
δs=0.01

therefore stop-band ripple δs = 0.01. where I am confused is how this value can be converted into dB so that it can be compared to the stop-band ripple seen in the MATLAB simulation (which is in dB). 40dB is the stopband attenuation, not the stopband ripple (or is it?). the simulation is showing a stopband ripple of around 32dB.... is the stopband attenuated and ripple with same ? what am I missing ?

thank you for your time


texts: Best reference for object size estimation in an image

texts:
I'm working on a project where I need to measure the size of a 2D object on a flat surface from an image. I have total freedom to create a reference with any shape and size.

The camera I am using is the raspberry pi cam.

My question is simple: what is the best reference to use?

EDIT:

Ended up using this thanks to Peter K..


texts: Finding audio "tics" in stereo wav files using python

texts:
I have thousands of audio files that I want to "batch" process searching for audio tics.  This is easily done using a DAW but that requires opening each file independently, searching for the tic (visually looking at the waveform or listening to the file play), and then cleaning the tic with signal processing tools within the DAW.  However, this approach is extremely time consuming.

I'd like to write a program using python to process all of the files and provide candidate files that contain tics in the audio.  I've been researching the web and found tons of references for plotting frequencies using fft after reading in the wav file but I don't want to plot the data I want to examine it in the program to determine if there is an audio tic (or potential tic) present.

Any help or ideas would be deeply appreciated.


texts: Optimal measurement model for Kalman in Augmented Reality

texts:
I am developing an augmented reality SDK that uses Kalman for tracking a planar marker. My state is composed of 3D position, a quaternion, velocity and angular velocity.

\begin{bmatrix}{\vec{p}}\\{\vec{q}}\\{\vec{v}}\\{\vec{\omega }}\end{bmatrix}

For some reason Kalman is not tracking properly. I think that the problem is our measurement model.

We use points (we tried 4 and 8) detected in the real-world marker (proyected points) as measurements $ z_k$. Kalman predicted measurements $h(x_k^-)$ are the matches of those points in the trained-marker, and proyected with the homography predicted by Kalman.
 Kalman doesn't predict homography directly, but can be extracted from position and quaternion. Homography from Kalman should proyect the matched pairs close to the measured pairs.

Is this a good measurement model? Does anybody have a better idea?

Here is a link of the expected result of project of this type with Kalman softening the tracking. In our project the 3D projections are shaking, it is not precise.


texts: Any DVB-S2 sample streams, publicly available?

texts:
I'm working on a DVB-S2 receiver and I'd like to be able to test a part of the DSP chain with real-world signals, but getting good sample streams from a digitizer is not terribly easy.
Can anyone point me to DVB-S2 sample streams available on-line, i.e. digitizer output? I'm particularly interested in adaptive/variable coded/modulated (ACM/VCM) streams, with at least one mod-cod switch. It can basically be of any length, raw I+Q streams, VITA 49 or anything similar.
A good simulator would be a distant second choice.


texts: retrieve phase of an extrapolated periodic 1D signal

texts:
I have a periodic signal on a given grid, say (in matlab format):

t = 1:30;
omega = 2*pi/18.431;
phi = -pi+2*pi*rand(1);   % a random phase [-pi,pi]
x = sin(omega*t+phi);     % the signal
x = x+0.5*rand(1,length(x)); % add some noise

Now I want to retrieve the phase phi. There are a few approaches to that, one is to use fft. The problem is that my grid is not good enough to pick that frequency, hence the phase. (another way is to fit to a sin, but that takes way too long if I need to do it 1e6 times)
I tried to implement the "Autoregressive all-pole model parameters — Burg's method" that is mention in an answer to this question. I manage to pick up the frequency quite well, but fail to pick up the phase.

I was trying to use angle(fft_vec(idx)), where fft_vec is the spectrum obtained after extrapolating the original signal (using arburg), and idx is the index where the frequency omega is picked up. What am I doing wrong? and how can I manage to get that phase by other means?


texts: Envelope detection in frequency domain with MATLAB

texts:
I need to compute the envelope of a spectrum in MATLAB. Is there a specific function that can do it?  I saw the function

[yupper,ylower] = envelope(x,np,'peak')

but i'm not sure this one can be used in the frequency domain. The image below shows the result I would like to obtain (green line).

Any suggestion? Thank you.


texts: Why is the second half of the FFT negative frequencies

texts:
There are lots of questions here about what the negative frequencies in fft mean, but I'm confused on why the second half of the fft calculation is the correct calculation for a negative frequency.

The equation is
$$X[k]=\sum_{n=0}^{N-1}x[n]e^{-j2 \pi kn/N}$$

I interpret this as the correlation between a wave with 1 cycle over N, a wave with 2 cycle over N, a wave with 3 cycles over N.

Let say I'm using 10 bins, numpy will tell me the 10th bin is actually representing a negative frequency. But looking at the equation isn't it a correlation between the signal and a signal with 10 cycles over the full period? If they plugged in a negative k into this equation that would make sense. Why does plugging in big values of K give the correlation for a negative frequency?


texts:
I have 2 audio .wav files recorded by the the same person with the same word. Each audio file has a format of 16bit, 44.1kHz and is a mono channel. I would like to know how to compare these 2 audio files if it is by the same person. What I know is to process the files to produce a floating point result of values between -1 and 1 and apply fft on it and compare the frequency. What I would like to know is how to compare the audio files, prefably with the code which shows the comparison and if possible the steps before that(processing to become values btw 1 and -1).Thanks. Im relatively new in this area so I would appreciate If u guys would help me out. I'm currently using a metro application in vs. I would prefer not to use any library like naudio or bass.net but I would still accept any answer.
A step by step solution starting from utilizing the .wav file is much appreciated. I have been trying to search topics related to what I'm doing but what I have found are small parts of it.


texts: Why exactly is a bit/radix reverse required when calculating the fft?

texts: When implementing the fft, you always include a bit reverse at the end of the process to put the data in the correct order. It seems to be because the fft proceeds by decimating the input array into odd/even sections (for radix-2 algorithms, for other algorithms e.g. prime factor you have to do a radix reverse), the final stage of the algorithm involves multiplications (by several exponential factors) on the individual array members. These can be labelled by a series of EOEEO etc (E = even, O=odd) depending on the process of decimation and whether the subarray was an odd/even decimate. Why does replacing E with 1 and O with 0 result in the bins requiring a final permutation. This has always bothered me about the fft.


texts: Tracking movement of audio speaker driver using images

texts:
I have a speaker emitting low-frequency sinusoidal wave and I have physically marked a curved edge on the speaker driver as shown in red in the image below, which I would like to track:

I detect the movement of the speaker driver using a Dynamic vision sensor(DVS) based event-based camera which can capture changes in intensity at every pixel with very high resolution(in the order of microseconds).

Can anyone point me towards how to model and predict the movement of this red edge on the speaker driver, moving back and forth in the image? If I were to plot the column displacement (with respect to the image) of this edge versus time, I am guessing the plot would resemble a sinusoid matching the frequency of the sound wave the speaker is emitting. Based on this, I think I can use a Kalman filter to predict the sinusoidal movement but I am not sure how to set up the equations.

I would appreciate any tips, pointers or resources on this.
Thank you!

EDIT:

The speaker is emitting a sinusoidal wave of single, constant frequency and amplitude.

This is the setup of the entire experiment:


texts: Support Vector Machine: A non-probabilistic binary linear classifier

texts: I read that SVM is a supervised learning method, it is also a non-probabilistic binary linear classifier. I understand why it is binary because it classifies our training pattern to two classes $w_1$ and $w_2$ which are labeled as $y_i=+ 1$ and $-1$. And I understand why it is linear because it classifies when the classes are linearly separable. But I don't understand the non-probabilistic part, could someone clarify?


texts:
first of all thanks for reading, and sorry for such a generic question.
If it is off topic for your forum i would be thankful if someone could point me to a place where i can find an answer.

I am evaluating developing a software to read backgammon positions out of a video or sequence of still images

Backgammon players use to record their matches with a video camera and later manually enter all moves and dice rolls to a computer software for analysis of their errors.

I am thinking of a software that analyzes the video or image sequence and recognizes dices and positions of checkers before and after the move producing an ascii output with dice rolled ad moves made.

Cameras are mounted in a fixed position, pictures could eventually be triggered by hitting the clock when playing with a chess clock

Is this feasible ( i guess yes )? Has anyone an idea of the effort i can expect to get this done.
If it fits my budget i would like to start a freelance project...

Thanks again for your help!

Best regards

wolf


texts: FFT of accelerometer signal: How to get a correct amplitude & noise reduction

texts:
I’m a student studying on vibration analysis & testing.
I’ve performed low level sine sweep test of a simple rectangular PCB with clamped boundary conditions on two ends of it. That test was performed with an amplitude of 0.5 g (g=9.8m/s^2) and a frequency range was from 20 to 500Hz).

From the accelerometer attached at the center of the PCB, I obtained following time profile (Sampling frequency: Approx. 1600 Hz) (see Fig. 1).

Then, I’ve created this MATLAB code to perform the FFT, to find amplitudes at 1st and 2nd eigenfrequencies of the tested PCB.

==========================================================================

clear all; close all; clc;

acc=load('acc.txt');
t=acc(:,1);             % input t (time) data
x=acc(:,2);             % input x (magnitude) data

dt=(t(2)-t(1));         % sampling frequency
fs=1/dt;
L=length(t);            % time data length

X=fft(x,L)/L;           % fft of magnitude x

amp=2*abs(X(1:L/2));
freq=fs/2*linspace(0,1,L/2);

figure
plot(t,x);              % accelerattion x (time domain)
xlabel('Time (s)'); ylabel('Acceleration (g)');
hold

figure
loglog(freq,amp);       % accelerattion X (freq domain)
xlabel('Frequency (Hz)'); ylabel('Acceleration (g)');
xlim([20 500])
hold

==========================================================================

The result of FFT shows unreasonably low amplitude of 0.1352 g at 1st eigenfrequency. In addition, there is many unidentified errors in the FFT processed signal (see Fig. 2).

I believe that I’ve implemented basic FFT functions required to perform a correct amplitude in frequency domain. So, I tried again by using following combination of cosine functions as an input:

t=0:1/1000:200-1/1000;      % input t (time) data
x=36*cos(2*pi*50*t)+100*cos(2*pi*100*t)+150*cos(2*pi*200*t);    % input x (magnitude) data

In this case, however, the results give the correct amplitudes for each peak of the spectrum (see Fig. 3).

So there are two questions to improve the FFT results;
1)  Why the FFT results from my accelerometer signal produces unreasonably low amplitude, even if those of cosine function gives correct results?
2)  How to get rid of the dirty noise signals, in order to obtain clear signal (Does the window function is effective to reduce such kind of error?).
Thank you for your advice in advance.


texts: Is it possible to find precise peak frequency using FFT phase shifts?

texts:
Been experimenting with FFT on a generated sinusoid and found something strange that doesn't seem to be described anywhere (though I may be missing something of course).

A sinusoid that exactly corresponds to a bin gives what we all know: an amplitude and a phase shift of the sinusoid in that bin.

However, for a frequency that falls between two bins the phase shift of the strongest bin expressed in polar angle seems to be shifted by almost exactly the amount by which the peak frequency is shifted from the strongest bin number. The phase shifts of the neighbouring bins also seem to show some correlation but it is not as strong.

For example, if the distance between bins is $\Delta = 44Hz$, I generate $f = 440Hz$, I get a clear sinusoid at bin $i = 10$ that yields phase angle $\phi = 0$ (the sinusoid itself is shifted by a quarter period for simplicity, hence $0$).

If I generate say

$f = 440Hz + k·\Delta$, where $k \in [-0.5, 0.5]$

then $\phi$ for the strongest bin 10 looks like $k·\pi$.

Some sample measurements:

$k=-0.5 \Rightarrow \phi=-0.499·\pi$

$k=-0.25 \Rightarrow \phi=-0.252·\pi$

$k=-0.15 \Rightarrow \phi=-0.151·\pi$

$k=-0.05 \Rightarrow \phi=-0.054·\pi$

The deviation gets bigger as you move towards the bin, though it's pretty good near the middle. Is this some kind of a parabolic correlation?

So what's the math behind this? Why do these values seem correlated?

And if they are correlated, could this be used for finding the peak frequency with some precision?


texts:
I am basically new to the $z$-transform and there are some points regarding its square magnitude that I do not understand.
Basically I do not understand how in slide 4 of PDF, they arrive at the following expression of $|H(z)|^2$:
$$P(z)=|H(z)|^2=H(z)\ast H^*(1/z^*)$$
If we start with
$$p(n)=h(n)\ast h(-n)$$
but directly take the $z$-transform of the above expression (without substituting $h(n)$ by $h^*(-n)$ as they do in PDF) we arrive at:
$$P(z)=H(z)\ast H(1/z)$$
where I am using the following properties of the $z$-transform:
$$x[n] \longleftrightarrow X(z)$$
$$x[-n] \longleftrightarrow X(1/z)$$
However, it is has been said before (StackExchange) that this expression ($P(z)=H(z)\ast H(1/z)$) is only valid for the unit circle, however I fail to see in which part of the derivation I made the imposition that $|z|=1$.
For reference I attach a capture of the lines I am referring to in PDF:


texts: Remove audio signal component under certain frequency in python

texts:
I want to remove all signal components under 10KHz in one audio file. Below is my code
from scipy.signal import butter, filtfilt

def butter_highpass(cutoff, fs, order=5):
    nyq = 0.5 * fs
    normal_cutoff = cutoff / nyq
    b, a = butter(order, normal_cutoff, btype='high', analog=False)
    return b, a

def butter_highpass_filter(data, cutoff, fs, order=5):
    b, a = butter_highpass(cutoff, fs, order=order)
    y = filtfilt(b, a, data)
    return y

(fs,rate)=wav.read('46.wav')
y=butter_highpass_filter(rate,10000, fs, order=5)

Below are the two outputs before and after applying the HPF.


texts: What is formula for quantization step size?

texts: I have read from different web links,different formulas of quantization step size as shown highlighted in attached snapshot,but what is actual/correct formula?


texts: I want to match a small template to a larger image, that the distance between the template and the subimage with the same size of the template is minimized. It can be solved directly or by applying 2D cross correlation, and both methods have an O(n^4) time complexity. Are there any method to simplify the algorithm by either reducing the complexity or applying pre-processing?


texts: I am working in medical and nature images processing . I want to find a popular method to segment texture image. Could you suggest a popular method to do it? For example: Gabor filter, tensor...


texts: Problems calculating 8-point FFT of an 8-point sine wave by hand

texts:
I need a small help for my assignment, which is to solve the 8-point FFT without using Matlab or C.

Preliminary information:

8-point sine wave: [0, 0.7071, 1, 0.7071, 0, -0.7071, -1, -0.7071]

8-point complex exponential: [1, 0.7071-j0.7071, -j, -0.7071-j0.7071]

So here's the attempts I did:

1.) Bit reversing the 8-point sine wave and rearrange it to:

[0, 0, 1, -1, 0.7071, -0.7071, 0.7071, -0.7071]

2.) Perform each butterfly calculation:

First pass:
[0, 0, 0, 2, 0, 1.414, 0, 1.414]

Second pass:
[0, -j2, 0, 2, 0, 1.414-j1.414, 0, 1.414+j1.414]

And the last:
[0, -j4, 0, 2-j2, 0, 2.828, 0, 2.828-j2.828]

However, the last pass which is the result does not match with the actual FFT result in Matlab:

[0, -j4, 0, 0, 0, 0, 0, j4]

Any steps I might have missed? Opinions and pointers are greatly appreciated. Thanks.


texts: How can I reduce background noise from recorded audio conversation and separate speakers in python?

texts:
I have a recording of an audio conversation of two persons. I want to remove the background noise from audio and then also separate both persons' audio separately in python.

I have gone through some concepts about applying filters on the audio, but I was unable to implement the correct filter. In some audio recordings, it able to cancel out the noise partially.

For Separation of speakers, I found some libraries in python like PyAudioAnalysis, uis-rnn (Speaker-diarization), but they have their own trained models, which are solving the problem. Any paid APIs are available to solve this speaker-diarization problem?

Is there any way to solve this problem?

Thank you:)


texts:
I have pairs of 1d digitised waveform signals which are almost identical - except there are sections which are the same in both but one is delayed slightly.
I need to find sections and the delay with the corresponding section in the other channel.

I can set a maximum delay BUT I need to measure a delay to less than the sample interval - so some sort of convolution/correlation approach rather than a simple feature id.

Any suggestions where to start?


texts:
M. H. Hayes calls in his book "Statistical digital signal processing" autocorrelation sequences $r[k]$.

For optimal filters the desired autocorrelation has the index d -> $r_d[k]$.
However, often there is also an $r_{dx}[k]$. Are they the same? Or is there an assumption where you can interchange them?

Because in some cases it seems like he does just that. No clue why the index changed in some formulas.

This is how d and x are connected:


texts: Leakage in power spectral density estimation

texts:
What does it mean for a power spectral density exhibiting leakes from one frequency bin to other.

I am reading a book which states the following:

"Often the time series we use as input for our algorithm will have a non-zero DC average, which
may even slowly change over time. Such a DC average will show up in the first frequency bin
(m = 0) of the resulting spectrum. If a window function is used or the average changes over
time, it will also leak into adjacent frequency bins, possibly masking low-frequency signals."

Could somebody explain what does this mean? Why does a window leak power into adjacent frequency bins?

I also read the following which has probably a similar connection and it would be good to get an explanation on this as well:

"If we simply take a stretch of length N out of a time series containing a sinusoidal signal and
perform a DFT, we will most likely find that the sinusoidal signal which we might naively expect
to result in a sharp peak in only one frequency bin, will instead show up as something ugly, The reason is that the DFT implicitly assumes that the signal is periodic, i.e. that the time series
of length N repeats itself infinitely in a cyclic manner. If the frequency of the sinusoidal input
signal is not an exact multiple of the frequency resolution fres, i.e. does not fall in the exact
center of a frequency bin, this assumption is not true, and the DFT will ‘see’ a discontinuity
between the last sample and the first sample due to the cyclic continuation. That discontinuity
spreads power all across the spectrum"

What does it mean for DFT to "see" a discontinuity as written above"?

EDIT:After accepting answer:

I ran a MATLAB simulation (code below) in which the frequency of sinusoidal is exactly a multiple of resolution of the PSD and thus falls directly at the center of a frequency bin, still there is leakage into neighboring bins (3 to the right and three to the left of this bin in which the sinusoidal lies). This spilling gets more and more resolved as I increase the window length. Which would seem to suggest that even the frequencies that fall directly at the center of frequency bins leak into the adjacent frequency bins and the amount of leakage will depend on the shape of the window and the length of the window. Is this understanding correct?

MATLAB code:

%%%%%%%%%%%%%%%%%%%% PSD Estimation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

close all;
N=50; %number of periods

Fs= 4096;
snr=10;

M=256; %length of FFT

Fres=Fs/M;

Mul_factor=20;

F_c=Fres*Mul_factor;  %in Hz%

Window_length=128;

Overlap=floor(0.4*Window_length);
x=0:1/Fs:N*(1/F_c);
y=sin(2*pi*x*F_c) + 1/sqrt(snr).*randn(1,length(x));

[ppx,w]=pwelch(y,Window_length,Overlap,M,Fs);

figure;
hold on;
subplot(2,1,1);
plot(x,y);
subplot(2,1,2);
plot(w,ppx);
hold off;


texts: How to filter sudden spikes and baseline changes in microphone signal?

texts:
The orange is a signal I recorded, the blue - my first restoration attempt, after which I decided to ask.

The signal is audible, however there are 2 types of defects 1) baseline changes 2) sudden drops/spikes (which are not single point):

This doesn't look like smoothing/IR filtering problem, but rather some detection + arithmetic. Maybe I can code solution myself, but are there some ready-made solutions?


texts: Confusion with ADC conversion in MCP3424

texts:
I am learning about ADC MCP3422 Chip, because I want to use ADC Pi chip with my Raspberry Pi which is using MCP3424 ADCs, but I am having trouble understanding how the ADC calculation is done in the datasheet.

(Data sheet links are available in the end)

From what I know of ADCs,

An ADC has a bit size.
and ADC tends to generate the total number of level based on the Reference Voltage.

for example,

If there is a 3-bit ADC then and the Reference Voltage is 2volts, then,

2^3 = 8-bits

Now 2volts will be divided in 8 levels.

8/2 = 0.25volts (each level will represent 0.25 volts

and,

000 = 0 -> 0.25 volts
001 = 0.25 -> 0.50
010 = 0.50 -> 0.75
011 = 0.75 -> 1.00
100 = 1.00 -> 1.25
101 = 1.25 -> 1.50
110 = 1.50 -> 1.75
111 = 1.75 -> 2.00

Now, in case of MCP3424, I have so much confusions

The bit size is 18.
Reference voltage is 2.048volts

2^18 = 262144

Does that mean there will be 262144 levels ?

So, 2.048/262144 = 0.000007812volts
Does that mean each level will represent, 0.000007812 volts ?

Also, the data sheet says,

The data rate for analogue to digital conversions is 3.75 (17 bit), 15 (15
bit), 60 (13 bit) or 240 (11 bit) samples per second. Data rate and
resolution can be configured within software using the I2C interface.

How the data rate is calculated here, and how come reducing the bit is increasing the Data Rate ?

MCP3424 Datasheet: www.pridopia.co.uk/pi-doc/mcp3424.pdf

ADC Pi Datasheet: http://www.abelectronics.co.uk/docs/stock/raspberrypi/adcpi2/Datasheet-ADCPiV2.pdf


texts: System Frame Number in LTE Specifications

texts:
What exactly is System Frame Number in LTE specifications? What is the use of it?

I have read that it is a 10 bit number and used for synchronization purposes. But it's not clear how it helps for synchronization. Any help is appreciated.


texts:
I saw many solved examples about this topic but again I coudn't come up with any solutions about this question. How can I find the Fourier Series coefficients of the following signal ?

$x(t)=2 \cos(3\pi t) + \sin(100\pi t+\frac{\pi }{3})$

I know that; $\cos(θ)=\frac12 (e^{jθ} + e^{−jθ})$  and,
$\sin(θ)=\frac{1}{2j} (e^{jθ} - e^{−jθ})$

I also know that I should use
$$x(t) = \sum_{-\infty}^{\infty} a_{k} e^{jk(2\pi/T)t}$$

But I'm having trouble to define the fundamental period $T$ and the relation between sinusoidal terms and coefficients $a_k$, to sum all things together. Thanks to everyone...


texts: Two type of calculating R in steepest-descent modeling algorithm

texts:
I have wrote this algorithm for steepest descent:

function [e2,w_opt]=SteepestDescent_Alg2(x,d,itr,w)
N=length(w);
sample=length(x);
x=[zeros(N-1,1); x];%padding

x1=zeros(sample,N);
for i=1:N
    x1(:,i)=x(N-(i-1):end-(i-1));
end

R=x1'*x1/sample;
P=x1'*d/sample;
lambda=eig(R);
mu=1/(min(lambda)+max(lambda));

w_opt=zeros(size(w));
dd=(d.'*d)/(sample);
e2=zeros(1,itr);
for i=1:itr
   grad=2*R*w_opt-2*P;
   e2(i)=dd+w_opt'*R*w_opt-2*P'*w_opt;
   w_opt=w_opt-mu*grad;

end
wc=R\P
end

These lines forming R:

x1=zeros(sample,N);
for i=1:N
    x1(:,i)=x(N-(i-1):end-(i-1));
end
R=x1'*x1/sample;

But if we use other way to calculating R:

function R=corlnm2(h,N)
    %This function obtains the correlation matrix of the output
    %of an FIR filter which is derived by a white noise, and its
    %coefficients are given in vector "h".
    %"N" specifies the dimensions of "R".
    %
    %   R=corlnm2(h,N)
    %j=sqrt(-1);
    a=size(h);
    if a(1)>a(2)
       h=h';
    end
    m=length(h);

    for k=1:N
        if k<=m
            R(k)=h(k:m)*h(1:m-k+1)';
        else
            R(k)=0;
        end
    end
    R=toeplitz(R);
end

The code have written for this problem, also assume there is coloring filter with tap numerator coefficient of h:

Both two way of estimating R, getting value, really close together, but the second way gives weird learning curve.
Also the input noise set to 0.1 variance, thus minimum kesi(Mean Square Error) must be 0.1, calculating R in first manner give correct learning cure(plot of MSE vs itteration) but the W's are extremely close to Wo
even with more than 0.001 precision, why? And I think both way must give same answer why but this isn't ...?


texts: Calculate properties of a given Modulated Signal

texts:
I'm having a hard time trying to understand signal modulation graphics and how can I calculate/find the properties of the signal. The properties I'm talking are:

Max. amplitude
Carrier frequency
the time it takes to code a bit

Can I do it just observing this two graphics? If not, can I do it using matlab?  I'm a little confused since I'm used to see amplitude and frequency graphics but with bars and discrete values, not with continuous functions.

This is one of the examples I was talking and what I believe is a FSK modulation:


texts: Shift in Time Domain After DFT Based Convolution

texts:
To my understanding, multiplying a signal in the frequency-domain is equal to a convolution in the time-domain.

I wrote a small python program, but i always end up with a shift in the time domain. where does this come from? An hints how to get the correct convolution, where the convolved output signal is in place corresponding to the input signals?

import numpy as np
from matplotlib import pyplot as plt

# make simple rectangular signals
r1 = np.zeros(100, dtype=float)
r2 = np.zeros(100, dtype=float)
r1[1:20] = 1.
r2[20:40] = 1.

# fftransform the signals
fft_r1 = np.fft.rfft(r1)
fft_r2 = np.fft.rfft(r2)

# multiply the frequence-spectra of the signals
fft_p = np.multiply(fft_r1, fft_r2)
# ifftransform back to time-domain
conv = np.fft.irfft(fft_p)

f, axarr = plt.subplots(3, 3)
f.tight_layout()
axarr[0, 0].plot(r1)
axarr[0, 0].set_title("r1")
axarr[0, 1].plot(np.abs(fft_r1), '.')
axarr[0, 1].set_title("fft_r1")

axarr[1, 0].plot(r2)
axarr[1, 0].set_title("r2")
axarr[1, 1].plot(np.abs(fft_r2), '.')
axarr[1, 1].set_title("fft_r2")

axarr[2, 0].plot(np.abs(fft_p), '.')
axarr[2, 0].set_title("fft product")

axarr[2, 1].plot(conv)
axarr[2, 1].set_title("conv (ifft of fft_product)")
axarr[2, 2].plot(np.convolve(r1, r2, 'same'))
axarr[2, 2].set_title("conv, np")

Here is an image of the plots that the above code generates:


texts: Accurate description of the spectrum of sinusoid waveform added with WGN?

texts:
The transmitting signal is
$$
s(t) = \sin(20\pi t)+\sin(40\pi t)+\sin(60\pi t)
$$

The received signal after AWGN channel is
$$
r(t) = s(t)+n(t)
$$
where the variance of noise $n(t)$ is $\sigma^2$.

The theoretical single  spectrum of the $r(t)$ should be

$$
R(f) = \pi\delta(f-10)+ \pi\delta(f-20)+ \pi\delta(f-30)+\sigma^2
$$

where $\delta(.)$ is Delta function. However, the spectrum obtained through MATLAB seems not like the theroetical one.

When the SNR is setted as lower than -25dB, the spikes will be submerged by noise. And how to calculate the threshold SNR where sinusoid part is totally covered by noise?

The relative code is here

fs_init = 10; % basis frequency
om=fs_init*2*pi;
T = 2*pi/om;
tall = 10;
h=T*0.01;
t=0:h:tall-h;
fs_init= 10;
ut = zeros(1,length(t));

%%% Added constants
NSyboml = 3;
a=1;

for i = 1:NSyboml
    ut = ut+a*sin(2*pi*i*fs_init*t);
end

SNR = 0;
rt = awgn(ut,SNR,'measured');   % add noise

% FFT
y = rt;
L = length(ut);    % Length of signal
Ts_v = t./(0:L-1); % sample time
Fs = ceil(1/Ts_v(2));    % sample frequency
deltaf = 0.1; % resolution
NFFT = floor(Fs/deltaf);
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,floor(NFFT/2+1));

% Plot single-sided amplitude spectrum.
 figure;set(gcf,'Color','w','Position',[0 0 500 350]);
plot(f,20*log10(abs(Y(1:NFFT/2+1))));
xlim([0,6*fs_init])
xlabel('Frequency (Hz)');ylabel('|R(f)|');
grid on;
ylim([-120,0])
title(['SNR = ',num2str(SNR),'dB'])
%%%enter preformatted text here


texts:
If a CT signal $x(t)$ is sampled for one ($1$) second and $4096$ samples are generated:

Isn't the highest frequency that can be sampled without aliasing ($4096/2$) $2048\textrm{ Hz}$?
If a $4096$ FFT of this signal is computed what is the frequency spacing between the output points (in $\textrm{Hz}$) ?


texts: Why do you get instantaneous phase by calculating correlation with a carrier signal?

texts:
I am somewhat new to DSP. I'm trying to implement BPSK by following this Python QAM tutorial.

My code seems to work, but I really just ported the tutorial's Python code to C++, and do not understand it. This is the part that confuses me the most:

# Demodulate in "real" and "imaginary" parts. The "real" part
# is the correlation with carrier. The "imaginary" part is the
# correlation with carrier offset 90 degrees. Having both values
# allows us to find QAM signal's phase.

for sample in samples:
    t += 1
    angle = CARRIER * t * 2 * math.pi / SAMPLE_RATE
    real.append(sample * math.cos(angle))
    imag.append(sample * -math.sin(angle))

for t in range(0, len(real)):
    # This converts (real, imag) to an angle
    angle = math.atan2(imag[t], real[t])
    phase.append(angle)

I understand that this code is correlating the input signal with two identical carrier waves which are offset by 90º. I do not understand why that correlation has anything to do with phase.

I'd love an answer to any of the following questions:

Why does this code work?
What is the connection between correlation and phase?
Is this a common, reliable method of calculating phase?
Why does the FFT need so many samples to calculate phase, but this code just needs 1 sample?

Feel free to refer me to a signal theory or DSP book that answers these questions!


texts: Fourier transform 4 times = original function (from Bracewell book)

texts:
I was glancing through "The Fourier Transform & Its Applications" by Ronald N. Bracewell, which is a good intro book on Fourier Transforms. In it, he says that if you take the Fourier transform of a function 4 times, you get back the original function, i.e.
$$\mathcal F\Bigg\{ \mathcal F\bigg\{  \mathcal F\big\{  \mathcal F\left\{  g(x) \right\} \big\} \bigg\} \Bigg\} = g(x)\,. $$
Could someone kindly show me how this is possible? I'm assuming the above statement is for complex $x$, and this has something to do with $i^0=1$, $i^1=i$, $i^2=-1$, $i^3 = -i$, $i^4=1$?
Thank you for your enlightenment.


texts:
I sampled a signal and unfortunately every second sample is very noisy.
The noise is Gaussian and bandlimited exactly in the same bandwidth as my signal.
Is there a way to improve the noise without averaging? I need to keep the original sample rate.

In theory I know the spectrum of my signal. I can skip all noisy (every second) samples and do a FFT. This gives me a spectrum with very low noise. But it is undersampled.


texts: How the zero - phase filter without filtered signal truncation at the end can be implemented?

texts:
I mean what for the window FIR filter the filtered signal is truncated at the end because impulse response of the filter is symmetric. For example the code from here (in python) (lowpass FIR filter) gives the next results:

color meanings:
blue - input signal
green - shifted filtered signal
red arrow - the end of the filtered signal

The red arrow shows where the filtered signal is ended. How can I implement the zero - phase or nearly zero - phase filter so what the filtered signal would end at the same point in time as the original one? The end of the filtered signal is of most significance.

Thanks.


texts: Separating Ultrasonic signal from echo at the receiver

texts: A transducer is acting as a transmitter and a receiver. It keeps on sending pulses which can hit an object placed at 5cm. Echo comes back and hits the transducer while it is continuously sending pulses. That is there is no way to detect echo signals explicitly (as the line is being driven by input signal). How do we detect whether object is present at 5cm? I was thinking of extracting beats/lag from the distorted input signal (my intuition: when the echo hits the transducer, it tries to generate a signal which oppose the input signal) when the object is present and compare it with a case when the object is not present.  What's the best technique to use here (any Adaptive Signal Processing)?


texts: What is the meaning of the length of diagonal lines in FFT

texts:
I am relatively new to FFT analysis of images and have a question about them. I like to think I understand the basics but many of the properties shown in a FFT image are beyond me.

My main question is what is what is the meaning of the length of diagonal lines in a fourier transform? What is the meaning of the length of a diagonal line on the image domain or in the Fourier domain? The diagonal lines are related to the edges in the image but what kind of property does the length describe?

If asking these questions means that I don't fully understand FFT, are there any resources that would help me dig deeper?


texts: extend parts in an existing audio file to make it sound longer without stretching the file

texts:
I'm looking for a way to extend certain parts of an exiting audio file to make these parts sound like the where played longer. And I dont want to change play speed or stretch the file.
Lets say u have a digital sound file of someone playing a trumpet. And he's playing diffrent tones. Now I want to jump to a certain point in this file and hold this very tone as long as I want. To make it sound like it was played very very long. Without anyone noticing that it was artificialy extended.
And I want to do this with not just recordings of instruments.

What technics do you suggest?

Maybe something like granular synthesis or any other synthesis technic?

It would be so awesome if someone could help me with this.
Thanks in advance


texts:
I have generated 20 MHz bandwidth LTE waveform. I wanted to do carrier aggregation of this signal to get 100 MHz Signal.

I want to understand how carrier aggregation is done mathematically, so using built-in matlab functions isn't what I'm looking for.


texts: Reconstructing input from the output of a known discrete-time IIR filter

texts:
I have known discrete-time IIR filter.  I pass a signal x(n) through the filter and obtain the output y(n). How would I design a filter to obtain x(n) from y(n)?
In general, is it possible to design such a filter? If not then under what conditions is it impossible to retrieve the input x(n)?


texts: What is the best algorithm to detect leading edge?

texts: I am interested to detect leading edge of one dimensional signal. There may be several algorithm for edge detection, specially for image processing (2 dimensional), but my interest is on one dimensional signal. I am specifically looking for algorithm which can reject trailing edge.  Any suggestion or useful link to an algorithm?


texts: Conditions for expressing a system as difference equation

texts:
I have read when studying this subject that a system is LTI and causal if and only if it can be expressed as a difference equation (if it is in continuos time, as a differential one). I don't know if this is true, mayne I'm remembering it wrong.

The problem is that today I thought of the case of an IIR filter. It is not causal and it can be written as a difference equation.

So I have two questions about this:

1) Why does an LTI system have to accomplish the initial rest condition (causality?) in order to be expressed as a difference equation?

2) What about the IIR filters? They are not causal and they can be expressed as a difference equation. Why is that? What am I thinking wrong?


texts: Performing DFT twice on an image. Why am I getting an inverted image?

texts:
I was asked to perform DFT on an image twice as a part of my school assignment. Why am I getting a blurry inverted image when I perform DFT on an image twice? Sorry, I'm new to image processing and signal processing. Can someone help me explain this mathematically?

Here's the result I obtained.
PS: I used FFT algorithms to perform the DFT. (Python and numpy, np.fft.fft2)

[Edit]: I haven't shifted the DC value, F(0,0), to the center as usual, for the magnitude spectra given here. (I haven't used np.fft.fftshift)

Here's the exact code I used.

import numpy as np
from matplotlib import pyplot as plt

img = plt.imread("Q4.tif")
dft = np.fft.fft2(img)
dft_of_dft = np.fft.fft2(dft)

spectrum = np.abs(dft)
c = 255 / log(1 + np.amax(spectrum))
spectrum = c*np.log(spectrum)

double_dft_spectrum = np.abs(dft_of_dft)
c = 255 / log(1 + np.amax(double_dft_spectrum))
double_dft_spectrum = c*np.log(double_dft_spectrum)

p, axarr = plt.subplots(1, 3, figsize=(12,4))
axarr[0].imshow(img, cmap = 'gray')
axarr[0].set_title('Original Image')
axarr[1].imshow(spectrum, cmap = 'gray')
axarr[1].set_title('DFT')
axarr[2].imshow(double_dft_spectrum, cmap = 'gray')
axarr[2].set_title('Double DFT')
plt.show()


texts: Generating wavelet using amplitude spectra

texts:
Equation (4) of a recent paper (An improved peak-frequency-shift method for Q estimation) shows how to generate a wavelet using a zero-phase Ricker wavelet.

$|B_1(f)| = |B_0(f)|\exp(-\pi t f / Q)$

In the above, $|B_1(f)|$ is the amplitude spectra of the wavelet that I want to calculate, $|B_0(f)|$ is the amplitude spectra of the reference (Ricker wavelet), $\pi$ is the ubiquitous constant, $t$ is the time separation between wavelets, $f$ is the frequency, and $Q$ is a number (the Quality factor).

I know how to calculate the zero-phase Ricker wavelet in the time domain as $B_0(t)$, and I know how to calculate $|B_0(f)|$ as the square root of the sum of the real and imaginary parts squared of the frequency-domain reference Ricker wavelet.  The real and imaginary parts are found using the FFT.

However, now that I've calculated $|B_1(f)|$, how do I transform $|B_1(f)|$ back into the
time domain?  I know $|B_1(f)|$, but can I find the real and imaginary parts of $|B_1(f)|$ so that I can use the IFFT to compute $B_1(t)$ in the time domain, or is some other information missing and required?

Is the "without phase changes" words in the recent paper (http://www.seg.org/documents/10161/997244/1218.pdf) a clue that might help with the numerical implementation?

So how did the authors generate the wavelets in Figure 1 of the paper?  Is something other than Equation (4) being used here?

Perhaps there is nothing more happening here than an issue with notation. Looking at another paper (Estimation of quality factors from CMP records), the frequency spectrum of a Ricker wavelet is computed using Equation (1):

$B(f) = \frac{2}{{\sqrt \pi  }}\frac{{{f^2}}}{{f_m^2}}{e^{\frac{{ - {f^2}}}{{f_m^2}}}}$

In the above, $f_m$ is the dominant frequency.  However, there doesn't seem to be any complex part of this expression.  Does this imply that the complex part is comprised of all zeros?  To numerically evaluate this equation, how do I compute the $f$ variable?  For example, using Matlab, $f$ can be computed using the colon operator:

f = fmin:deltaf:fmax

But what is fmin and fmax?  Now $B(f)$ can be computed and taken back into the time domain using the IDFT (or the IFFT), but what if I want a real time-domain discrete signal for the $B(t)$ function?

Equation (5) of the same paper gives an expression that I think can be used to calculate the Q factor wavelet (note that this looks the same as the equation at the very top of this post):

$B(f,t) = B(f){e^{\frac{{ - \pi ft}}{Q}}}$

However, what is meant here by the "amplitude spectrum"?  How do I get the real and complex parts of this spectrum?

A time domain version equation of the Ricker wavelet can be found here: Wikipedia link, but then what is the time domain expression used to calculate the Q factor wavelet?  As an aside, it would have been easier to have the time domain version of:

$B(f,t) = B(f){e^{\frac{{ - \pi ft}}{Q}}}$

But what is the "amplitude spectrum" in this context, and how can I compute the wavelet in the time domain?


texts:
I am trying to find some method to detect people using only one camera 3 meters above the ground. This is a frame returned by camera:

UPDATE: Video test -> http://dl.dropbox.com/u/5576334/top_head_shadow.avi

In order to do that, first I understand that I have to perform a background-foreground segmentation. That is the easy part.

With the foreground mask, I am able to make simple operations such Hough transform to find circles, but this way only detects the 60% of heads, including many false positives.

I could use some other simple techniques like color segmentation, but I found that people heads are very different seen from above because of their hairstyle, color, amount of hair,...

Other option I have though about it is the possibility of using HOG Descriptors, or Haar-like features, but I would need an extensive database of people seen from above to train the models. I have not found anything like that.

I thought this would be a very recurrent problem, but I can not find very much about it in the literature or internet. Any help to resolve this task will be appreciated :-)

UPDATE: For more information, The goal is to implement some generic method to make pedestrian flow tracking. The first prototype will be tested in a Mall.


texts: Confused about anti-aliasing in analog filters

texts:
I'm a newbeginner when it comes to signal processing. I'm reading up about anti-aliasing, Nyquist and band-pass filters. There's something I don't get: Anti-aliasing in analog filters.

Lemme try to explain. I use a 8th order analog butterworth band-pass filter (centered at 17.5 Hz with a 25 Hz 3dB bandwidth) on the analog signal. So it cuts at 5 and 30 Hertz and ofcourse there's the transition-band before the stop-band. It is supposed to be an anti-aliasing filter. Where is this anti-aliasing happening?

I asked my teacher before he left why the butterworth was called anti-aliasing filter when it didn't really do it. He answered that since I was working on the analog signal, it was just a band-pass with no anti-aliasing because this was before ADC. The aliasing only occur after the ADC when the analog signal is made to digital and digital filters are used. WUT?

I mean, the anti-aliasing still happens when the signal goes through ADC, right? (well, I sample at 512Hz so I oversample the signal but stil...) So why is the filter called anti-aliasing filter?

Could someone explain this to me? I totally don't get it. Why is it called anti-aliasing filter and where does this anti-aliasing happen?


texts: What Noise Will Change the Frequencies Components of a Signal?

texts: Normally, when talking about adding noise to simulation data, the choice are AWGN, pink noise and so on. However, in practice, the noise in the experiments changes the locations of frequency peaks as well. How can I simulate this kind of noise?


texts: Why can Quadrature Demodulation demod a Frequency Modulated Signal?

texts:
I use a Quadrature Demodulator in my SDR application, which is defined as:

$\angle (S_n, S_{n+1})=arctan(S_{n+1}*\overline{S_{n}})$

So practically its amplitude is the angle between two Samples $S_n$ and $S_{n+1}$ where $n$ refers to a position in a sequence of complex values of I and Q. $\overline{S}$ be the complex conjugate.

I understand that for Quadrature based modulation the phase-changes contain the information. But why can I demodulate frequency-modulated Signals with a Quadrature Demodulator. This modulator is often referred to as FM Demod. Can somebody explain me why that is?

Best,
Marius


texts:
I'm trying to model the transfer function of a linear system (a MOEMS mirror) based on a datasheet plot of its response. I'm developing the model in the python-control model and I think that I've got the model pretty close, except that the Bode plot appears to wrap the phase response to keep it within $\pm 180^\circ$. My question is threefold:

Is there a material difference between my model and what's in the datasheet with respect to the frequency wrapping?
Is there a simple way in the python-control library to unwrap the plot
Are there any other suggestions to improve my model?

Here is the response plots from the datasheet:

Here is my model:


texts: Resources on multiplexer and demultiplexer?

texts:
If I search multiplexer in Google and start reading, I find sources that describe a multiplexer as a device that selects between several analog or digital signals, then outputs a single signal. For example, a multiplexer is described as kind of a switch, that just selects one of the input signals.
This seems like a form of multiplexer, but more generally, I always though a multiplexer combined the signals into a single signal then a demultiplexer separates the signals into the separate signals....
So, is a multiplexer just a switch (as defined in the beginning of the Wikipedia article)? Or, does a multiplexer mix signals (e.g., frequency division multiplexing)?
Sorry, I don't know what tags I should select.


texts:
I want some data (images that have only shift) to test on xuvtools  or Microsoft ICE and my own software.
Is there any available?


texts: Why is the second-order-section cascade approach giving "worse" results?

texts:
It seems that as a general rule, for digital IIR filters of order more than 2, one is encouraged to use a cascade of second order sections, for reasons connected to the poor stability of high-order filters. See, for example, my question What is the largest "safe" order for the digital Butterworth filter of a given signal? and the answers given there, or the "Limitations" section of https://uk.mathworks.com/help/signal/ref/butter.html.

Now suppose I have a digital signal $x(t)=\sin(2\pi t)$, $t \in \{0,0.08,0.16,\ldots,99.92,100\}$.

Suppose I want to filter this signal in the passband $[f_\mathrm{min},f_\mathrm{max}]=[0.5,3]$ using a zero-phase Butterworth bandpass filter, with filter order $60$; I believe the transfer function of the filter should be
$$ H(2\pi if) \ = \ \frac{f^{30}}{f^{30}+\left( 0.4f^2 - 0.6 \right)^{30}} $$
where 0.4=1/(3-0.5) and 0.6=1/((1/0.5)-(1/3)).

Presumably, the correct result for the filtered signal will be almost identical to the original signal.

In MATLAB, I can perform the filter by a cascade of second order sections, using the code

n=15;
Wn=[0.5 3]/6.25;
[z,p,k]=butter(n,Wn);
[sos,g] = zp2sos(z,p,k);
d=filtfilt(sos,g,x);

or I can perform the filter directly from the transfer function coefficients, using the code

n=15;
Wn=[0.5 3]/6.25;
[b,a]=butter(n,Wn);
d=filtfilt(b,a,x);

The results for the two approaches are as follows:

The upper graph gives the result of the SOS approach, and the lower graph gives the result of the direct approach.

It seems that for quite a significant proportion of the duration of the signal (around the start and end), the SOS method is giving considerably inaccurate results.

    Why is the direct approach giving (what I presume to be) a much more accurate result overall than the SOS approach? Should some caveats be added to the general advice that one should always use SOS?


texts: MFCC delta: How to compute delta, in real time, with no future frames?

texts:
I am trying to compute Delta coefficients for real-time audio analysis. As far as I know, a valid formula is:

$$d_t= \frac{\displaystyle\sum_{n=1}^{N}n\left(c_{t+n}-c_{t-n}\right)}{2\displaystyle\sum_{n=1}^{N}n^2}$$

It seems that I need $n$ future frames at each time step $t$ to compute both delta and delta-delta. However in real-time, I don't have future frames for several $\textrm{ms}$ (depending on my window segmentation). My methodology would be to compute, for timestep $t$, delta and delta-delta with an offset (i.e. compute the values from the previous frame or the one before). But then, these coefficients would correspond to one of the previous frames, bringing an offset to the feature vectors.

Is there any other way to get around this issue ? (maybe using a slightly different formula ?)


texts: Measuring similarity between two very similar pictures

texts:
I know similar questions have already been asked, but as I understand, little differences in my goal make a difference on a decision on which algorithm to use. As I am a total novice in this area, I am asking which algorithm would be best for measuring the similarity of two very similar images - e.g. two photos of faces which were taken from the same angle and are grayscale. Basically, this algorithm would need to quantify the difference or similarity of these two very similar pictures.

What software can I use to do that? Basically, I need something that inputs 2 pictures and then produces a number which tells me how different/similar they are.

EDITED: Picture examples

Hey something as similar as these two pictures  and . And which software can be used for these analyses?


texts: When convolving two functions that are constants in a region and 0 everywhere else, where does the integration start?

texts:
Heads up, this is for homework.  I never took a signals and systems course, so I'm behind on this stuff.

I want to compute the convolution of two rectangular regions.  I know the standard equation for convolution, where the integrals are from $-\infty$ to $\infty$, but it is useful to restrict the integration to the areas that matter.

I have one function that has a value of $1/3$ when $-0.5 \le x \le 0.5$ and $0 \le y \le 0.4$.

I have a second function that has a value of $1$ when $-1/50 \le x,y \le 1/50$.  Where would the bounds for integration be for convolving functions like this?


texts:
I'm receiving PCM data trough socket connection in packets containing 320 samples. Sample rate of sound is 8000 samples per second. I am doing with it something like this:

int size = 160 * 2;//160;
int isinverse = 1;
kiss_fft_scalar zero;
memset(&zero,0,sizeof(zero));
kiss_fft_cpx fft_in[size];
kiss_fft_cpx fft_out[size];
kiss_fft_cpx fft_reconstructed[size];

kiss_fftr_cfg fft = kiss_fftr_alloc(size*2 ,0 ,0,0);
kiss_fftr_cfg ifft = kiss_fftr_alloc(size*2,isinverse,0,0);

for (int i = 0; i < size; i++) {
    fft_in[i].r = zero;
    fft_in[i].i = zero;
    fft_out[i].r = zero;
    fft_out[i].i = zero;
    fft_reconstructed[i].r = zero;
    fft_reconstructed[i].i = zero;
}

// got my data through socket connection

for (int i = 0; i < size; i++) {
     // samples are type of short
     fft_in[i].r = samples[i];
     fft_in[i].i = zero;
     fft_out[i].r = zero;
     fft_out[i].i = zero;
 }

 kiss_fftr(fft, (kiss_fft_scalar*) fft_in, fft_out);
 kiss_fftri(ifft, fft_out, (kiss_fft_scalar*)fft_reconstructed);

 // lets normalize samples
 for (int i = 0; i < size; i++) {
     samples[i] = rint(fft_reconstructed[i].r/(size*2));
 }

After that I fill OpenAL buffers and play them. Everything works just fine but I would like to do some filtering of audio between kiss_fftr and kiss_fftri. Starting point as I think for this is to convert sound from time domain to frequency domain, but I don't really understand what kind of data I'm receiving from kiss_fftr function. What information is stored in each of those complex number, what its real and imaginary part can tell me about frequency. And I don't know which frequencies are covered (what frequency span) in fft_out - which indexes corresponds to which frequencies.

I am total newbie in signal processing and Fourier transform topics.

Any help?


texts: Bayesian Information criterion is independent of prior - What does 'prior' mean here?

texts:
I am trying to identify the possible number of states in my data. Each state corresponds to a different scenario. For example, I am measuring humidity and trying to identify the number of states in any given day. (Rain, Cloudy, Sunny).

For this I want to use the BIC to get the optimal number of states when modeling the data with a Gaussian Mixture Model. I am using scikit-learn for this and sklearn documentation says:

  Model selection concerns both the covariance type and the number of components in the model. In that case, AIC also provides the right result (not shown to save time), but BIC is better suited if the problem is to identify the right model. Unlike Bayesian procedures, such inferences are prior-free.

I am not sure what the priors are here.
Thanks in advance!


texts:
My team is working on a program that can read nutrition facts labels using OCR, much like NutriScanner (though by its reviews it doesn't seem like it works particularly well).

I've seen other questions noting that it'd be a good idea to straighten out the image prior to running OCR on it. Is there a good image library that can automatically do that? I've looked around and found numerous Photoshop tutorials on how to do it manually, but that's not what I'm looking for.

I know OCR engines like ABBYY have some pre-processing features built-in, but I'd prefer to piece together a solution using Tesseract and a free library for the pre-processing.

I haven't found much in the way of leveraging the positioning of the items on the label to improve scanning accuracy, but any suggestions would be appreciated.


texts:
I’m new to DSP and I have to do an audio equalizer in c++.
I did a lot of research about it  and tried some stuff in the last month, but I’m a little overwhelmed with all those informations and it’s not working yet.

I decided to start over and for now, all I got is a function which fills the audio buffer with a sin wave (1kHz). And I’m trying to apply a filter with those values to it.

<Filter>
    <Bands num-bands="28">
        <band0    freq="31.25"      width="7.23625"     gain="0" />
        <band1    freq="39.3725"    width="9.1171"      gain="0" />
        <band2    freq="49.6063"    width="11.4868"     gain="0" />
        <band3    freq="62.5"       width="14.4725"     gain="0" />
        <band4    freq="78.7451"    width="18.2342"     gain="0" />
        <band5    freq="99.2126"    width="22.9737"     gain="0" />
        <band6    freq="125"        width="28.945"      gain="0" />
        <band7    freq="157.49"     width="36.4684"     gain="0" />
        <band8    freq="198.425"    width="45.9473"     gain="0" />
        <band9    freq="250"        width="57.89"       gain="0" />
        <band10   freq="314.98"     width="72.9368"     gain="0" />
        <band11   freq="396.85"     width="91.8946"     gain="0" />
        <band12   freq="500"        width="115.78"      gain="0" />
        <band13   freq="629.961"    width="145.874"     gain="0" />
        <band14   freq="793.701"    width="183.789"     gain="0" />
        <band15   freq="1000"       width="231.56"      gain="6" />
        <band16   freq="1259.92"    width="291.747"     gain="0" />
        <band17   freq="1587.4"     width="367.579"     gain="0" />
        <band18   freq="2000"       width="463.12"      gain="0" />
        <band19   freq="2519.84"    width="583.495"     gain="0" />
        <band20   freq="3174.8"     width="735.157"     gain="0" />
        <band21   freq="4000"       width="926.24"      gain="0" />
        <band22   freq="5039.68"    width="1166.99"     gain="0" />
        <band23   freq="6349.6"     width="1470.31"     gain="0" />
        <band24   freq="8000"       width="1852.48"     gain="0" />
        <band25   freq="10079.4"    width="2333.98"     gain="0" />
        <band26   freq="12699.2"    width="2940.63"     gain="0" />
        <band27   freq="16000"      width="3704.96"     gain="0" />
    </Bands>
</Filter>

So here are my questions :

In which domain should I apply the filter ?
I started in the frequency domain, but this blog (here and here) shows me that it’s not the best and only solution.
Which kind of filter should I use ?
I’m lost with all those high pass, low pass, peaking, shelving filters; and I don’t know which one to choose.
I only found “tutorial” to create a filter which modify only one frequency / band. Is it possible to create a filter that is a sum of multiples filters ? Or applying multiples filters in series to the signal ?

Feel free to ask if I forgot something that might help to understand my problem.
Thanks for your time.

PS : Sorry if this post is not very specific, but I want to clear that out before posting specifics problems or code.


texts:
New here tho. This may be a newbie mistake of mine or pretty basic to do so. So I calculated a Power spectrum using FFT from an 'amplitude spectrum' (Altho. I'm still trying to do the Lomb-Scargle periodogram for this one...sadly) to determine the non-coherent signals of the object. The thing is, the overall plot starts instead in the 'negative side' likely due to the FFT implementation or perhaps the data itself (which is in positive values). May I ask if there's a possible way to adjust the whole power data to start on "0"?
The code initially runs like this; I'll also attach the sample data used
# Import the required modules
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Load the data
df = pd.read_csv('FLSP.csv') #Attached is the sample data used
df.head() #Shows Frequency/Amplitude data only
df.info() #You can skip this step

#Do the Fourier Transform
N = len(df) #Proxy to number of data points => 8246 datapoints
dt = 100

ft = np.fft.fft(df)
freqs = np.fft.fftfreq(N, dt)

ft_shifted = np.fft.fftshift(ft)
power_shifted = np.abs(df['Amplitude'])**2
freq_shifted = np.fft.fftshift(freqs)

#Plot the Power spectrum
plt.plot(freq_shifted, power_shifted, label="Power Spectrum")
plt.xlabel('Frequency [Hz]')
plt.ylabel('Power')
plt.rcParams["figure.figsize"] = (15,4)
plt.savefig('test_spec.jpg')

In addition, the normal/unprocessed amplitude-frequency data literally starts at 0. :/
P.S. I tried to set the X and Y Limits...and it just basically "zooms" the data in that specified part (which is still important in the latter don't get me wrong).
Also would love to hear some words about L-S periodogram implentation as I tried Astropy recently and didn't work for my data. Thanks and clear skies to everyone.


texts:
I have this signal as the following figure:

Now, I need to know each beginning index of each pulse as described in the following figure:

I have tried to detect the peaks through obtaining the cross correlation function with the sequence that I am sending and the Signal that I am receiving (which is exactly as if am doing auto-correlation). But they are not aligned as the following figure:

Can you suggest a solution to this problem, please? I am kinda stuck and this is my last step in my project.

I can show the codes if needed.


texts: How to simulation different kinds of Noises in speech signal?

texts: What are the different kinds of noise in speech signal? How can I simulate the same in Matlab for adding to a clean speech signal?


texts: which is the best book or any resource to study fundamentals of rf transmitter and receiver?

texts: want to know from where should I study the fundamentals of RF transmitter and receivers ?


texts: Modified Tukey window applied in frequency domain

texts:
In analysis of transient signals (ground motion time-series) in seismology, many operations are performed in frequency domain and it is common practice to apply a filter which is like a modified Tukey window in frequency domain to keep data band-limited before applying an inverse IFFT to go back to time-domain. Essentially, 4 frequencies f1, f2, f3 and f4 are specified and the filter is a combination of high pass and low pass taper. Here quoting from a web manual-
"The taper is unity between f2 and f3 and zero below f1 and above f4. Frequencies f1 and f2 specify the high-pass filter at low frequencies, while frequencies f3 and f4 specify the low-pass filter at high frequencies. Both f3 and f4 should be less than the Nyquist frequency: 0.5/DELTA. The filters applied between f1 and f2 and between f3 and f4 are quarter cycles of a cosine wave. To avoid ringing in the output time series, a suggested rule-of-thumb is f1 = f2/2 and f4 >= 2*f3".

Can someone please explain what is the reason behind the rule of thumb mentioned at the end ?
Is there any specific advantage of using such a filter compared to other filters like an acausal Butterworth filter ?

I have added links to 2 figures (for some reason, upload image is not working for me) which show time and frequency domain response of 4 filters (cosine tapers with f2=2f1 and f4=2f3 [black], and f2=1.25f1 and f4=1.25f3 [red] with f2=0.2 Hz and f3=0.9 Hz) and 2-pass bandpass Butterworth filters with 4 and 8 poles applied at frequencies f2 and f3.


texts: Why do we need multiple layers in each octave and multiple octaves in SIFT?

texts:
I skimmed through the SIFT paper. I understand that there are multiple octaves, which are composed of multiple layers. The layer $k$ of an octave (btw, where does this name come from?) corresponds to the image filtered with a Gaussian kernel with a standard deviation of $k\sigma$, so layers higher in the octave correspond to more blurred versions of the original image. From these blurred images, you calculate the difference of Gaussians (DoG), from which you can compute the pixels that are locally higher (compare to a neighborhood around that pixel). The pixels that are locally higher than its neighbours are the potential keypoints. Once this is done, you can downsample the Gaussian-filtered images in the first octave to produce another octave, then you compute the DoGs again. This process can be repeated (for several iterations).

Intuitively, we apply the Gaussian kernel with a progressively higher standard deviation so that we can find keypoints at different scales (or resolutions), but why do we need to further downsample the Gaussian-filtered images in the first octave and repeat the process? Intuitively, this could still help to find keypoints at different resolutions (or scales), but I can't fully understand why would this approach be correct. So, why do we need multiple layers per octave and multiple octaves in SIFT?


texts: What is the difference between y[n] and y(k) (using square brackets)?

texts:
Can I modify y[n] = αy[n-1] + x[n] the same way I would do it with y(k) --> Y(z)?
I need H(z), but I don't know what is the difference between using (k), and (n). I often encountered [k] notation, what is the difference between (k) and [k]?


texts: Method for determining probe angle by analyzing skewed sine wave

texts:
I've got a fun problem and would be curious to get feedback on how some of you would go about solving this.

Imagine I have a probe and am scanning the surface of some material. This material surface is described by a perfect cosine signal. If my probe is perfectly normal to the surface, my probe will output a "1 to 1" match of the surface signal (excluding some DC offset).

However, if my probe is not perfectly normal to the surface, the collected signal would appear to be a skewed sinusoid. I've put together a simple diagram of set up.

Currently, my method for determining the probe angle would be to determine the frequency content of the signal. In the case of the probe being perfectly normal to the surface, I would expect that frequency domain would show a single impulse corresponding to the surface frequency.

In the case of the angled probe, I would expect to a find a range of frequencies. Obviously the peak would still correspond to the dominant spatial frequency, however, there would now be a certain bandwidth associated the frequency domain. This bandwidth is associated with the fact that the collect signal is a skew sinusoid.

My question would then be, how would I correlate signal bandwidth to probe angle?It would be nice to get an analytical solution to signal bandwidth and probe angle.

Furthermore, if anyone else could see a way of determining probe angle that isn't frequency domain related, I would be interested in hearing it.

Edit: As I think about this problem more, I'm becoming less confident in whether or not probe angle would create a skewed sinusoid. Assuming the angle doesn't exceed the max slope found in the signal, I'm starting to think the resulting signal would simply be a phased offset sinusoid...


texts: Frequency response of marginally stable LTI systems

texts:
The frequency response of a system is defined as:
$$\int_0^\infty{h(t)e^{-j\omega t}dt}$$
where $h(t)$ is the impulse response. But in marginally stable systems, $h(t)$ does not decay so the integral doesn't converge. Does the frequency response "exist" in this case?


texts: Discrete Time Fourier Transform (DTFT) for an unstable system (Ideal Low Pass Filter)

texts:
The Dirchlet conditions state that if the signal is absolutely summable then it the DTFT of the signal definitely exists. This is a sufficient condition but not necessary condition.

There are systems like Ideal Low Pass Filter, which are not absolutely summable. The condition of absolutely summability is a necessary and sufficient condition for stability. Therefore, I can find a bounded input for which the system produces unbounded input.

For such systems, which are not absolutely summable, but are absolutely square summable, we define the DTFT in the same manner and argue that even though non-zero error exists, the energy of the error is 0, which essentially gives rise to Gibbs Phenomenon.

But the condition of $y[n] = x[n] * h[n]$ is independent of stability, and simply depends on Linear and shift invariance property. From this definition, I can find a bounded input which will produce unbounded output. But the relation, $Y(w) = X(w)H(w)$ is also independent of stability. Even if I take into account Gibbs Phenomenon, I am unable to deduce the existence of a bounded input which will produce and unbounded output, and this essentially suggests the fact that bounded input will give bounded output.

Where am I going wrong?


texts: How can I remove random dots from an image?

texts:
I recently received some scanned pictures which are in a pretty good state, with OK resolution, but they are randomly spattered with a bunch of black dots. These cover everything (clothes, faces, walls, windows, and so on) except for a few very bright areas. I also have no idea how they got there. Here is a sample:

From an information content perspective, I would expect that these dots could probably be removed as they likely have a quite distinct signature. (If they were evenly distributed, for example, I know that a spatial mask on their Fourier transform would do wonders.) Is there some algorithm to remove these artifacts?


texts: Why is C++ so popular for Image Processing?

texts:
I have been a student of Image Processing for 3 years now and have been using C++ as the programming language to implement different Image processing operations. But I don't really why in particular C++ is so popular for Image processing rather than other languages like Java and C-sharp.

Could you please explain why C++ is so popular for image processing?

Thanks!


texts:
Which technique gives better result in extracting a band from a signal, let's say the alpha band (8-13 Hz):  using a band-pass-filter or a DWT (Discrete Wavelet Transformation)?

P.S.: I am working in EEG processing.


texts:
Is it possible to obtain same PSD from different FFTs?
Can anyone explain it mathematically?


texts: Find the length of the impulse response for the given output and input

texts:
Homework Question:

Consider a signal $x[n]=\alpha e^{j \omega_{0} n}+\beta e^{j \omega_{1} n}+\gamma e^{j \omega_{2} n} .$ What is the length of impulse
response $h[n]$ of a system (non-trivial) such that $x[n] * h[n]=0$ ?

I have written the form in frequency domain in terms of system function as $$H(\omega)\big(\alpha \delta\left(w-w_{0}\right)+\beta \delta\left(w-w_{1}\right)+\gamma \delta\left(w-w_{2}\right)\big)=0$$
Thus $H(\omega)$ must have zeroes at $\omega$ = $\omega_0,\omega_1,\omega_2$
I am not sure about the meaning of impulse response length and also how to proceed to find the same from here.


texts: Calculate cut-off frequency of lowpass IIR-filter

texts:
Given a an IIR lowpass-filter in z-space:

$ H(z) = \frac{\sum_{i=0}^P b_{i} z^{-i}}{1+\sum_{j=1}^Q a_{j} z^{-j}} $

How to calculate it's 3dB cut-off frequency?

I about evaluating it's fourier transform (as long it exits) and take it's magnitude:

$\frac{1}{\sqrt{2}} = \frac{|H(e^{j\omega_c)}|}{|H(e^{j0})|}$

This is then transformed to calculate $\omega_c$. Is this correct? Are there other ways to do that?


texts:
I have the following diagram for acoustic echo cancellation

I'm having a hard time figuring out what's present on the top and bottom lines in terms of reflected echos, original signal etc. Here's what I think

I am assuming a situation in which I am talking in my microphone at home via some software to a meeting room in which a teleconfrencing setup is present. The microphone and speaker in the diagram repersent the teleconfrencing setup. My voice goes through the teleconfrencing speakers, hit's the walls of the meeting room and back into the microphone.

So, what I think is that the right after the microphone symbol in the diagram is my echoed voice x_echo[n]
On the bottom line at the speakers, only my original voice should be present since that's what's meant to be going through the speakers - so x[n].
Now, if that's the desired signal for my LMS adaptive filter, then how would my LMS adpative filter work, there would be no correlation at all.


texts: Drawing conclusions from impulse response of a discrete LTI system

texts:
I have an impulse response of an LTI system which is
h(n)= n*u(n)-u(n-2) where n=[0,3] (1)

Now regarding the stability and causality of this system, i've drawn the conclusion that the system is causal since the output only relies on past or present values of n and it is stable since n is bounded. In this case n=0,1,2,3. Correct me here if i'm wrong but in case h(n) was u(n) - u(n-2) without knowing anything about n, it would stil be stable right? And if h(n) is the same as the original (1) but again without knowing anything about n it would be unstable correct?
Now i want to analyze this h(n) in odd and even components and also find the linear difference equation of h(n) ,but i can't find anything in my textbook that is of any help. It's the first time i've attended a signals and systems course and i'm really struggling to understand a few things, so any help here would be greatly appreciated.


texts: Which time-frequency coefficients does the Wavelet transform compute?

texts:
The Fast Fourier Transform takes $\mathcal O(N \log N)$ operations, while the Fast Wavelet Transform takes $\mathcal O(N)$. But what, specifically, does the FWT compute?

Although they are often compared, it seems like the FFT and FWT are apples and oranges.  As I understand it, it would be more appropriate to compare the STFT (FFTs of small chunks over time) with the complex Morlet WT, since they're both time-frequency representations based on complex sinusoids (please correct me if I'm wrong). This is often shown with a diagram like this:

(Another example)

The left shows how the STFT is a bunch of FFTs stacked on top of each other as time passes (this representation is the origin of the spectrogram), while the right shows the dyadic WT, which has better time resolution at high frequencies and better frequency resolution at low frequencies (this representation is called a scalogram). In this example, $N$ for the STFT is the number of vertical columns (6), and a single $\mathcal O(N \log N)$ FFT operation calculates a single row of $N$ coefficients from $N$ samples. The total is 8 FFTs of 6 points each, or 48 samples in the time domain.

What I don't understand:

How many coefficients does a single $\mathcal O(N)$ FWT operation compute, and where are they located on the time-frequency chart above?
Which rectangles get filled in by a single computation?
If we calculate an equal-area block of time-frequency coefficients using both, do we get the same amount of data out?
Is the FWT still more efficient than the FFT?

Concrete example using PyWavelets:

In [2]: dwt([1, 0, 0, 0, 0, 0, 0, 0], 'haar')
Out[2]:
(array([ 0.70710678,  0.        ,  0.        ,  0.        ]),
 array([ 0.70710678,  0.        ,  0.        ,  0.        ]))

It creates two sets of 4 coefficients, so it's the same as the number of samples in the original signal. But what's the relationship between these 8 coefficients and the tiles in the diagram?

Update:

Actually, I was probably doing this wrong, and should be using wavedec(), which does a multi-level DWT decomposition:

In [4]: wavedec([1, 0, 0, 0, 0, 0, 0, 0], 'haar')
Out[4]:
[array([ 0.35355339]),
 array([ 0.35355339]),
 array([ 0.5,  0. ]),
 array([ 0.70710678,  0.        ,  0.        ,  0.        ])]


texts: Computation of Only Even or Odd Frequency Bins of DFT

texts:
I have an algorithm where I am computing the FFT of a large signal. However, I desire only the even or odd terms of the DFT of the signal, but not both. Currently, I discard these undesired terms. Is there a way by which I may appreciably reduce the runtime complexity when only every other DFT term is desired?

How might I begin to find such an optimization? If it is unclear, I will look for how the larger, encompassing algorithm could be improved, but I'm starting by examining the smallest, most expensive portion before thinking about more fundamental changes to the system.


texts: How do I calculate peak amplitude of the signal components after zero padding and FFT?

texts:
I am learning about DFT and trying to apply it to some audio processing. I am new to DSP but experienced in programming and have some background in math and physics. The FFT algorithm I use (lomontFFT) doesn't have 1/N scaling in front of the DFT sum (ie. it's defined just like on wikipedia DFT page). I will use simple example to describe my issue.

Let's say I have have 1024 samples of the pure 100Hz sine signal with peak amplitude of 1, and let the sample rate be 10240Hz. So that means that frequency resolution is 10240Hz/1024 = 10Hz. So when I perform FFT I get peak in 10th frequency bin which is correct. (since the signal is real I am only looking at the first half of the spectrum). Now, the magnitude of this peak in 10th bin is 512. How should I interpret this value? Is this magnitude somehow related to the energy of the 100Hz sine wave component in the signal?

Now, how can I get a spectrum to show amplitudes? I'd like to see what components are contained in the signal and what are their amplitudes. So in this example I should have one component at the 10th frequency bin with the value of 1 which is equal to the amplitude. I know I can divide the current value I got by 512 which seems to be the N/2. Is this correct way to calculate it?

If so, what about zero padding? If I zero-pad the same signal with additional 1024 zeros now I have total of 2048 samples. This means that frequency resolution is now 5Hz and my sine component is in the 20th bin. The magnitude is again 512, however now if I divide it by N/2=2048/2=1024 I get 0.5 instead of 1 for the peak amplitude. It seems like I should not count zero padded samples in this scaling? But what about if I just get the signal from somewhere and I don't know if signal is zero padded?

Also it seems that zero padding changes magnitudes in other bins. So in the first case without zero padding I get magnitude of 512 in the 10th bin and all other magnitudes are nearly zero (eg. values of the order 10^-10). But in the second case with zero padding, beside the magnitude value of 512 in the 20th bin I also get large magnitudes in bins around it (eg. 19th bin has magnitude of 334 and 21th bin has magnitude of 318 etc...). I guess these are side-lobes of spectral leaking but why are they showing up if I only have one sine frequency of 100Hz and frequency resolution is 5Hz so it falls exactly in the 20th bin?

I wish I could show some plots but I am programming this in C# console application so I can't provide visuals.

Note: I am using "frequency resolution" term here to denote "frequency bin spacing", I am aware that zero-padding doesn't increases frequency resolution since it doesn't add any new information to the signal.


texts: How to implement a $1$-bit quantizer in Simulink?

texts: I am trying to implement a delta-sigma modulator block diagram in Matlab Simulink but can't find a $1$-bit quantizer (which is required in the modulator) anywhere. Could anyone please tell me how to go about it?


texts: Sinusoid amplitude loss in power spectrum estimation using Pwelch method

texts:
I am trying to estimate the amplitude or power spectrum of a sinusoidal signal using Pwelch method. The following is the matlab code I use.

rng default
fs = 1000;
t = 0:1/fs:5-1/fs;
x = cos(2*pi*100*t) + 0*randn(size(t));
[pxx,f] = pwelch(x,fs,0,fs,fs,'onesided'); plot(f,10*log10(pxx))

And it gives the following result

By default, a Hamming window of length $f_s$ is used in the pwelch function. Since the frequency resolution is 1 Hz, the frequency of the sinusoid lies exactly in one of the discrete frequency bins of the FFT and no scalloping loss is involved.
The question I have is that why the amplitude or power of the peak is -4.357dB instead of -3dB. I tried other windows with the same length. The rectangular window gives a peak of exactly -3 dB and the Hanning window, -4.78 dB. The power loss maybe related to the type of windows, I guess. But I cannot figure out why.

Can anyone explain this?

Thank you in advance.


texts: Spectral correlation zero modulation frequency $S_x(\alpha, 0)$

texts:
I got a simple modulating signal $x(t)=\sin(2\pi\alpha t)\sin(2 \pi \beta t)$ with carrier frequency $\alpha$ and modulation frequency $\beta$. The spectral correlation will obviously have components at the zero modulation frequency ($\beta = 0$). This is not surprising as the envelope signal is always positive.

I am aware that components at $\beta = 0$ also represent the average energy of the signal (Welch) but in the means of components separation/energy conservation, I would like to have the energy of $x(t)$ concentrated at $S_x(\alpha, \beta)$ only.

What am I missing here?

For the current case, do I have a complete separation between the two components having the same carrier and different modulation frequencies?

To me, it seems that part of the energy "leaks" to the zero modulation frequency component.


texts: Synchronization of two audio tracks via Mel-frequency cepstral coefficients (MFCCs)

texts:
I am trying to solve the (common) problem of synchronizing (i.e. measuring the delay between) two audio tracks recorded from different sources during a conference talk (about 1h of audio). One track is recorded with the not-so-good video-camera internal mic (but in sync with video), and the other one recorded directly from the mixer output (good audio quality). The final goal is obviously to superimpose the good audio from the mixer to the video track. By the way, I am trying to implement this on my own in python.

I have already tried to calculate the cross-correlation between selected segments (ranging from 2min to 20min) of the two (normalized) raw audio files, but it appears that the result is very noisy and extremely dependent on the choice of the segment length and position, making it difficult to search for well defined correlation peaks.

I have stumbled into the approach proposed here by @pichenettes and I found it really interesting:

  Extract a sequence of MFCC vectors from both signals. This way you'll
  have something of lower dimensionality and a bit more robust to noise
  and differences in transducers.
  Optionally normalize the MFCC ("by
  design" coefficient 0 has more variance than coefficient 1 and so
  on...)... Ideally you'd want each row of the MFCC matrix to have
  variance 1.
  Compute the cross-correlation of two matrices you get,
  along the time axis (that is to say, compute the 2D cross-correlation
  and just keep the data for the time axis).

However, I have trouble dealing with the result of this correlation. In my understanding, I would then search where the correlation is maximum in terms of frame index, and then calculate the delay from such index. The point is that after calculating the correlation, I am left to deal with this quantity for 13 cepstral coefficients, which also turns out to be strongly dependent on the coefficient itself. My question is: how can I deal with this array of 13 cross-correlations to calculate the track delay? Am I thinking this in the wrong way?

It is probably useful to mention that the delay between the tracks (measured by ear) is about 18-19s. The sync resolution I need would be something slightly below the 25fps of the original video, e.g. 10ms is definitely ok.

Thank you!


texts: AWGN : Recombining AWGN to obtain new AWGN

texts:
I am a newbie to AWGN.

My professor has given me a task of taking 4 different AWGN (0 mean and SD of 1) channels (Lets say each channel has 100 samples). Then I recombine these noise samples by adding all the noise samples together. Now I divide the AWGN channel by the square root of the channel count. In this case, I have 4 samples so I divide the newly generated channel by 2. Now as I understand this new channel has same mean and SD as each of the channels that were recombined to generate this new channel. I now use this new AWGN and combine it with my signal and study a Decoders performance using signal+newly created AWGN. I will be adding the noise to a BIAWGN channel. So my signal will be +1 or -1 and noise will be added on top of that

My questions are as follows:
1. What could be the motivation of doing this. Will this help me in any way?
2. Does anyone know of any research papers that employ this method when studying a decoders performance?


texts: Emulate signal loss of a pixellated detector in Python?

texts:
I have a matrix 64x64 where each cell represents the pixel of a pixellated detector.
The  spacial response of this detector decreases by going further from its center (that is, coordinates "31,31" or "32,32"). I have experimental data (10 samples equally distant in the x axis and 10 samples in the y axes) showing that the loss depends on the distance from the center. I have for example the value 100 at the center, the value 70 at coordinates (37, 37), the value 58 at coordinates (43, 43), etc. By plotting this data, it looks like a Gaussian Function.

For post-processing purposes, I would like to compensate each pixel of the matrix by a factor, where the factor is estimated by using the experimental data (20 samples in total) mentioned above.

Examples:

if at coordinates (16,16) the response resulted to be half compared to the center, I would double the values of that cell
if at coordinates (10,10) the response is 1/3 compared to the center, I would triplicate the values etc...

Is there a way to do this in Python pixels with scipy.signal or similar or in Matlab?

Thank you in advance.


texts: Walking through a spectrum a little at a time

texts:
I am capturing samples with an RTL-SDR:

import numpy as np
from rtlsdr import RtlSdr

sdr = RtlSdr()
F_station = int(88.7e6)
Fc = F_station - F_offset
Fs = 2.4e6
N = Fs
sdr.sample_rate = Fs
sdr.center_freq = Fc
sdr.gain = 'auto'

samples = sdr.read_samples(N)
x1 = np.array(samples).astype("complex64")

I would like to walk through this spectrum 5kHz at a time.  I am attempting to "tune" to each frequency:

width = 5000
targetFreq = Fc - Fs/2 + width/2
while targetFreq < Fc + Fs/2:
    Foffset = targetFreq + Fc
    fc1 = np.exp(-1.0j*2.0*np.pi* Foffset/Fs*np.arange(len(x1)))  # center on target freq
    x2 = x1 * fc1

Then I decimate to reduce the bandwidth to the width I want to process, stepping over the whole bandwidth in 'width' increments.  My decimate function uses scipy.signal's decimate function, often several times (to get down to the right width):

    x3 = decimate(x2, width, Fs)

I process the x3s and put them together.  The output has some sanity to it, but is not correct.  Is the method I'm using to step through the larger bandwidth (multiply by a complex exponential with phase -F_offset/Fs and decimate to "narrow the bandwidth") the wrong approach?


texts:
I've got a question related to a comparison of image segmentation algorithms.
I'd like to compare two algorithm results to each other in step one.
In another step I'd like to compare the two algorithms results against a few ground truth segmented images.
Unfortunately I got only a few ground truth data results in form of single images.
So I can't compare all possible images and parts of an image to the two algorithms.

My first idea on step #1 was that I go down on subpixel area and look up which algorithm is more precise in relation to the original image and discuss it without the ground truth data.
I'll take the difference of the pixels on which the difference lasts. If it's too obvious, e.g. if one algorithm fails completely than the other wins automatically.

In the second approach where I've got ground truth data I would measure the absolute difference in pixels of each algorithm on significant parts of an image.

So, what I wanted to know is:
1) Are this correct approaches for comparing segmentation algorithms?
2) How do I measure the difference in step 1? Do I have to measure all segments of each algorithm?
3) What is a good quality criteria? Is it possible to get a quantitative criteria for the two algorithms?
4) Do I have to compare the whole segmented parts of each algorithm to the ground truth data to gain absolutely correct results?

Please let me know if something is unclear or not correctly formulated.
Any help, advice or feedback is appreciated!
Thank you guys in advance.

Sincerely


texts: DFT and integer valued basis functions'sf requencies

texts:
In Matlab the function

W=dftmtx(N)

gives the DFT matrix of size N.

Each row is computed for an integer frequency k. $W_{k,n} = e^{-i2\pi kn/N}$, k-th frequency, nth sample if I am not mistaken.

I remember that I ve learned that the frequencies (k) are integers for the DFT. For the continuous Fourier transform it is a continuum of freq and times so everything they are real numbers both.

Could you develop on the usage of integer frequencies? and possibly relate it to the DCT where it seems to me that, e.g. the second basis vector is like half a cycle (as shown on my plot), and half a cycle is like a fractional frequency?

code for plot:

DCTm=dctmtx(8);
DFTm=dftmtx(8);
figure;plot(DCTm(2,:));hold on;plot(real(DFTm(2,:)))


texts: Does image size impact compression efficiency differently in different formats?

texts: E.g., if an image is, say, 600px x 400px and the PNG format produces a smaller file size than JPG, does this hold true at any image size? If the image were 600,000px x 400,000px would the two file sizes still have the same relative proportions? Or is it possible that JPG's compression means that PNG will eventually produce a larger file size past some number of megapixels?


texts:
Assuming the signal ($x$) is in volts.

The output units of pwelch are stated to be $V^2/\text{Hz}$. I wanted to confirm this so I ran:

fs = 48000;
t = [0:1/fs:5-1/fs];
x = 0.5*cos((2*pi*1000)*t);
[pxx f] = pwelch(x, 1024, 512, 1024, fs, 'onesided');
[m,i] = max(pxx);
sqrt(m*f(i))

Which results in $1.2697$ not $0.5$. There must be something I am missing! Anyone know what it is?


texts: Why lattice-structured all-pole IIR filter becomes stable, if the k-coefficients satisfies $|k_i| < 1$?

texts:
Why the lattice-structured all-pole IIR filter becomes stable,

if the k-coefficients satisfies $|k_i| < 1$?

Anyone who can tell me the way how to prove it, would be so thankful for me :)

ps. If anyone who has other suggestion solving differently with the proof below using Rouché's Theorem, it's welcome too!


texts: Why must I take abs of filter frequency response?

texts:
I was playing with filters in SciPy and noticed something that I'm not that familiar with:

I'm using the code:

import numpy as np
from scipy.signal import butter, lfilter, freqz
import matplotlib.pyplot as plt

def butter_lowpass(cutoff, fs, order=5):
    nyq = 0.5 * fs
    normal_cutoff = cutoff / nyq
    b, a = butter(order, normal_cutoff, btype='low', analog=False)
    return b, a

def butter_lowpass_filter(data, cutoff, fs, order=5):
    b, a = butter_lowpass(cutoff, fs, order=order)
    y = lfilter(b, a, data)
    return y

# Filter requirements.
order = 6
fs = 30.0       # sample rate, Hz
cutoff = 3.667  # desired cutoff frequency of the filter, Hz

# Get the filter coefficients so we can check its frequency response.
b, a = butter_lowpass(cutoff, fs, order)

# Plot the frequency response.
w, h = freqz(b, a, worN=8000)

taken from: https://stackoverflow.com/a/25192640/4959635

And doing some plots of the given freqz results:

plt.plot(w,h)
plt.show()

plt.plot(w,abs(h))
plt.show()

So why must I take abs to get "the plot that I want"? And what's the first one with negative amplitudes?