texts: How does one make a Zero Latency, Linear Phase, or Natural Phase filter?

texts:
Looking at FabFilter's ProQ3 plug-in, they have an option at the bottom of the window to switch between Zero Latency and Linear Phase modes (and I think a Natural Phase option too).

I'm familiar with BiQuad filters, I'm pretty confident I understand them quite well... but I don't know how FabFilter achieve these different latency and phase modes!

If anyone has any info or references about how one can go about implementing these different types of filters, It'd be much appreciated!


texts: Turn your guitar to MIDI and Guitar Synthesizer

texts:
I don't know if this question is related to DSP, but I'll give a chance.

Introduction:
These days there are a Guitar Synthesizers which allow the guitarist
to play another instruments like: brass, drums, strings, pianos and other guitar models
from his guitar.

It possible to turn any guitar with the MIDI Pickup, that sends the all data
that the synth needs.
Now, from what I understand the pickup turns the guitar into MIDI one.

My question is how a signals like those that the guitar makes can be converted into
MIDI instructions ?

There is a sampling before this conversion? I think that it should be, because if not.
How the Synth will know in which level (volume) or duration to produce the sounds?


texts: Does a filter need to completely attenuate high frequencies to be considered low-pass?

texts:
I'm looking at a system with a frequency response that is: $$H(e^{j\omega})=\tfrac{1}{4}(2\cos(\omega)+\cos(2\omega)+2)$$

I think the magnitude of this system looks like this (not sure what is the proper name for a function like this):

Would this be considered a low-pass filter even though the output is always greater than zero? If not, what would be the proper name for it?


texts:
Using MATLAB I need to subtract the background files from the real signal I am trying to measure. We took data of just the background noise prior to driving the system with some voltage, so we do not have to estimate the background, I need to know if i can subtract the two phase wise or how I can do this with the real and imaginary parts.

Thank you!!


texts: What is meant by 'combine the luminance and chrominance '

texts:
I am new with image processing. I'm trying to implement a research paper in MATLAB. I didn't understand a sentence.
Here it is:

  The luminance is enhanced by applying the proposed algorithm and it is
  combined with the chrominance and converted back to color image.

How can I "combine the luminance and the chrominance"?

Paper reference: Image enhancement with the application of local and global enhancement methods for dark images, 2017 International Conference on Innovations in Electronics, Signal Processing and Communication (IESC)


texts: What happens when I try to resample a speech recording from 8kHz to 16kHz?

texts:
I have a question regarding resampling in the context of speech. Given a speech recording sampled at 16kHz, downsampling to 8kHz will basically remove half of the samples (each 16000 samples become 8000). Now, I'm wondering about the inverse senario, given a telephony quality speech recording (300Hz -> 3400Hz) sampled at 8kHz, what happens if I try to resample the signal to 16kHz ? How will the 8000 additional samples for each second be computed ?

I tried this using sox and a new recording has been generated with no complaints or error messages, So my question is : how is this done ? Is there some kind of standard procedure, like an interpolation used to build the missing samples  ?


texts: Side Lobes in the Magnitude Response of a Low Pass FIR Filter

texts:
I have the impulse response (from the filter coefficients) of an FIR filter obtained from MATLAB's "interp" function using the command:
[y, b] = interp(x, 5); % where b contains the interpolation filter coefficients.
When I plot the magnitude response of this filter using "freqz" in MATLAB, I get the following

What do those side lobes between 0.5 and 0.7 (x pi rad/sample) and 0.9 and 1 (x pi rad/sample) mean for my FIR filter? Why are they there?


texts: How to make bode plot when output signal changes amplitude?

texts:
When I do frequency analysis on my feedback controlled system and the controller is really tightly tuned, I get a frequency response that looks like this:

Blue is excitation signal and green is system output signal. Does this mean that my system has nonlinear behavior? Or this just a condition that would be visible when hitting a zero or a pole?

Smaller frequencies work fine and produce a sine wave output that is easy to interpret. It is higher frequencies that end up looking like this.

Since I intend to use this to derive a bode plot, I'm also curious how do I interpret this data and what is the actual magnitude and phase on this plot for this frequency? It seems to me like it is fairly random. How would I go about sweeping frequencies and making a bode plot when many frequencies in this region look like this? FFT maybe on both signals? But how exactly?


texts: Does a .wav file created from a .mp3 file have better quality than the .mp3 file itself?

texts:
A .wav file created from a .mp3 file has the same frequency domain plot as the mp3 file itself https://stackoverflow.com/questions/58706674/difference-between-frequency-domain-in-mp3-and-wav.

However, the .wav file created from .mp3 file has larger file size. According the post https://stackoverflow.com/questions/15593806/why-is-a-wav-file-created-from-a-mp3-file-much-larger-in-size, this is because the .wav file is storing much more data than the mp3 file is.

Now, is there any difference in the quality between the .wav file and .mp3 file?

Does the quality of .wav file sound better since it has more data stored?


texts: what does "derivative" means in image processing?

texts:
In image processing and especially edge detection, when we apply sobel convolution matrix to a given image, we say that we got the first derivative of the input image, and when applying the laplacian matrix to the initial image we say that we got the second derivative.

Taking into consideration that in both cases we applied the same operation (img * matrix), then why the first operation gave us the first derivative, and the second one gave us the second derivative and not the fifth ? is the values of the mask (convolution matrix) which decide which derivative we got ? or I'm already mistaken in my description ?


texts: What is the advantage of multiple antenna in receiver in energy harvesting ?harvested more power?

texts:
What is the advantage of multiple antenna in receiver in energy harvesting ?

Assume there are $3$ transmitted antennas in the A device,and $1$ received antenna in the B device,now assume A device use beamforming with $3$ antenna to transmit some signal to B device,and B device harvest $0.1W$ power from the signal.

Now if i add one more received antenna to device B,that is, there are $2$ antennas in B device now,and assume these two antennas are very closed,how much power will device B harvest now? still $0.1W$? or $0.1W\times2$ ?

I am confused about this question,because if device B still harvest $0.1W$,then what is the advantage  of multiple antenna in receiver in energy harvesting ?

If device B harvest $0.1W\times2$,and this mean if i want to create power,i just use $1$ antenna to transmit 1W RF power to a receiver with $\infty$ antennas receiver,then i can get $0.1W\times \infty $ power ,but it is impossible .


texts: Why analog anti aliasing filter is used before analog to digital converter when there is already a digital filter after ADC?

texts:
Normal data acquisition consist of:

Analog anti aliasing filter( Sampling frequency : $5\textrm{ kHz}$)
ADC - Digital Filter - (Sampling : 200K samples /sec)
Digital low pass filters Filters
DAC

Questions:

My question is why analog anti-aliasing filter is used when their is already a digital low pass filters after ADC to prevent anti aliasing.
If analog anti-aliasing filter have sampling frequency $5\textrm{ kHz}$ , the system will not take frequency greater than $2.5\textrm{ kHZ}$,

then why ADC frequency is $200\textrm{ kHz}$?
Doesn't analog anti-aliasing filter  sampling frequency limit overall system frequency ?


texts: Wavetable and Nyquist: which size do I need?

texts:
I was reading this tutorial by the master earlevel, while trying to build some sort of wavetable.
He says First, let’s back up and figure out how long our tables need to be. Recalling that we need to sample a signal at greater than twice the highest frequency component, that means that for 368 harmonics, we need at least 368 x 2 + 1 samples, or a table length of at least 737 samples., refering to a 40hz (lowest wavetable frequency) and the following harmonics (up to 14720 hz).
Not really sure about those 737 samples keeping the sampling theorem by Nyquist.
Should be 40 * 368 * 2 + 1 samples needed? That's the real "highest frequency component" of the signal.
Why 368 * 2 + 1?
Not really sure why I just need a 737 samples to express a signal that reach ~15khz.


texts:
I am using Delphi trying to make a very simple speech recognition system. The system collects raw data well, but I have a hard time turning the data into a spectrogram:

The system collects an array with $1024$ integer values for each $100$ ms.

I try to FFT this array into $(R, I)$, and plot time on the $x$-axis and $\sqrt{R^2 + I^2}$ on the $y$-axis, but no frequency bands appears.

Does anyone know what I should do in stead? Source code in any language is very welcome.


texts: High performance DSP processor with better on-chip memory

texts:
I am currently using a combination of 4 ADSP 21469 because of the complexity and huge chunk of code that I currently have. BOOT and application will execute from external Flash memory. The code for radar processing are equally distributed across 4 DSPs

Even after splitting the code across 4 DSPs, I still need to perform code optimization because of memory constraint. By doing a certain level of optimization, my variables are not accessible due to which I have to read from the registers, which vary all the time.

My thought was to use a single advanced processor that is robust enough to contain all the code so I can use common libraries wherever I can to make my code efficient on target.

To summarize, the bottleneck is that ADSP 21469 has 5 Mbits of on-chip RAM, 4 Mbits of on-chip ROM which is way less than my requirement. If I can use a multicore processor(Ex:quad code) that works at >=400 Mhz, which has an on-chip memory of >=20 Mb to hold all my data fr a faster access or supporting external memory without being slower in accessing the data.


texts:
I am using Digital Signal Processing Principles, Algorithms, and Applications 4th edition and by Proakis. Here is what I don't understand

say the signal $x_a(t)$ has its Fourier Transform $X_a(F)$ and digital signal $x(n)=x_a(nT)$ which is $x_a(t)$ after sampling with sampling frequency $F_s$  has its DTFT $X(f)$

since
$$x_a(t)=\int^{\infty}_{-\infty}X_a(F)\,e^{j2\pi Ft}dF\tag{1}$$

because $x(n)=x_a(nT)$ and $nT=\dfrac{n}{F_s}$
$$x(n)=x_a(nT)=\int^{\infty}_{-\infty}X_a(F)e^{j2\pi nF/F_s}dF\tag{2}$$

Using inverse DTFT for $x(n)$ then

$$\int^{\frac12}_{-\frac12}X(f)e^{j2\pi nf}df=\int^{\infty}_{-\infty}X_a(F)e^{j2\pi nF/F_s}dF\tag{3}$$

for $f=\dfrac{F}{F_s}$ then

$$\int^{\frac12}_{-\frac12}X(f)e^{j2\pi nf}df=\frac{1}{F_s}\int^{\frac {F_s}{2}}_{-{\frac {F_s}{2}}}X(F)e^{j2\pi nF/F_s}dF\tag{4}$$

That is what the book says and it use that to explain the reconstruction process in theory. However isn't it will be like this according to substitution in integral

$$\int^{\frac12}_{-\frac12}X(f)e^{j2\pi nf}df = \frac{1}{F_s} \int^{\frac {F_s}{2}}_{-{\frac {F_s}{2}}}X\left(\frac{F}{F_s}\right)e^{j2\pi nF/F_s}dF\tag{5}$$

I think this should be in Math Section but since it is about Digital Signal so I post it here.


texts:
I had implemented a $4^{\rm th}$ order Chebyshev I Band Pass IIR Digital Filter in Simulink to separate out $148\textrm{ Hz}$ frequency from the sum of the following waves.

Input Waves

$$
\begin{array}{|c|c|c|c|c|}\hline
\text{Amplitude} & \text{Bias} & \text{Frequency} & \text{Phase}& \text{Sampling Rate} \\
\hline
14 & 0 & 1\textrm{ Hz} & 0 & 1000\textrm{ Hz}\\
15 & 0 & 148\textrm{ Hz} & 0 & 1000\textrm{ Hz}\\
12 & 0 & 50\textrm{ Hz} & 0 & 1000\textrm{ Hz}\\
10 & 0 & 150\textrm{ Hz} & 0 & 1000\textrm{ Hz}\\
13 & 0 & 100\textrm{ Hz} & 0 & 1000\textrm{ Hz}\\
\hline
\end{array}
$$

This is the input FFT. The FFT's  seems to indicate that the filter is doing its job but the output wave has a low frequency component (as seen on scope) which is not reflected in the FFT.

This is the output wave and FFT

function l = fft_plot(x,Fs)
x=x.data;
l=size(x,1)-1;
y=fft(x);
p2 = abs(y/l);
p1 = p2(1:l/2+1);
p1(2:end-1) = 2*p1(2:end-1);
f=Fs*(0:(l/2))/l;
plot(f,p1);
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|');
l;

This is the function I use to plot the the frequencies.

Can someone help me identify the source of this discrepancy?


texts:
I am working on a SLAM algorithm as part of my research and I am having issues reliably  extracting landmarks from sensor (Kinect) data.

(I've never dealt with machine vision before.)

I am looking to detect corners and their range/heading in real-time (close to 100 Hz if possible?).
The main control software runs on Matlab.

My current method does the following:
1) Median filter on depth data
2) Get middle horizontal depth frame (1x640 vector)
3) `clusterdata` to segment
4) least squares line fit segments
5) merge segments that are adjacent with similar slopes
6) find intersections of /good/ data

My results are mediore at best. Current CornerDetection.m if anybody is curious.

Am I approaching this wrong? Should I be looking at full frames instead of a single row? Should I be using any /big-boy/ of the methods I keep reading about? (Hough transform, Harris, Canny, LSD) Are there real-time methods for doing these kinds of processing operations on typical (intel i3) laptop? I've been shying away from them due to their (percieved) processing requirements.

The landmark extraction is not the focus of the project, and the method need not be original at all. Any required reading or pointers or Matlab functions I should look at would be very helpful.

Full Disclosure: I have a similar question over at StackOverflow but a friend mentioned that this SE does the /real/ MV.

EDIT: I should add, the environment is highly structured and is almost entirely square hallways on flat floors.


texts: Unable to understand how the paper simplifies the covariance matrix - Kalman filter

texts:
The paper Convergence Analysis of the Unscented Kalman Filter for Filtering Noisy Chaotic Signals

presents the convergence analysis of Unscented Kalman Filter

download
http://www.eie.polyu.edu.hk/~cktse/pdf-paper/ISCAS07-Feng1.pdf . The Measurement update equations from Eq16 -- Eq19 are clear to me but I don't understand how Eq(20) is derived which is $P_n = K_nR_n$ where $P_n$ is the covariance of the filtering error and $R_n$ is the covariance matrix of the measurement noise. Can somebody please show the steps how Eq(20) is reached ? I tried something like this starting from Eq(18) but I am stuck --

$$ P_n = P_n^- - K_n P_{y_n y_n}K_n^T,$$
$$ = P_{y_n y_n} - R_n - K_n P_{y_n y_n}K_n^T  $$ (substituting Eq 19)
$$ = P_{x_ny_n} - K_n P_{y_n y_n}K_n^T   $$


texts: GNU Radio | Transceiver loopback adapted | Transmission stops unexpectedly

texts:
(This is a follow up question to a previous question: link)

I have implemented a flowgraph of a transceiver loopback inspired by the examples found at gnuradio/gr-digital/examples/packet, with a slight change - instead of driving the Packet_tx with:

Message Strobe > Random PDU Generator > Packet_tx

I am using:

File Source (/tmp/in_strings.txt) > Throttle > Stream to Tagged Stream > Tagged Stream to PDU > Packet_tx.

Then the data is recovered by the Packet_rx with:

PDU to Tagged Stream > File Sink (/tmp/out_strings.txt)

Flowgraph below:

My expectation: I was hoping to transmit most of the data from in_strings.txt to out_strings.txt

What really happened:

Chunks of data are lost during transmission in an intermittent fashion. Diff below:

Transmission stops unexpectedly after ~40kB.

The files involved in this experiment:

loopback3.grc
in_strings.txt
out_strings.txt
packet_tx.grc, packet_rx.grc: gnuradio/gr-digital/examples/packet

I wonder what may be the cause of this?
Thanks in advance!


texts:
I know the z-transform of an upsampler is:

$$
y[n] = \begin{cases}
x(n/L) &n=0,\pm L, \pm 2L, ...\\
0&otherwise
\end{cases}
\longrightarrow  Y(z)= X(z^{L})
$$

if $x[n]_L$ is defined to zero for $n <0$ and $n \ge L$ and to be non-zero over interval $[0, L-1]$...then, what's the Z-transform of:

$$
y[n] = \begin{cases}
x[n]_L & 0 \le n \le L-1\\
0&otherwise
\end{cases}
\longrightarrow  Y(z) = ???
$$

its kind of like:

$$
y[n] = x[n]\ u[-n + L]\ u[n]
$$

I have this z-transform for LPF that is similar, but doesn't match:

$$
\begin{cases}
y[n]=a^{n}&0 \le n \le L-1 \\
\\
0& otherwise
\end{cases}
\longrightarrow  Y(z) = \frac{1-a^Lz^{-L}}{1-a{\ z}^{-1}}
$$


texts: IID noise assumption at Matched Filter sample time

texts:
I read that at the correct sample times of a matched filter output the noise is independent assuming a Nyquist pulse.

Can someone provide a proof of this or explain it more? Assuming your matched filter duration had a longer duration than your sample period, it seems the sample noise should be correlated.

Why is this not the case?


texts: Least Square Error Estimation: Conditions for $ (A^TA)^{ -1} = A^{-1}(A^T)^{-1} $?

texts:
I am new to linear algebra and have this simple question...
in least sqaure estimation...the best estimation of the equation $Ax = b$ is $x_{Estimated} = A (A^t A )^{-1} A^t b$...the projection of $b$ on the column space of $A$ is $p = A (A^t A)^{-1} At b$ which is written as $p = P b...P$ is the projection matrix = $A (A^t A)^{-1} A^t$
now using inverse rule $(AB)^{-1} = B^{-1} A^{-1}$  .......$P$ reduces to $I$ ....so is the projection matrix $P$ just the identity matrix $I$ ..?? am i missing out some basic or is my concept not clear? can we write $(A^t A)^{-1}  = A^{-1} (A^t)^{-1}$ always??


texts: Expression related to Tellegen's theorem and signal flow graphs

texts:
I'm reading the paper "Signal Flow Graphs-Computer-Aided System Analysis and Sensitivity Calculations" by Arnold Y Lee and my question in about expression/equality (59) in the paper. The expression looks like this:

$$
\Sigma_{i=1}^r \hat{y}_i(t) * \Delta y_i(t) + \Sigma_{i=1}^q \hat{x}_i(t) * \Delta x_i(t) = \Sigma_{i=1}^m \hat{u}_i(t) * \Delta u_i(t) + \Sigma_{i=1}^q \hat{v}_i(t) * \Delta v_i(t)
$$

I do understand the derivation of the foregoing theorem and I also follow the derivation of (40) and (46), which is:

$$
\Sigma_{i=1}^r \hat{y}_i  y_i + \Sigma_{i=1}^q \hat{x}_i x_i = \Sigma_{i=1}^m \hat{u}_i u_i + \Sigma_{i=1}^q \hat{v}_i  v_i
$$

and I also understand the steps leading to (48)

$$
\Sigma_{i=1}^r \hat{y}_i  \Delta y_i + \Sigma_{i=1}^q \hat{x}_i \Delta x_i = \Sigma_{i=1}^m \hat{u}_i \Delta u_i + \Sigma_{i=1}^q \hat{v}_i  \Delta v_i
$$

But I do not understand how to derive or explain (59).

The appearance of the convolution operator is not really explained and it is not obvious to me how to explain it. I hope some smart people here can help (?)


texts: What is the difference between convolution and cross-correlation?

texts:
I've found on multiple sites that convolution and cross-correlation are similar (including the tag wiki for convolution), but I didn't find anywhere how they differ.

What is the difference between the two? Can you say that autocorrelation is also a kind of a convolution?


texts: O(1) peak segmentation algorithm in matlab?

texts:
I have an intensity image, similar to the image below.  I would like to very quickly, segment this image, into separate peaks.  Where each peak is labelled, and segmented.  A notional segmentation of 3 blobs is given below by the black lines.

Definition of a peak segment is:  The contour that just crosses the highest saddle point between this peak and an adjacent peak.

This has to be a well studied problem, but I can't figure it out.  I have been looking at the Matlab functions:

imregionalmax
imreconstruct
imhmax

all of which are close.... It is not hard to write an algorithm to do this (see below) using imreconstruct to operate on the tallest peak, segment out the first peak, and repeat.  The algorithm below is O(N) in number of peaks.  Such an algorithm can and should be O(1) in number of peaks (and this is important for my application.)

The above image was rendered in matlab with the command

imagesc(peaks)

Here is an algorithm that performs the segmentation:

a = peaks;
peakValsX = [21, 25, 35];
peakValsY = [20, 38, 25];

N = numel(peakValsX);

clear('peakImgs', 'peakMask');
for ix = 1 : N;
    aptImg       = zeros(size(a));
    aptImg(peakValsY(ix), peakValsX(ix)) = a(peakValsY(ix),peakValsX(ix));
    peakImgs(:,:,ix) =  imreconstruct(aptImg,a);
    % All we've done is eliminated the other peaks.
    assert(all(reshape(peakImgs(:,:,ix) <= a,[],1)));
end

for ix = 1 : N
    peakMask(:,:,ix) = ix*(max(peakImgs(:,:,setdiff(1:N, ix)),[],3) < a);
end

peakMaskResult = max(peakMask,[],3);
imagesc(peakMaskResult);

And the resulting segmentation:

To Reiterate.  The question is, "Is there a matlab implementation of the peak segmentation algorithm (as described above) that can be executed in O(1) of number of peaks?"


texts: After upscaling a signal what noise metric to use for noise qualification

texts: If I have a 2d signal (like image) and interpolate (linear) it to get an upsampled signal, how can I qualify the noise, with which metric? STD changes between the signal and its'upsampled counterpart and I believe that the variance changes as well. So which metric to use to show that the signal is noised to the same degree?


texts:
I've designed an IIR bandpass elliptic filter in Scilab with the following parameters.

Sampling Frequency     = 25000 Hz
Lower cutoff frequency = 100 Hz
Upper cutoff frequency = 150 Hz
Pass band ripple = stop band ripple = 0.001 ~ 0.005 dB

When I compute the group delay of this filter, I get a value of about 31 samples at a frequency of 125 Hz.

However, when I filter a 125Hz signal using the flts function, I see that the delay doesn't really line up with the number 31.

If the group delay was 31 samples, shifting the output signal back by that number would align it with the input signal which is the behavior I've seen with all FIR filters (N -1 / 2). Of course, the group delay doesn't vary with frequency in FIR filters but I'm looking at just this one frequency (125 Hz) at the moment.

Is the group delay correct? If so, why wouldn't the output align with the input if it is shifted? Given below is the full Scilab code.

Fs = 25000;
Flp = 100;
Fhp = 150;

filterTf = iir(3,'bp','ellip',[Flp/Fs Fhp/Fs],[0.001 0.005]);

figure("BackgroundColor",'1|1|1');
bode(syslin(1/Fs,filterTf),0.01:0.05:Fs/2);

t = 0 : 1/Fs : 0.1;
inputSignal = 10 * sin(2 * %pi * 125 * t);
filteredSignal = flts(inputSignal,filterTf);

figure("BackgroundColor",'1|1|1');
xtitle('Signals','Samples','Signals');
plot(inputSignal,'r-','LineWidth',2);
plot(filteredSignal, 'k-','LineWidth',2);
legend(["Input Signal";"Filtered Signal"],"out_upper_right");
xgrid(1);

figure("BackgroundColor",'1|1|1');
[tg,fr] = group(25000,filterTf);
plot(fr,tg);
xgrid(1);


texts: The precise meaning of 'coefficient' in signal processing

texts:
when I read papers on signal processing, I often see the term 'coefficient' being used to refer directly to 'samples', i.e. "We can reduce the number of coefficients, by simply subsampling the even samples." or in presentations on the lifting scheme (wavelets), it seems the output of the low pass filter is also called coefficients.

To me, the output of a low pass filter is a 'smoothed' version of the original input sequence. Further, to me, a coefficient is e.g. a, b in  y[n] = ax[n] + bx[n-1]. In this sense, the coefficients a and b certainly is a representation of the signal-- but i would not call y[n] the coefficients.

I am probably very confused about the terminology. Could someone clarify this with some intuition?


texts: Is PSOLA or WSOLA better for vocal stretching/retuning?

texts:
I'm looking to implement a time-domain pitch modification algorithm such as PSOLA (Pitch Synchronous Overlap and Add) or WSOLA (Waveform Similarity Overlap and Add).
At the moment I'm using PSOLA, but it seems to me that WSOLA would be more robust to polyphonic signals with complex waveforms, whereas PSOLA works better with monophonic signals such as vocals. I feel it could be better to future-proof by using WSOLA, even though I'm only interested in monophonic signals for now.
I'm wondering if there is any disadvantage to using WSOLA as opposed to PSOLA.
It seems both techniques work in a similar fashion, both identifying repetition within the waveform, although WSOLA does not necessarily lock to the fundamental. Does fundamental locking make PSOLA superior for vocals?
To be more precise, I'm trying to work out the advantages and disadvantages of WSOLA vs PSOLA for the following tasks:

Pitch correction
Time correction
Formant correction


texts: suppose if we send AM modulated message signal through space how the receiver will be knowing that we applied AM modulation?

texts: suppose if we send AM modulated message signal through space how the receiver will be knowing that we applied AM modulation basically how it will be knowing that which modulation is applied for our modulated signal


texts: Identifying the age of a speaker using speech recognition

texts:
I am just wondering if it's possible to gather the age group of someone speaking in a sample?

For example, could I tell whether the sample is a child, teenage, adult, etc?


texts: Direct and Transpose Polyphase Multirate Processing

texts:
Polyphase implementations of upsampling/ interpolation and downsampling/ decimation, after having invoked the Noble identities, are presented as follows (taken from Proakis):

(Three-Channel Polyphase Decimation)

(Three-Channel Polyphase Interpolation)
The decimation always seems to use the direct form (delay before filtering), while the interpolation always seems to use the transposed form (delay after filtering). I understand that these two forms are equivalent (or believe that's the case). But I'm unable to find an explicit discussion on why this is canonical; why, for instance, doesn't the interpolation use the direct form? I've seen a couple of suggestions that it has something to do with the critical path, but I'm not clear on precisely what this means.
Could anyone clear this up? I suspect I'm being a bit obtuse...


texts: Why does the DFT have only $N$ components in it? I can see that after N components the frequency component is periodic and repeats with the same values but that does not seem to explain why we can have only $N$ components. Is this related to the sampling theorem? How does this all tie together?


texts: What scale should a detected SIFT point be extracted at?

texts:
I've heard this from a few different researchers but I can't find a definitive value.  Given the "scale" extracted by David Lowe's SIFT detector, we need to extract a descriptor at a specific scale.

Is it 6 times the detector "scale"?  3?  1?  I've heard conflicting values.  What is known about this?


texts:
I have a signal sampled at 40MHz, I would like to resample it to 37MHz. The signal is not periodic, I did resampling with Matalb resample function and it doesn't cause phase shift (as far as I understood). Matlab applies an anti-aliasing FIR filter and compensate for the delay introduced by the process.

I want to do the same process in Python. I know there is a resample function in scipy.signal but the documentation is not clear for me. Does the resample function introduces phase shifts?

if so, there is also a decimate function in scipy as well which applies similar FIR filter. Should I use decimate function over resample?


texts: Can you help me with this question. Can you explain where i should start to solve the problem.


texts: is there a mathematical relation between percent overlap and window length or amplitude

texts:
I am trying to plot short time energy of an utterance with percent overlap as an input variable.

As I referred to the short time energy equation it can be represented as square summation of $x(n)*w(n-m)$ where $w(n)$ seems to be window length.
But I couldn't figure out how to write it as percent overlap.


texts:
I've implemented a few FIR filters into a song equalizer, but there seems to be a crackling that I'm unsure how to fix.
Heres a video for reference: https://www.youtube.com/watch?v=IlzWRYpv0rk. Noise starts at 10s into the video.

Here's the programs current flow:

Create filters -> Convert them to frequency domain;

Read .wav file -> Apply FFT -> Multiply each frequency bin by sum of filters output -> Apply IFFT -> Play.

FFT has 1024 samples, Filter has 1024 samples.

Also, I'm unsure about when to implement overlap-add. Should it be on filter-data multiplication? In this case, should my filters should have a lower size? It seems like every video on youtube is lacking on where OA should be used. If you guys have good resources on that, I would greatly appreciate it.

Thanks for any help!


texts: Constructing $X(\omega/2)$ from the FFT of $x[n]$

texts:
Let $X(\omega)$ be the Discrete Time Fourier Transform (DTFT) of $x[n]$, I want to construct $X(\omega/2)$.

Precisely, I use FFT function to compute the samples of $X(\omega)$ in one period, say $[0, 2\pi]$. I want Construct samples of the $Y(\omega)=X(\omega/2)$ in that period.

My work:

Since dividing frequency by 2 stretch the signal, the values in $[0, \pi]$ of $X(\omega)$ cover all the $[0, 2\pi]$ space of $Y(\omega)$. On the other hand, the values in $[\pi, 2\pi]$ of $X(\omega)$ cover all the $[0, 2\pi]$ space of $Y(\omega)$ too.

Let X be a vector with size of n that  contains the samples of $X(\omega)$, so to construct vector Y that contains the samples of $Y(\omega)$ I use the following Matlab code

Y = (kron(x[1:n/2], [1, 1]) + kron(x[n/2+1:n], [1, 1]))/2

Is my work correct?
Thanks.


texts: Definitions of PSD, ESD and Autocorrelation

texts:
This question is going to encompass multiple areas and may not have a single answer but here it goes. I'm trying to conceptualize 3 different concepts and how they relate to each other. These 3 concepts are:

Energy Spectral Density (ESD) which I'm initially defining as $$\widehat{S_{xx}}=|\hat{x}(f)|^2$$ where $$\hat{x}(f)=\int_{-\infty}^{\infty}x(t)e^{-2\pi ift}dt$$ and $$\int_{-\infty}^{\infty}|\hat{x}(f)|^2df=  \int_{-\infty}^{\infty}|x(t)|^2dt$$ from Parseval's theorem.

Next my definition for autocorrelation for a (WSS) stochastic process:

$$(1)R_{xx}(\tau)=E[X(t)X(t+\tau)]$$ this seems to be at disagreement for a different definition for autocorrelation namely for signals which is $$(2)\int_{-\infty}^{\infty}x(t)x(t+\tau)dt$$ I would expect the definition for signals to be $$\lim_{T\to\infty}\frac{1}{2T}\int_{-T}^{T}x(t)x(t+\tau)dt$$ since for ergodic stochastic processes, the two would converge to the same thing.

Finally for Power Spectral Density (PSD) I would define:

$$S_{xx}=F\{R_{xx}(\tau)\} $$ or the fourier transform of the autocorrelation function. This clearly depends on the definition. For (2) this is $$S_{xx}=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}x(t)x(t+\tau)e^{-2 \pi if\tau}dt d\tau$$
$$\int_{-\infty}^{\infty}x(t)\int_{-\infty}^{\infty}x(t+\tau)e^{-2 \pi if\tau}d\tau dt$$
$$\int_{-\infty}^{\infty}x(t)\int_{-\infty}^{\infty}x(u)e^{-2 \pi if u}e^{2 \pi if t}du dt$$ $$\int_{-\infty}^{\infty}x(t)e^{2 \pi if t}\int_{-\infty}^{\infty}x(u)e^{-2 \pi if u}du dt$$ $$S_{xx}=\hat{x}^*(f)\hat{x}(f)=|\hat{x}(f)|^2=\widehat{S_{xx}}$$ which makes no sense to me.

Using (1) (with ergodic process) $$S_{xx}=F\{R_{xx}(\tau)\}=F\{E[X(t)X(t+\tau)]\}$$  $$\lim_{T\to\infty}\frac{1}{2T} \int_{-\infty}^{\infty}\int_{-T}^{T}x(t)x(t+\tau)e^{-2 \pi if \tau}dt d\tau$$ $$S_{xx}=\lim_{T\to\infty}\frac{1}{2T}(\hat{x}^*(f)\hat{x}(f))=\lim_{T\to\infty}\frac{1}{2T}|\hat{x}(f)|^2=\lim_{T\to\infty}\frac{1}{2T}\widehat{S_{xx}}$$ which makes a lot more sense to me. So my question is, what is the definition of Autocorrelation (and is it context dependent).Subsequently what is the definition of PSD and ESD and how do they relate to each other and to autocorrelation. It seems like terminology is lacking "standardization" so that the meaning of something could be completely dependent on the context and the author. Any help on consolidating these notions would be greatly appreciated.


texts:
If the sampling rates at receiver and at transmitter are different, there will be ICI.
However I don't find any practical technique to estimate and compensate this kind of error. Is it true that we always assume that error is small and ignore it?
What would the constellation look like if we have sampling rate error?
Any suggestion is appreciated.


texts: How to find the energy of a rect signal?

texts:
Given a signal
$$
x(t)=-2\operatorname{rect}\left(\frac t4\right)
$$

What is the energy of signal $-x(t + 1)$?
What are the steps needed to find the energy?


texts: What Are the Limitations of a Canny Edge Detector?

texts:
Broadly a majority of the literature on edge detection algorithms and applications that uses edge detection, references Canny's edge detector.  So much so that it looks like almost "the solution" to edge detection. Certainly, it would do the best job balancing noise and preserving edges.

However, as a simple curiosity, is there an area of concern for Canny's edge detector? or are there areas of applications where Canny will not be best?

In this context, faster implementation is not really concern. The focus of edge detector being good or bad should be the quality and utility of edges generated.

Also, I am really not focusing on implementation specific issues. I am looking for more theoretical limitations or characteristics inherent in the algorithm.


texts: Locating reference audio in longer audio

texts:
I'm trying to solve the following problem:

Let's say I have a reference sound and a recording that I know contains at least one occurrence of the reference sound. How can I determine the positions in the audio where the sound was played? It's possible that the longer recording could have noise, and I cannot assume perfect time alignment with the sound that's playing in the recording (meaning, if I knew the content of the sound played in the recording other than the reference sound, I cannot just subtract that from the recording itself).

The method I'm experimenting with is as follows:

Grab windows the size of the reference sound from the recorded sound
For each window, compute the N dominant frequencies (by finding peak magnitudes in the FFT results)
Assign points to the dominant frequencies of the reference sound (where the most dominant gets a score of N, and the least gets a score of 1)
Compare the window's dominant frequencies to these and score it

The next few parts are just experimental, and used to narrow down results.

Do some filtering on the matches (for instance, a match with a score lower than half the possible score gets filtered out)
Look at overlapping matches and compute the cross correlation with the reference sound (using every possible time shift, prefer the maximum result). Prefer the match which requires the smaller shift
Perform that shift on the match's endpoints

The problem is that I want to also detect if part of the reference sound was played, and step 6 would not allow that if the reference sound was played two times in quick succession where one was cut off.

It seems like there has to be a solution that's not as ad-hoc as this. I'm very new to the field of DSP, so there may be something simple that I don't know about.

Any ideas?

Thanks!


texts: What is EAQUAL ? How does it relate to PEAQ?

texts:
This wiki post on wiki.hydrogenaudio.org says that it is very similar to PEAQ and also a part of ITU-R BS.1387 recommendation ? How reliable it is for determining audio quality.

Are there any other open implementations of PEAQ that are good.


texts: Using Fast Fourier Transform to determine musical notes

texts:
Hi guys i am doing a course in Digital Filters and Spectral analysis. We are given a coursework/homework, and I have absolutely no idea what to do with it. I come from Maths background, never done any signal processing before, and since I am new to the university I don't really have anyone to ask.

Problem:

In this exercise you are required to use spectral analysis techniques to determine the musical notes played within a short audio sample (with sampling frequency 44.1KHz). The sample will comprise a short sequence of 5 chords, each comprising 3 or 4 different musical notes played concurrently. Each note comprises a fundamental plus a series of harmonics at multiples of the fundamental frequency. All of the notes in this exercise belong to the 12 note equal temperament scale.

Here is some piece of code I scrambled so far:

[x,fs] = audioread('sample1_va18535.wav');
fs % fs is the sampling frequency usually 44.1 KHz
wavplay; % Play audio
N = 4410; % 0.1 seconds at 44.1KHz
N1 = 2205; % 0.05 seconds
n = N1+1:N1+N; % 0.05 – 0.15 seconds
xn = x(n,1); % Select left channel of short clip
wavplay; % Play short clip
t = n/fs; % Time index
plot(t,xn);
xlabel('Time (s)');
ylabel('Amplitude');
window = hamming(N); % Create window
wxn = xn .* window; % Apply window
Xk = fft(wxn); % DFT
k = 0:N-1;
f=k*fs/N; % Frequency in Hz
pause;
plot(f,abs(Xk));
ylabel('Magnitude');
xlabel('Frequency (Hz)');

Now I am pretty sure this is far from over ( I am not even sure if this code is correct).Would anyone be so kind and explain to me how can I generate those frequencies? I know I am required to create a vector of fundamental frequencies and ignore any harmonics.

Here is the file: https://ufile.io/lyge5


texts: Why is the ideal low pass filter not achievable?

texts:
I find myself to be quite confused by some concepts of DFT. Suppose I have some spectrum-normalized signal (which I simply receive without any prior information) $$A\cos\left(0.5n\right)\ +\ B\cos\left(0.7n\right)\ +\ C\cos\left(1.2n\right)\ +\ D$$
with A,B,C,D being some constants
Now I find that the DFT of the same signal corresponds to a different set of basis functions given by $e^{\frac{2\pi jn}{N}}$ for N being the number of data points.
Now I can retrieve the signal by multiplying each "complex frequency component" with its "complex amplitudes" and adding them. Now my question is as follows:
If I apply an ideal low pass filter, I should get an infinite sequence of data points because the sinc function would have infinite points in it and convolution of it with an infinite set of data points would be again infinite and double-sided. (I hope this is a correct guess??).
But if I simply had a mechanism to be able to separate this unknown sequence into the above form, (say some alternate transform that would give me this decomposition instead of the exponential decomposition) then will I be able to design the "Ideal low pass filter" in that case just by knowing the above decomposition? I feel it can be proved (though the uniqueness I'm not sure) that such a decomposition will exist because it would be a set of N polynomials in the cosines of the found natural frequencies, like for the mth data point$$y\left(m\right)\ =\ \sum_{i=1}^{N}\cos\left(m\alpha_{i}\right)$$
where $\alpha_{i}$ is the ith frequency. Here the frequencies are normalized so the +$2\pi$ for each frequency idea cannot be used to refute the uniqueness
Also if I knew that the signal had exactly N points, then the signal could be represented at most by N real frequencies. Then why is the ideal low pass filter not realizable?
I sincerely apologize if the question was very naive, it could potentially be so.


texts: How to make color balance of photoshop using opencv

texts:
I want to make the same thing programmatically like Color balance in Photoshop , like in below image

if we have same bar positions in Photoshop then how we can make them in OpenCV , because the problem which I am not understanding is that we have the image with RGB format yes we can convert in other color format but how I can understand these values (do we need to subtract the Cyan values in OpenCV if Cyan Level is -20 in PS ? Or we need to Add ?) and did the same operation in OpenCV ,
For example if I need to change values in Cyan , Magenta and Blue Do I need to convert image first to add values in Cyan and magenta and then convert it back to BGR and then increase blue ?
And is there any built in function in OpenCv for Shadows , MidTones and Highlight

I am trying something like this

Mat img = imread("E:\\raw_3.jpg");
vector<Mat> colors;
split(img,colors);
colors[0] += 69;
colors[1] += 40 ;
colors[2] -= 23 ;
merge(colors,img);
imshow("image" , img);
imwrite("E:\\color_balance.jpg",img);
waitKey();

for Cyan - red = -23 Magenta - Green = 40 Yellow - Blue = 69 But i am not getting the accurate result as it should be


texts:
EDIT

The first version of my question has not worked as I expected, so that I will try to be a little bit more specific.

The final goal I am trying to achieve is the generation of a ten minutes time series: to achieve this I have to perform an FFT operation, and it's the point I have been stumbling upon.

Generally the aimed time series will be assigned as the sum of two terms: a steady component $U(t)$ and a fluctuating component $u^{'}(t)$. That is

$$u(t) = U(t) + u^{'}(t);$$

So generally, my code follows this procedure:

1) Given data

$time = 600 [s];$

$Nfft = 4096;$

$L = 340.2 [m];$

$U = 10 [m/s]$

$df = 1/600 = 0.00167 Hz;$

$f_{n} = Nfft/(2*time) = 3.4133 Hz;$

This means that my frequency array should be laid out as follows:

$$ f = (-f_{n}+df):df:f_{n} $$

But, instead of using the whole $f$ array, I am only making use of the positive half:

$$ f_{+} = df:f_{n} = 0.00167:3.4133 Hz; $$

2) Spectrum Definition

I define a certain spectrum shape, applying the following relationship

$$ S_{u} = \frac{6L/U}{(1 + 6f_{+}L/U)^{5/3}}; $$

3) Random phase generation

I, then, have to generate a set of complex samples with a determined distribution: in my case, the random phase will approach a standard Gaussian distribution $(\mu = 0, \sigma = 1)$.

In MATLAB I call

nn = complex(normrnd(0,1,Nfft/2),normrnd(0,1,Nfft/2));

4) Apply random phase

To apply the random phase, I just do this

$$ H_{u} = S_{u}*nn; $$

At this point start my pains!

So far, I only generated $Nfft/2 = 2048$ complex samples accounting for the $f_{+}$ content. Therefore, the content accounting for the negative half of $f$ is still missing. To overcome this issue, I was thinking to merge the $real$ and $imaginary$ part of $H_{u}$, in order to get a signal $H_{uu}$ with $Nfft = 4096$ samples and with all real values.

But, by using this merging process, the $0-th$ frequency order would not be represented, since the $complex$ part of $H_{u}$ is defined for $f_{+}$.

Thus, how to account for the $0-th$ order by keeping a procedure as the one I have been proposing so far?


texts:
I am working on the implementation phase and time recovery algorithm and have doubts. Could you please explain to me some question?

PLL for time and phase recovery

I have found I can use PLL not only for a carrier phase correction but also for time. Is there difference in implementation?
Reference: Digital communications a discrete-time approach by Rice

what should be first: phase or time recovery?


texts: Can the (point-wise) multiplication of two discrete band-limited functions be inherently aliased?

texts:
I'm not fully used to the language of DSP, so forgive me if I confuse some of the notation, or if the below is trivial.

I'm interested in the case where we want to do the point-wise multiplication of two discrete signals, $f[x_n]=g[x_n]h[x_n]$ for $n=0,\dots,M-1$. This is easy enough to do in the computer. However, I'll take a detour and formulate the problem in the (Discrete) Fourier domain, where the multiplication becomes a convolution:
$$
\widehat{f}[k_n] = \sum_{j=-M}^M \widehat{g}[k_j]\widehat{h}[k_n-k_j].
$$
Interesting is that (just like the MATLAB conv command) we get $2M-1$ outputs; i.e., the convolved signal is inherently longer than the original signal. If we take the result back to the sample domain, we have to throw away $M$ samples to get back to the original domain (or get back to sample domain and pick every second entry).

I ran the following test in MATLAB that seems to confirm my thought,

M=100;
x=[0:M-1];
g=sin(x/M*6*pi);
h=cos(x/M*6*pi);
f=g.*h;

ff = fft(f);gf = fft(g);hf = fft(h);
v  = ifftshift( (-1/2:1/M:1/2-1/M) + mod(M,2)/(2*M) ); % Normalized frequencies

figure(1); plot( x, g, x, h, x, f )
title('Discrete multiplication')
legend('g','h','f')

figure(2); plot( v, abs(gf), v, abs(hf), v, abs(ff) )
title('Spectrum')

This generates the following two figures:

and

that appears to confirm my thoughts. The spectrum of $f[x_n]$ (in yellow) is broader than the spectrum of either input signals. Then to get to the question in the title: (1) is it possible that the point-wise multiplication of two discrete, band-limited functions is aliased itself? And (2) although I was able to recreate the $f$ also using the convolution theorem using

ghf = conv( fftshift(gf), fftshift(hf)./M, 'same' );
gh  = ifft(ifftshift(ghf),'symmetric'); % = identical to the vector 'f'

would it be possible to circumvent the aliasing by outputing the 'full' convolution, thereby getting $2M-1$ samples back, rather than $M$ samples?


texts: analog-to-discrete-to-analog system sampling problem

texts:
This is not a homework problem, I am solving practice problems for my exam.

Consider the analog-to-discrete-to-analog system shown in figure 1. The CT signal $x_a(t)$
is sampled at a frequency of $F_s = 2000$ Hz ($T_s = 0.5$ msec). The resulting impulse train
is then converted to a discrete time sequence $x_d[n]$. The Lowpass DT filter $H_d(e^{j\Omega}$ is
subsequently used to filter $x_d[n]$ giving $y_d[n]$. Finally, a CT version of the output $y_a(t)$ is
created, using an ideal DT-to-CT converter (at the same sampling frequency $F_s = 2000$ Hz).

Note : $H_d(e^{j\Omega}$, which is obviously periodic, is shown for only one period.

a) For the CTFT of $x_a(t)$ given by $X_a(\omega)$ in the figure with $B = 2000\pi$ rad/sec, sketch the
$X_d(e^{j\Omega})$, the DTFT of the DT sequence $x_d[n]$.

b) Sketch $Y_a(\omega)$, the CTFT of the CT signal $y_a(t)$. Again, assume that we are using the
same frequency as that of sampling $F_s = 2000$ Hz.

I followed the following steps:

Step 1: Multiplied $x_a(t)$ by an infinite pulse train and then switched to frequency domain so I can have an expression for $X_d(\omega)$ in CTFT.

Step 2: After conversion, the "envelope" (which in this case is the triangular shapes) are not drawn but instead we have pulses, something like this:

(Excuse my very bad drawing skills) However, only the red lines exist in this case since we are now in discrete time.

Step 3: I believe in step 2 I have found how $X_d(e^{j\Omega})$ should look like. But then here I get stuck about how should I filter the signal. I get that the filter is periodic but how do I use this in here? Isn't the width of the filter much smaller than the width of the signal?


texts: Why $y[n] = x[-n]$ is not time-invariant?

texts:
I followed these steps, but the answer still says that this system is time-invariant

let: $x_2[n] = x[n-k]$

$$\begin{align}
y_2[n] &= x_2[-n] \\
 &= x[-(n-k)] \\
 &= x[k-n] \\
\end{align}$$

and

$$\begin{align}
y[n-k] &= x[(-(n-k)] \\
 &= x[k-n]
\end{align}$$

where am I wrong in the analysis?


texts: Correlation of independent random processes

texts: Suppose $X(t)$ and $Y(t)$ be two independent random processes. Is $E(X(t_1)Y(t_2))$ necessarily zero?


texts:
when it comes to digital I/Q signal power measurement we know that this power is viewed as $I^2+Q^2$ (as its polar form). This is the power as referred to final analogue signal. Yet the IQ modulator does not convert I/Q to polar form, instead only the final I is output to real world say in the RF modulator.
When I model two I/Q mixers it does not show that final power is $I^2 + Q^2$ but rather just $I^2$:

x = randn(1,1024)+j*randn(1,1024); %random I/Q input
sincos1 = exp(j*2*pi*(0:1023)*.01);
y1 = x.*sincos1; % first digital IQ modulator

sincos2 = exp(j*2*pi*(0:1023)*.1);
y2 = real(y1.*sincos2); %rf IQ mixer giving final analogue output

if you check power of y2 you will see it is close to real(y1) rather than complex y1.
I ask this because for all power dependent applications e.g. DPD we assume power is $I^2+Q^2$
what am I missing here?

Thanks


texts: Zero-frequency response of an IIR transfer function

texts:
I have a question about the zero-frequency (DC) response of a IIR filter. The coefficients of the 3rd order IIR filter are as follows,

% polynomial coefficients for the numerator of the IIR transfer function
b = [0.0066324, -0.0130292, 0.0063988];

% polynomial coefficients for the denominator of the IIR transfer function
a = [1, -1.4158855, 0.4158913];

Note that the roots of a are all less than unity, but one is quite close to the unity. I am trying to understand why MATLAB's filter() function produces the following results:

rng default;
x = rand(15,1);
y = filter(b,a,x);
mean(y)/mean(x)

>> 0.0012

In the last statement, I computed the ratio of the input and output mean, MATLAB returns 0.0012.

However, from the zero-frequency of the transfer function $H(z)=0.3448$ (i.e., sum(b)/sum(a)=0.3448), I have expected that mean(y)/mean(x)=0.3448. Checking this,

[H,W] = freqz(b,a);
H(1)

>> 0.3448

Have I misunderstood something here about MATLAB's filter() function, or other misconception of the zero-frequency response of a transfer function? Thanks to anyone who is able to provide an insight to this problem.


texts: Finding the closest match of a recorded word to a 'corpus' of singly-recorded words.

texts:
I am interested in learning more about processing audio and thought that it will be helpful to learn while doing a project. The project involves a pseudo-speec recognition where I have a corpus of singly-recorded audio of words, say apple.wav, bat.wav, cream.wav, dog.wav, that came from a text-to-speech program.

I have an 'unknown' audio file of a recorded audio of a word (spoken by a person) which is either the word 'apple', 'bat', 'cream', or 'dog'.

Suppose the spoken 'unknown' audio file is the recording of the word 'dog', how do i go about in matching that recording to the closest text-to-speech recording (i.e. dog.wav)?

(context: i want to built a system in our chemistry lab to log our waste disposal through speech e.g. the user talks through a computer saying "ethanol" and the computer records that audio and finds the closest recording of a chemical in the library of chemical audio recordings (ethanol.wav). The file name is then recorded in a database as a log of the disposal of ethanol)

This might be a duplicate but I have been browsing but I can't find anything.


texts:
Contextual knowledge (CK) is used in some AI application, Can someone give me a concrete definition of this term.

I am working on ontologies( a set of concepts and relationships among them) and computer vision. I basically aim at integrating knowledge (ontologies) and visual features extracted from images to leverage machine vision techniques.  I crossed one of the scientific research paper and I encountered the term "Contextual Knowledge" and they give no explicit or even abstract description of it and that makes me wonder about it. Intuitively, I believe, it is used in knowledge representation or knowledge based construction and it must have something to do with databases... But unfortunately, I couldnt find the concrete and informative information about it or even its use in different disciplines


texts: Which eigenvector to choose after calculating PCA

texts: After calculating the principal component analysis (PCA) of a given data set, we are normally left with a matrix containing the eigenvectors sorted in order of the size of the eigenvalues. Now, in pattern recognition which eigenvector should we choose: the first eigenvector or do we have to do further processing of the eigenvector in order to choose the desired eigenvector?


texts:
I have a signal $$ x(t)= \frac{1}{T} e^{-\frac{t}{T}} u(t) - \frac{1}{T} e^{\frac{t}{T}} u(-t) $$

and I know that it transits in a integrator circuit and I have to find y(t) in time and frequency domain. From theory on my book i know that

$$ y(t) = \int_{-\infty}^{t} x(\tau) d \tau $$

So I started to calculate this integral with my $x(t)$:

$$ \frac{1}{-RCT} \left[ \int_{0}^{+\infty} e^{\frac{-\tau}{T}} d\tau - \int_{—\infty}^{0} e^{\frac{\tau}{T}}d\tau \right] $$

but this gave me

$$ \frac{1}{-RCT} \left[  \dfrac{e^{-\infty } -1}{-\frac{1}{T}} - \dfrac{-e^{-\infty } +1}{\frac{1}{T}} \right] $$

and this gave me 0.

The correct result should be $$ -e^{ -\frac{|t|}{T} } $$

Thank you so much


texts:
I am having the entropy integral below where $\mathbf x$ is a $N$ dimensional Gaussian vector having variance as $\mathbf P$ and mean zero,

$$ -\int\frac {\exp\left(\frac{1}{2}\mathbf x^T\mathbf P^{-1}\mathbf x\right)}{{(2\pi)}^{\frac{1}{2}}|\mathbf P|^{\frac{1}{2}}}\log_2\left(\frac {\exp\left(\frac{1}{2}\mathbf x^T \mathbf P^{-1}\mathbf x\right)}{{(2\pi)}^{\frac{1}{2}}| \mathbf P|^{\frac{1}{2}}}\right) d\mathbf x$$

How do I solve this integral ? My approach is,  let

$$
\mathbf x=\begin{bmatrix}
    x_{1} \\
    x_{2}  \\
    \vdots\\
    x_{n}
\end{bmatrix}\quad\text{and}\quad \mathbf P=\begin{bmatrix}
    \sigma_{1} & 0 & 0 & \dots  & 0 \\
    0 & \sigma_{2} & 0 & \dots  & 0 \\
    \vdots & \vdots & \vdots & \ddots & \vdots \\
    0 & 0 & 0 & \dots  & \sigma_{n}
\end{bmatrix}$$

I am getting an integral like
$$-\displaystyle\int \frac {\exp\left(\frac{1}{2}\left(\frac{x_1^2}{\sigma_1^2}+\frac{x_2^2}{\sigma_2^2}+\ldots+\frac{x_n^2}{\sigma_n^2}\right)\right)}{{(2\pi)}^{\frac{1}{2}}|\mathbf P|^{\frac{1}{2}}}\log_2\left(\frac {\exp\left(\frac{1}{2}\left(\frac{x_1^2}{\sigma_1^2}+\frac{x_2^2}{\sigma_2^2}+\ldots +\frac{x_n^2}{\sigma_n^2}\right)\right)}{{(2\pi)}^{\frac{1}{2}}|\mathbf P|^{\frac{1}{2}}}\right) d\mathbf x$$
but I am confused how to do this $d\mathbf x$ stuff when $\mathbf x$ is a vector. Am I doing it right?

The answer given is

  $$\frac{n}{2}\log_2(2 \pi e)+ \frac {1}{2}\log_2|\mathbf P|$$


texts:
I tried the following code for modulation of two analog waves. Can anyone point to how to modulate and demodulate for an analog and a digital wave? I tried by replacing the second signal (x2) with a digital pulse but I am not able to recover the analog wave after demodulation.

T = 1;
Fs = 44100;
t = 0:1/Fs:T;
Fc = 17000;

f1 = 100;
x1 = sin(2*pi*f1*t);
f2 = 200;
x2 = sin(2*pi*f2*t);

Cs = sin(2*pi*Fc*t);
Cc = cos(2*pi*Fc*t);

%%Modulation
mod_wav = x1.*Cs + x2.*Cc;

%%Demodulation
demod_x1 = mod_wav.*Cs;
demod_x2 = mod_wav.*-Cc;

%%filter
fpass = 10; fstop = 500; N = 30;
b = firls(N,[0 fpass fstop Fs/2]/Fs/2, [1 1 0 0], [1 1]);
filt_x1 = filter(b,1,demod_x1);
filt_x2 = filter(b,1,demod_x2);

In the above code, if i use butter filter, then it is properly working but not if i use FIR like above. Why is that? In a broader sense, when to use butter and and when to use FIR filter?


texts: Lowpass : What is wrong with average filtering?

texts:
The question is : What is wrong with averaging as low pass filter ?

The details :
I want to lowpass filter a signal to downsample it.
The constraints are : I have no RAM available and I work in streaming, therefore I cannot use a weighting window to filter.
Consequently, I have to do either an average on the last X samples, or a classic filter like :

signal_t+1 = signal_t * (1-factor) + new_measurement * factor

with factor a value adapted to the sampling.
What is more, I know there are signals around a frequency just above the downsampling frequency.

Is it better to use the average or to use the 1-order filter described above ?

More details and tests :
I work with real samples, not complex. Sampling frequency = 200 Hz, frequency after downsampling = 4Hz.

Let's compare a 1-order filter, with a cutoff frequency of 1Hz to limitate aliasing, with two averaging filters. The first averaging filter is the average of 50 samples to downsample from 200Hz to 4Hz. The second averaging filter is an average on 66 samples to get as much rejection as with the 1-order filter.

I think that the filter "average on 66 samples" is the best :
The 50-samples average filter has a rejection higher than the 1-order filter, and I really need to limitate aliasing. But the 66-samples filter has a cutoff frequency larger than the 1-order filter and a rejection at least equal after 2Hz. What is more, the 66-samples filter cuts the frequencies around 3Hz and I know there will be signals on 3Hz that will make my signal noisy after the 4Hz downsampling - I work with real samples, not complex.

Then, I would chose the 66-samples averaging filter.

Is it something wrong in the logic above ?
Would you have suggestions ?

Here is the code :

import numpy as np
import matplotlib.pyplot as plt

nfft = 8192
fsampl = 200
dtsampl = 1 / 200
fcutoff = 1
dtcutoff = 1 / (2 * np.pi * fcutoff)
faverage1 = 4
faverage2 = 3

print("generate signal")
raw_signal = np.zeros(nfft)
raw_signal[int(nfft/2)]=1

print("filter signal")
filtered_signal = 0.*np.copy(raw_signal)
for i in range(1, np.size(raw_signal)):
    filtered_signal[i] = filtered_signal[i-1]+ (raw_signal[i-1]-filtered_signal[i-1]) * dtsampl / dtcutoff

averaged_signal_1 = np.copy( raw_signal )
num_average = fsampl / faverage1
for i in range(1, np.size(raw_signal)):
    averaged_signal_1[i] = np.average( raw_signal[int( max( 0, i - num_average ) ):i] )

averaged_signal_2 = np.copy( raw_signal )
num_average = fsampl / faverage2
for i in range(1, np.size(raw_signal)):
    averaged_signal_2[i] = np.average( raw_signal[int( max( 0, i - num_average ) ):i] )

print("get FFT")
raw_signal_fft = np.fft.rfft(raw_signal)
filtered_signal_fft = np.fft.rfft(filtered_signal)
averaged_signal1_fft = np.fft.rfft( averaged_signal_1)
averaged_signal2_fft = np.fft.rfft( averaged_signal_2)

raw_signal_fftlog = 20*np.log10(np.abs(raw_signal_fft))
filtered_signal_fftlog = 20*np.log10(np.abs(filtered_signal_fft))
averaged_signal1_fftlog = 20*np.log10(np.abs(averaged_signal1_fft))
averaged_signal2_fftlog = 20*np.log10(np.abs(averaged_signal2_fft))

print("plot")
freq_axe= np.linspace( 0, fsampl / 2, int( nfft / 2 ) + 1 )
plt.plot(freq_axe, raw_signal_fftlog, '-')
plt.plot(freq_axe, filtered_signal_fftlog, 'r-')
plt.plot(freq_axe, averaged_signal1_fftlog, '-')
plt.plot(freq_axe, averaged_signal2_fftlog, '-')
plt.plot([0.02, 100], [-3, -3], 'k:')
plt.legend(['raw signal (dirac)', '1-order 1Hz filter', 'average on 50', 'average on 66'],  loc="upper right")
plt.ylabel('amplitude (dB)')
plt.xlabel('frequencies (Hz)')
plt.xlim([0,8])
plt.ylim([-30,2])

plt.show()


texts: Period of a quasiperiodic digital signal

texts:
I have a signal made of a perturbed square wave, sampled so that there are at least six samples per period, for a total of 15 to 50 periods. The sampling frequency and the signal frequency are unrelated.

The perturbations are of several types:

jitter in the period (say 10%),
variable amplitude of the squares (say from 1 to 3),
additional arbitrary signal with an amplitude below 1, often localized.

I am looking for a simple, fast but robust computational procedure to estimate the average period (preferaby without a DFT or autocorrelation).

Typical example:


texts:
Assume I have a signal(BPSK) and it has a certain amplitude. I would like to add a noise with a certain power to it. Assume I am using coding rate Rc as well. One method I am thinking would be to consider

EbNo="value" Eb=sum(signal.^2)/(length(signal)

sigma^2=Eb/(2*Rc*EbNo);
noise=sqrt(sigma^2)*randn(1,length(signal));
rec=signal=noise;

However it seems power of my noise does not match what I expect. Does anyone have any other suggestion or algorithm or do you guys know if there is anything wrong with what I wrote.


texts: Equivalent number of looks (ENL) calculation

texts:
As stated in gagnon1997speckle in paragraph 2.2, under the unit-mean noise assumption one can say that:

\begin{equation}
ENL = \left(\frac{\bar{y}}{\sigma_{y}} \right)^2 = \frac{1}{\sigma_{n}^2}
\end{equation}

where
\begin{equation}
y = nx, \qquad \bar{y} = E[y]
\end{equation}

Can you help me to understand that assertion?

Thank you very much for your attention.


texts: How to explain IDFT of square root of a DFT?

texts:
I have this MATLAB code:

w = [1 2 3 2 1];
W=fft(w);
V=sqrt(W);
v=ifft(V);

And I need to explain how to get to $v[n]$ without using the direct formula for DFT - I need to use the properties of DFT.

I've tried solving the problem using circular shift and circular convolution but I can't seem to understand the result.

According to MATLAB, $v[n]=\textrm{[1 1 1 0 0]}$.


texts: Determining the causality of a signal with it's pole-zero plot

texts:
I have the following question:

  Pole-zero plot of x(t) and y(t) are given below:

  The signal $g(t)$ and $h(t)$ are defined as $g(t)=x(t)e^{-3t}$ and
  $h(t)=y(t)*e^{-t}u(t)$. If $g(t)$ and $h(t)$ are both absolutely
  integrable, determine whether the signals $g(t)$, $h(t)$  are
  left-sided/right-sided.

My try:

I take the laplace transform of both the signals and get $G(s)=X(s+3)$ and $H(s)=Y(s)\cdot \frac{1}{s+1}$

Also because both $g(t)$ and $h(t)$ are absolutely integrable, their transforms must be stable so both must have $jw$-axis in their respective ROC.

As we can see $X(s+3)$ shifts the pole-zero plot to the left by $3$ units so we have all the poles in the left $s$-plane and ROC would be $Re\{s\}>-1$ hence $g(t)$ is right sided.

Similarly $H(s)$ has all the poles in the left $s$-plane and ROC is again $Re\{s\}>-1$ hence $h(t)$ is right sided.

Is this reasoning correct?


texts: Finding parameters of exponentially decaying sinusoids (Matrix Pencil Method)

texts:
The matrix pencil method is an algorithm which can be used to find the individual exponential decaying sinusoids' parameters (frequency, amplitude, decay factor and initial phase) in a signal consisting of multiple such signals added. I am trying to implement the algorithm. The algorithm can be found in the paper from this link or this link.

In order to test the algorithm, I created a synthetic signal composed of four exponentially decaying sinusoids generated as follows:

fs=2205;
t=0:1/fs:249/fs;
f(1)=80;
f(2)=120;
f(3)=250;
f(4)=560;
a(1)=.4;
a(2)=1;
a(3)=0.89;
a(4)=.65;
d(1)=70;
d(2)=50;
d(3)=90;
d(4)=80;
for i=1:4
    x(i,:)=a(i)*exp(-d(i)*t).*cos(2*pi*f(i)*t);
end
y=x(1,:)+x(2,:)+x(3,:)+x(4,:);

I then feed this signal to the algorithm described in the paper as follows:

function [f d] = mpencil(y)

%construct hankel matrix
N = size(y,2);
L1 = ceil(1/3 * N);
L2 = floor(2/3 * N);
L = ceil((L1 + L2) / 2);

fs=2205;
for i=1:1:(N-L)
    Y(i,:)=y(i:(i+L));
end

Y1=Y(:,1:L);
Y2=Y(:,2:(L+1));

[U,S,V] = svd(Y);
D=diag(S);
tol=1e-3;
m=0;
l=length(D);
for i=1:l
    if( abs(D(i)/D(1)) >= tol)
        m=m+1;
    end
end
Ss=S(:,1:m);
Vnew=V(:,1:m);
a=size(Vnew,1);
Vs1=Vnew(1:(a-1),:);
Vs2=Vnew(2:end,:);
Y1=U*Ss*(Vs1');
Y2=U*Ss*(Vs2');
D_fil=(pinv(Y1))*Y2;
z = eig(D_fil);

l=length(z);
for i=1:2:l
    f((i+1)/2)= (angle(z(i))*fs)/(2*pi);
    d((i+1)/2)=-real(z(i))*fs;
end

In the output from the above code, I am correctly getting the four constituent frequency components but am not getting their decaying factors. If anybody has prior experience with this algorithm or has some understanding about why this discrepancy might be there, I would be very grateful for your help. I have tried rewriting the code from a scratch multiple times but it has been of no help, giving the same results.

Any help would be highly appreciated.


texts:
What options exist for discrete audio compression that is good quality, moderate compression (e.g. 3+:1), and low complexity (e.g. hundreds of processing cycles to encode each sample without the use of floating point), especially ones that are not patent-encumbered? The specific application is ambient sound - vocal and nonvocal audio.

I'm not very well-versed in this space of algorithms. I'm familiar with the high quality high compression algorithms, but even MP3 is too expensive for my purposes. The only low complexity moderate compression algorithm family I know is ADPCM, and I have no idea if any implementations of that could be considered good quality.

EDIT: Relevant question: what is the highest quality fixed-point ADPCM algorithm?


texts: Parks-McClellan - compiling C++ code from Iowa Hills page

texts: I am trying to compile C++ code for FIR filter design using Parks-McClellan algorithm from http://www.iowahills.com/Example%20Code/NewParksMcClellan.txt . However, I cannot find the following header files: "FIRFilterCode.h" and "Main.h" referenced in "NewParksMcClellan.cpp". Does anyone have experience compiling this code? Thank you.


texts: Fourier transform of certain noisy function

texts:
So, I have a noisy signal in time domain, $f(t) = t \eta(t)$ where $\eta(t)$ is white noise with variance $\sigma$ and mean zero, and that it has the property $\langle \eta(t)\eta(t') \rangle = \sigma^2 \delta(t-t')$ ($\langle \ldots \rangle$ denotes ensemble averaging). What I want to do is that I want to calculate the square magnitude of the spectrum in frequency domain upon ensemble averaging, $\langle |z(\omega)|^2 \rangle$. To do this, I follow Dave's answer in https://physics.stackexchange.com/questions/53739/magnitude-of-the-fourier-transform-of-white-noise. So, it will be
$$
\langle |z(\omega)|^2 \rangle = \iint e^{i\omega t} e^{-i\omega t'}t't \langle \eta(t)\eta(t') \rangle dt dt'
$$
Using the property stated above, $\langle \eta(t)\eta(t') \rangle = \sigma^2 \delta(t-t')$, I can obtain
$$
\langle |z(\omega)|^2 \rangle = \sigma^2 \int t^2 dt
$$.
Thus, the ensemble averaged square magnitude of my function is independent of $\omega$.

Now I perform the same calculation using MATLAB and I obtained the following pictures.

It seems like when I take ensemble average of the lower curve, it will be dependent on $\omega$, which contradicts my calculation. Can someone please point out my mistake(s)?

clear all;
clc;

n = 2048;
ft = rand(1,n)*(2+2)-2 + 0;
t = linspace(-10,10,n);
Dt = 1/(t(3)-t(1));

fw = ifft(fft(t.*ft));
w = (-length(t)/2:length(t)/2-1)*2*pi*Dt/length(t);
subplot(211)
plot(t,t.*ft)
xlabel('t')
ylabel('f(t)')

subplot(212)
plot(w,abs(fw).^2)
xlabel('\omega')
ylabel('|z(\omega)|^2')

That's my code. By the way I think you are using normal distribution for the noise, I used white noise type.


texts: What is the relation between PCM amplitude values and the values in a Spectrogram?

texts:
I am curious to know the relation between the 16-bit amplitude values in the PCM-encoded signal and the values inside the corresponding spectrogram. I am using Scipy reading a 44100-sample rate song:

from scipy import signal
from scipy.io import wavfile

sample_rate, samples = wavfile.read('some_song.wav')
freq, times, spectrogram = signal.spectrogram(samples, sample_rate, window='hamming',
                                                             nperseg=4410, noverlap=0)

The integer values of samples (in my song) is [-15039, 16432] which I interpret as the relative amplitude level at the particular sample.

However, the integer values of the spectrogram ranges from [0, ~16.7 million]

Can someone explain the relation between those intervals? I guess they're both saying something about the amplitude.

Thanks


texts: Video stabilization using Lucas-Kanade method

texts:
I got an assignment in a video processing course - to stabilize a video using the Lucas-Kanade method. Assuming the matlab code I wrote for performing LK on 2 images works (i.e, I can get the optical flow matrices u, v that allow me to warp one image towards another) - how can I use it to perform a video stabilization?

As far as I understand, the main idea is to calculate the OF for each 2 adjacent frames, and to warp all the images towards the first one. that means that I need to keep the total warp that I accumulate during the whole process- and practically: saving total warp matrices u_tot, v_tot and add to them the u, v matrices I got from 2 adjacent frames, to perform a warp of the latter frame according to u_tot, v_tot and so on (notice the matlab code below).

Am I going in the right direction? I'd like to get an advise... thanks

matlab code:

EDIT: changes the code + added the WarpImage imp. (23.4.17)

function StabilizedVid =LucasKanadeVideoStabilization(InputVid,WindowSize,MaxIter,NumLevels,NumOfFrames)
    % InputVid is a VideoFileReader object
    % WindowSize - window size for the LK phase
    % MaxIter - maximal number of iterations for the LK phase
    % NumLevels - number of levels in the pyramid for the LK phase
    % NumOfFrames - number of frames to process

    reset(InputVid);
    StabilizedVid = vision.VideoFileWriter('StabilizedVid.avi');
    cnt = 1;
    if (~isDone(InputVid))
        frame1 = im2double(rgb2gray(step(InputVid)));
        first_frame = true;
    else
        error('no frames in the video');
    end

    while ~isDone(InputVid)
        cnt = cnt+1;
        frame2 = im2double(rgb2gray(step(InputVid)));
        [frame1, frame2] = sizeCheck(frame1, frame2, NumLevels);
        if (first_frame)
            u_tot = zeros(size(frame1));
            v_tot = zeros(size(frame1));
            step(StabilizedVid,frame1);
            first_frame = false;
        end
        disp(['processing frames no. ', num2str(cnt-1), ', ', num2str(cnt)]);
        tic
        [u ,v] = LucasKanadeOpticalFlow(frame1,frame2,WindowSize,MaxIter,NumLevels);
        disp(['time: ', num2str(toc)]);
        u_tot = u_tot + u;
        v_tot = v_tot + v;
        frame2_warp = WarpImage(frame2, u_tot, v_tot);
        step(StabilizedVid,frame2_warp);
        if cnt >= NumOfFrames
            break
        end
        frame1 = frame2_warp;
    end
    release(StabilizedVid);
end

%%%%%%%%%%%%%%%%%%%%

function I_warp = WarpImage(I,u,v)
    % I - image to warp
    % u,v - the optical flow parameters gotten from the LK algorithm

    [x, y] = meshgrid(1:size(I,2),1:size(I,1));
    % interpulate
    I_warp = interp2(I, x+u, y+v, 'cubic');
    % in case of NaN values - put the original values of I instead
    I_warp(isnan(I_warp)) = I(isnan(I_warp));

end


texts: Impulse response of a continuous time system

texts:
Question

  The impulse response of a continuous time system is $h(t) = e^{-t}u(t)$. When $x(t) = u(t - 1)$ is input to this system what is
  the value of the output signal $y(t)$ at $t = 2.34$.

My Attempt

For convolution $y(t) = h(t) \star x(t)$
\begin{align}
x(2.27) &= u(2.34-1) = 1\\
h(2.27) &= e^{-2.34}\cdot u(2.34) = 0.09632763823\\
\Longrightarrow y(t) &= 1 \cdot 0.09632 = 0.096
\end{align}

But the answer is wrong. Not too sure where my mistake is. Could someone correct my error?

Second Attempt
\begin{align}
y(t) &= ∫x(\tau)h(t-\tau)d\tau \quad\text{with limits negative and positive infinity}\\
&= ∫u(\tau-1)e^{-\tau}u(t-\tau)d\tau \\
&= ∫e^{-\tau}u(\tau-1)u(t-\tau)d\tau \\
&= ∫e^{-\tau}d\tau \quad \text{with limits 1 to 2.34}\\
&= 0.2715518029
\end{align}

Though the answer still appears to be wrong.


texts: Auto Correlation for Time Frequency Analysis

texts:
Given a signal $x(t)$, how do I implement a form of autocorrelation function defined as $a(t,T) = x(t-T)x(t+T)$, where $T$ is an arbitrary constant?

(a fast implementation would be ideal)

Edit:
This kind of signal I came across from seeing a "Parametric Symmetric Autocorrelation function", defined as above.

It is used in time-frequency analysis methods like WVD,...etc.
$ R(t,\tau) = x(t + \frac{\tau}{2})x^{*}(t-\frac{\tau}{2})$

Thus far, I have implemented the steps as below for an example chirp:
but the output of the fft2 at the end is wrong. (not a correct frequency)

At the output of the autocorrelation function (the PSIAF variant):

The final output of the LVD is wrong (should be point like):

Solved: Will look at using some of the already published C codes as per answer below to compute the $ R(t,\tau) $


texts: FIR implemented via FFT -- low-pass works good, high-pass gives distorted results. What's wrong?

texts:
I'm implementing (in software) FIR filters. I have done two implementation: convolutional one and based on multiplication in frequency domain with FFT/IFFT. I'm using standard FFT implementation (not my own) and overlap-add processing.

FFT parameters are automatically selected to be like this: $fftSize = 2 * 2^{\lceil\log2(nTaps)\rceil}$, $samplesPerOp = fftSize - nTaps + 1$ and $overlapSize = nTaps - 1$.

Now I'm testing my implementation. I've generated signal as $\cos(F_1*2*pi*n/F_s) + \cos(F_2*2*pi*n/F_s)$, where $F_1 = 10$, $F_2 = 1000$ and $F_s = 44100$. Also, I design two set of taps via windowed-sinc method: one for low-pass, with transition band $110Hz - 900Hz$ and other high-pass with same transition band. I've tried different windows - Hamming, Blackman-Harris and others.

I apply these two filters to signal, with convoluted and FFT implementations. Low-pass filter works perfectly well in both cases: when I select $nTaps$ large enough (via estimation formula from textbook - "Multirate signal processing" by frederic j. harris, for 90dB attenuation it gives me $nTaps = 327$ taps) I got clean 10Hz signal from both implementations (they are differ on edges of signal, but it is expected, of course)

But high-pass filter behaves strange. Convolutional implementation works. It gives almost undesturbed 1000Hz sine wave. And FFT implementation returns a mess. Result of FFT filtering looks like 1000Hz signal, but it is very corrupted - phase jitter, amplitude jitter, etc.

It looks like, I do something wrong, but I could not understand what. Each textbook, tutorial and article about using FFT for FIR filtering doesn't mention something like this.

Oh, I'm using double, not fixed-point arithmetic, so precision loss should not be a problem.

And, not, it is not HW :)

Here are pictures from gnuplot (1/5 of «second»):

Low-Pass, convolution on top, FFT on down: http://lev.serebryakov.spb.ru/dsp/dsp-low-pass-side-by-side.png
High-Pass, convolution on top, FFT on down: http://lev.serebryakov.spb.ru/dsp/dsp-high-pass-side-by-side.png


texts: A question regarding z transform and its magnitude response

texts:
My teacher of signals and systems gave us a review problem as following:

given a DT rightsided LTI system with transfer function

$$\frac{1-a^*z}{z-a}, \left | a \right |<1
$$
show that the system's magnitude response is in unity for all frequencies using graphical method.

Can anyone give me any suggestion of solving this problem? I've been going back and forth between the textbook and course video for hours, but still very clueless.
I am particularly confused about the indication of using graphical method, because it seems no matter how I manipulate the fraction, there's always vector multiplication instead of simple addition.


texts: Finding number of independent samples using autocorrelation

texts:
I have a pressure signal (y) with 512000 samples and with a sampling frequency 5000 sample/sec. I am trying to find the number of statistically independent samples using autocorrelation. I used

autocorr(y)

I do not know if this is correct or how to get the number of independent samples

I found this question, but there is no valid answer

https://stats.stackexchange.com/questions/149517/autocorrelation-and-statistically-independent-samples

Thanks


texts: How to get started analyzing audio signals for detecting cracks in a material?

texts:
I have two processes, one is normal and the other with some cracks of material. And I have the acoustic signals got from the materials by a sensor. I want to compare these signals to see if this signal can be used to detect cracks. I think two different processes (with and without cracks) will create two different signals. Based on that, I want to compare these signals, but I'm new to DSP.

Could you please give me some suggestions what I should do, step by step to process these signals?

(I will of course read books to get knowledge about DSP, but it's really huge. I therefore hope that someone can tell me what I should do, step by step to process those signals. By doing so, I can save some time)


texts: Newbie looking for an interesting introductory book to telecommunication and signals/data processing

texts:
I am currently in my first year of Bsc Applied Physics. Over the past two years, I have realized I'm interested in majoring in telecommunication after I finish my bachelor. Also, for one of my classes I need to give a presentation; I chose my topic to be about Data Transmission. While working on my abstract for my project, I came across things I never even thought of! This, however, sparked my interest in this field even more!

So is there any interesting introductory book to signals and telecommunication that you would suggest and that is interesting and accessible for a bachelor student?

Thank you very much!

Yours,
WBk


texts: How to pick a sampling frequency for Matlab fft

texts: I am recording vibration data using an adxl335 accelerometer.I have ~50ms delay before i save a reading from this sensor so most probably each second i have ~20 readings. I verified that by checking the difference between two consecutive readings since i am recording the time of reading, however since my pc is not real time i guess matlab is varying but i found that the average time between two consecutive readings is 0.0517 so my sampling should be ~19 hz ? is this the value that should be chosen ?


texts:
What do you think of this notch / band reject filter for a very very narrow band ?

Original signal x[n]
--> FFT
--> then I just put "0" in the FFT bin of the frequency I need to reject (notch filter)
--> inverse FFT
--> output signal y[n].

How is called such a filter ? Does it really work, or is it too simple to be true ?


texts: How can I detect elements of GUI using opencv?

texts:
Given a screenshot of an application, is there any way of finding GUI elements of that application using only opencv? (something like in the image)

I tried to play with blending the image and other effects from the coherence.py sample in the opencv installation folder. Did not succeed to get a viable result.

Has anyone did this? Do you have any idea what I might try?

Thanks

(I'm new to opencv and image processing so please don't avoid obvious explanations if possible) :)


texts: additive white Gaussian noise -ask fsk psk

texts:
i want to simulate a system that uses ask,fsk ,psk in Matlab with additive Gaussian noise for each mode . figure shows the system propti  and Eb/N0=6db my question is  how to calculate the standard variation of the Gaussian noise for each mode , i tried the following :

EbN0dB=6;
EbN0=10^(EbN0dB/10);% db to linear scale
EN0=1/(EbN0);
sigmaASk=sqrt(N0);% siqma for bask
siqmaPsk=sqrt(2*N0);% siqma for
bask
sigmaFsk=sqrt(N0(1-sinc(4*1000*0.001);
mff=transmitted+sigma*randn(1,10*30);%modulated 10 bit signal plus
noise


texts: Kronecker delta instead of dirac delta as correlation function of white noise

texts:
From my understanding, if you have a sample $x_{t_1},\dots,x_{t_n}$ of $X_{t_1},\dots,X_{t_n}$ which are iid $N(0,1)$, then $x_{t_1},\dots,x_{t_n}$ is a sample path of Gaussian white noise.

However, it is stated that the correlation function $c(s,t)$ of white noise is $\delta(s-t)$ where $\delta$ is the Dirac delta function. I understand that if $s\neq t$ then $c(s,t) = 0$. However, if $s=t$, you want $c(s-t)=1$. Why isn't the kronecker delta function used instead?


texts: RRC filter in receiver side well applied?

texts:
I would like to ask question bout the rrc filter that I applied as an matched filter for receiver side in communication. My aim after RRC filter is to draw the eye diagram, and so far the eye opening is small and I wonder if there are still ISI after applying rrc.

This is my signal qpsk before / after applying RRC.
How do I know if the filter is applied well? How do I know if this signal still has ISI or not by looking at time domain signal? Obviously it seems so, because the eye opening is small.
Another question is, I have read some articles including how to design the filter, but it is still not clear for me how to set the tap(N). I would appreciate if you elaborate more about it.
Thank you in advance.


texts: deciphering the frequency response from the input data

texts:
Newbie to Signal processing, sorry if the question is basic.
I have a data set consisting of 601 values. The values being time Vs voltage . The voltage values have transients in them. My aim is to filter out these transients using an FIR filter. But i'm still far from doing that.
This is my voltage Vs Time plot.

I plotted the fft of voltage and this is what i got.

I read up that fft basically divides my sampling frequency,Fs, into N equal parts (N= 601, Total number of values). According to my (voltage Vs Time) plot, my Fs=2500Hz (by calculating Ts as the difference between consecutive values of time from data set).Then,2500/601 gives 4.159 as the first point in my fft. Is this even correct?

Going by the above,the strength of the signal is greatest at the 11th value (ie,10*4.159 =41.59 Hz) and the 592nd value (591*4.159=2458 Hz).Now, What significance does this information hold if i need to design a filter to eliminate the transients? What do information do i take away exactly, by performing the fft of the voltage signal?

Thanks


texts: Contour sharpening: Optimal direction for derivation

texts:
Talking about sharpening a contour in an image. What's the optimal direction for derivation? What's the maximum value of derivative?

I think that the optimal direction for derivation is the direction in which points the gradient. And the maximum value of derivative is the magnitude.

Is my answer to those questions right? Is there anything else you can suggest?


texts: Is the mean of visible color in CIELab color space can be non visible color?

texts:
I am converting color from RGB to CIELab to train a GMM. When I get back the mean of clusters of the GMM I have sometimes negatives values in RGB space. I was wondering if the mean of only visible color can be non visible color ? Therefore I was also wondering if the visual color of CIELab forms a convex shape.

EDIT:
I'm using Expectation-Minimization of OpenCV to train the Gaussian Mixture Model.


texts: How to implement a filter associated to a specific wavelet

texts:
I am working on ECG signals, to eventually extract features in order to detect an arrhythmia and classify it.
I am using Discrete Wavelet Transform with biorthogonal wavelet bior6.8
During my research, I came to know that wavelet transform is the convolution of the input processed signal with the daughter wavelets to get approximation and detail

$$X(a,b)=\frac{1}{\sqrt{a}}\int_{-\infty}^{\infty} \Psi\left( \frac{t-b}{a}\right)x(t)dt $$
where $a$ is scaling and $b$ is time.

I can't find the expression of the mother wavelet anywhere also when it came to practice DWT is usually presented as a filter bank of high pass and low pass filter
The question is what is the difference between the different wavelets if it is always presented as a bank of filters

In my work, I used these two Butterworth high pass and low pass filters, but I still can't explain my choice, I read that Butterworth is the most used in signal processing and that it optimizes the frequency response in the passband, getting as much as you can from the wanted frequency
Still, I have no arguments why I shouldn't use any others and not sure whether it is the correct way to implement bior 6.8 wavelet as I do not know any other way to implement wavelets and I would implement Daubechies or any other the same which do not make sense

from scipy.signal import filtfilt , butter

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,padlen=0)
    return y

from scipy.signal import butter, lfilter

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

So basically and to resume, the question is what is the difference between wavelet transforms and how can we value that during implementation and then, the use of BF in this type of wavelet is it correct?

NB: the image inserted is from Wikipedia


texts: unitary matrix complexity multiplication

texts:
Having a unitary matrix $X$ whose size is $n \times n$ and a vector $z$ whose length is $n$, and let's have:

$$y = X^H {\rm diag}(z)X$$

where $X^H$ is the conjugate transpose of $X$.

My question, is the complexity of this multiplication is still  almost $n^3$ or since the matrix $X$ is unitary, multiplication complexity should be less ?


texts: BER performance of fractional equalizers for colored noise

texts:
I am trying to compare the BER performance of fractional and symbol spaced equalizers for channel equalization in  colored noise scenario. I have found from simulation that for positively correlated noise, fractional equalizers perform better than symbol spaced equalizers. It is probably due to fact that with more samples we have more information in case of fractional equalizers. Is there any way of theoretically prove that fractional equalizers are better than symbol spaced equalizers for colored noise?
Thanks


texts: How to use function spectrum in R to perform spectral analysis

texts:
I intend to perform spectral analysis with R stat:spectrum and then plot power spectrum.

My code is listed here:

  t <- seq(0,1024,by=0.1)
  x <- cos(2*pi*t) + 0.75*sin(2*pi*4*t) + 2*sin(2*pi*6*t)
  x.spec <- spectrum(x,log="no",span=5,plot=FALSE)
  del <- 0.1
  spx <- x.spec$freq/del
  spy <- 2*x.spec$spec
  plot(spy~spx,xlab="frequency",ylab="spectral density",type="l")

the signal has 3 periodic components with 1 Hz, 4 Hz, 6 Hz, but the final spectrum only shows the first 2 frequencies, without 6 Hz. And I don't know why the range of x.spec$freq is [0,0.5] before scaling.

Please tell me my possible concept misunderstanding and guide me how to plot the spectrum correctly. Thank you very much.


texts:
I read that an "improper system" "has more zeros than poles; it is not causal, cannot be implemented, has a strictly proper inverse and has infinite high-frequency gain."

Does causality fail due to instant signal change? I try to make up a recurrence, where $x_n$ depends on both $x_{n-1}$ as well as $x_{n+1}$ but they all can be interpreted as $x_{n+1}$ dependence on $x_{n}$ and $x_{n-1}$ and, thus, are causal.

Is it related with solving recurrent relations saying that P(x) in generating function $f(x) = f_0 + f_1 x + f_2 x^2 + \cdots = P(x)/R(x) \ \ \ \ \ $ must have degree less than R(x) as Miguel A. Lerma says in Generating function of Linear Homogenous Recurrence. Here, $R(x) = 1 + r_1 x^1 + r_2 x^2 + \cdots$ is a reciprocal of the characteristic polynomial of our recurrence $x_n + c_1 x_{n+1} + \cdots = 0.$ This indeed seems to happen whenever which R(x) I try.

On the other hand, https://ccrma.stanford.edu/~jos/fp/Existence_Z_Transform.html seem to identify causality with pole values (if your pole > 1 then series does not converge, which means anticausality) rather than their number and others say that causality is $x_n = 0$ for all $n < 0.$ I do not see how this is related with poles/zeros ratio and my guess that poles > zeroes = causality may be wrong. I have asked to relate various kinds of causality here.


texts: Gardner timing recovery and constellation diagram

texts:
I would like to ask for some guidance regarding 2 issues mainly QPSK and Gardner algorithm for timing recovery.

I am having as input a set of IQ samples (10 samples per symbol) to which I need to provide timing recovery.

Having red Gardner’s landmark paper on that concept (A BPSK/QPSK Timing-Error Detector for Sampled Receivers) I understand that in a simple BPSK case where transition exists (in a pulse always) the two first terms (x[nT]-x[(n-1)T]) of the formula e={x[nT]-x[(n-1)T] }x[nT+T/2] cancel out and the error approaches zero. In cases where no transition exists then we don’t get the desirable cancelation but statistically that is going to be resolved later due to negative symbols inserted.

All that above is quite straightforward the complications start with the obscurity behind the input samples I am having and the relation they have with the constellation diagram and the initial pulses.

Above you can see the constellation diagram (of my samples) plotted. The axes are scaled this way because the numbers are represented in 8 bit integers.
Now if I choose a smaller chunk of my sample set let say 300 and scale them properly (divide by 256) I get that :(only for clarification purposes to show the samples)

Is apparent by the concept of timing recovery itself that needs to be kept only,a number of samples that fall very close to the 4 constellation points and discard all the rest.

Here I am having two main doubts the first is fundamental related to QPSK.
How do I connect the constellation diagram with the actual waveform?

Gardner was explaining his concept utilizing 2 samples only.In my case that 10 samples per symbol are utilised means that for each pulse am sampling 10 times (sorry for the oversimplification) and the I  part is the magnitude and Q the angle of each sample?

Is it like splitting the initial wave or pulse in 10 samples (sorry again for that simplifications I know they sound trivial to many but are necessary to clear my doubts) instead of 2 that Gardner was explaining?

If yes then how do I employ the formula,I  mean, how do I set the middle  (x[n*T+T/2])  term and how the other two x[nT]-x[(n-1)T]?

However, In QPSK things are more complicated due to the fact that both I and Q samples exist.

That introduces a new term in the Gardner’s equation e={x[nT]-x[(n-1)T] }x[nT+T/2]+{y[nT]-y[(n-1)T] }y[nT+T/2]  .Where, the second term refers to the Q samples,and introduces a greater difficulty on realizing where and how to used the formula.

Any ideas on how to employ that for QPSK as well?

Thanks a lot

George


texts: What does pre-emphasis $\alpha=1$ will do to a signal?

texts:
I am trying to understand pre-emphasis equation.

$$ y[n]=x[n]-\alpha x[n-1]$$

Where $\alpha = 0.95$.
My question is what does it mean if $\alpha = 1$?


texts: Convex Optimization with $ {L}_{1, 2} $ Regularization Term

texts:
I have an optimization problem such as follow:
$$\underset{X}{\operatorname{argmin}}\sum _s \left \| T_sX_{:,s} - Y_{:,s} \right \|^2_2 +\lambda\left \| GX \right \|_{2,1} \tag{1}$$
I have introduced a new variable:
$$\underset{X,Z}{\operatorname{argmin}}\sum _s\left \| T_sX_{:,s}-Y_{:,s} \right \|^2_2 +\gamma\left \| GX -Z\right \|^2_2+\lambda\left \| Z \right \|_{2,1} \tag{2}$$
And divided this problem into two sub-problems:
$$\underset{Z}{\operatorname{argmin}} \gamma\left \| GX -Z\right \|^2_2+\lambda\left \| Z \right \|_{2,1}\tag{3.1}$$
$$\underset{X}{\operatorname{argmin}}\sum _s\left \| T_s X_{:,s} - Y_{:,s} \right \|^2_2 +\gamma\left \| GX -Z\right \|^2_2 \tag{3.2}$$
I have found that (from a paper) for the eqn 3.1, solution is as follows:
$$Z_{n,:}=[GX]_{n,:} \operatorname{}max\left \{1-\frac{\lambda}{2\gamma \left \| [GX]_{n,:} \right \|_2} ,0\right\}\tag{4}$$
I am solving this problem iteratively. First, I solve for $Z$ using equation 4, then I am solving for $X$ using equation 3.2 and utilizing nonlinear conjugate gradient method. Something is clearly wrong since I cannot reach to a solution. And it is not like solutions are diverging but more like always 0. Do you see anything wrong so far? If not, I can upload my nonlinear conjugate gradient method. Thanx in advance and have a nice day!


texts: How Can I Remove Flickering Background in a Video?

texts:
I have a black and white video taken with a high speed camera and I notice a background flickering coming from my LED light.  The images alternate from dim to bright and it makes the videos quite disorienting.

Besides getting a different light, is there any post-proccessing that can be done to remove this effect?  Possibly something from the image processing toolbox in matlab, or something in imageJ would be helpful as well.

I have already acquired quite a few videos and would hate to have to repeat everything all over again so any help would be greatly appreciated.

thanks!


texts: Facing problem in plotting histogram of DCT coefficient of an image

texts:
In digital image forensic, it is assumed that the histogram of DCT coefficients of the un-compressed natural image has the smooth histogram. However, the histogram of DCT coefficients of the compressed natural image has peaks and gap in it. One such problem is discussed in this work. see this image for a better understanding .

I am using the following MATLAB code to plot the histogram of DCT coefficients of uncompressed and compressed images.

x_axis = -1000:0.01:1000;

img_1 = rgb2gray(imread('a.tif'));
img_2 = rgb2gray(imread('b.tif'));

subplot(2,2,1), imshow(img_1), title('Image');
subplot(2,2,2), imshow(img_2), title('Compressed Image');
subplot(2,2,3), plot(x_axis, histogram(dct2(double(img_1)))), title('Image');
subplot(2,2,4), plot(x_axis, histogram(dct2(double(img_2)))), title('Compressed Image');

but I am unable to get the results in the desired manner. see this figure below .

Can anyone please explain? what is the correct way of plotting the histogram of DCT coefficient of an image so that I may get the correct results?


texts: How can initial conditions be taken into account to calculate a system's terminal value using the final value theorem or some other technique

texts:
I wish to calculate the Final Value of the following system given initial conditions not at rest, and assuming the X will not change from its initial condition value.
The transfer function is
$$H(z) = \frac{z^{-1} \phi / (1 - \phi z^{-1})}{1 - z^{-1} \psi / (1 - \psi z^{-1})}$$
It arises from the following feedback system
$$Y(z)(1-z^{-1}) = z^{-1}F_{\psi}\cdot Y(z) + z^{-1}F_{\phi}\cdot X(z)$$
where $F_{\alpha}(z)$ is a 1st order high pass filter with parameter $\alpha$ of the form
$$F_{\alpha}(z) = \frac{\alpha (1 - z^{-1})}{1 - \alpha z^{-1}}$$
When the initial conditions are rest, then the final value of the system response to a step in x from $0$ to $x[0]$ is readily obtained using the Final Value Theorem:
$$fv = \lim_{z\rightarrow 1} z(1-z^{-1})H(z)\frac{x[0]}{1 - z^{-1}}$$
which in this case resolves to
$$\frac{x[0] \cdot \phi / (1 - \phi )}{1 - \psi / (1 - \psi )}$$
However this is not where the system will settle if initial conditions are non zero.
How does one solve for the final value when initial conditions are not zero?


texts:
Assume a discrete time signal $(x_n)$ is given. Some texts define the DFT as
$$ X[k] = \sum_{n=-N}^N x_n\exp\left(\frac{-2\pi j k n}{N}\right) $$
while others define it as
$$X[k] = \sum_{n=0}^{N-1} x_n\exp\left(\frac{-2\pi j k n}{N}\right) $$
or
$$X[k] = \sum_{n=1}^N x_n\exp\left(\frac{-2\pi j k n}{N}\right)$$
or many other seemingly random variants with different indices. So what is the true index limits for DFT? Or is there no unique consensus and any random author is allowed to introduce a new one?


texts:
I'm trying to derive the transfer function for Chebyshev filter.
$$|H(\Omega)|^2=\frac{1}{\sqrt{(1+\epsilon^2T_n^2(\frac{\Omega}{\Omega_c})}}$$
where   $$T_n(x)=\cos(N\cos^{-1}(x)) \forall x \le 1$$
$$T_n(x)=\cosh(N\cosh^{-1}(x)) \forall x \ge 1$$
$$H(s)=\frac{1}{\sqrt{(1+\epsilon^2T_n^2(\frac{s}{j\Omega_c}))}}$$
To calculate the poles I made the following substituion which looks like this:
$$\cos^{-1}(\frac{s}{j\Omega_c})=\alpha + j \beta$$
So
$$s=j\Omega_c(\cos\alpha \cosh\beta - j \sin\alpha \sinh\beta)$$
$$s=\Omega_c \sin\alpha \sinh\beta + j \Omega_c \cos\alpha \cosh\beta$$
where $\alpha=\frac{(2k-1)\pi}{2N}$ and $\beta = \frac{1}{N} \sinh^{-1}{\frac{1}{\epsilon}}$
But with this substitution my poles yield to be stability or produce an ambiguity on the stability end.
But if I make the substitution as $$\cos^{-1}(\frac{s}{j\Omega_c})=\alpha - j \beta$$
poles seem stable.
Can someone help me with this. is my substitution wrong?


texts: How to prove these two definitions of the minimum phase transfer function are same?

texts:
There are so many definitions of the minimum phase transfer function, and these are two of them.

The transfer function of the system which has no zeros or poles at right half plane.
The transfer function which has the minimum phase angle range among the systems which has the same magnitude characteristic.

And these two sentences are describing the same thing. So I want to prove that these statements are equivalent. How to prove it?

PS : Suppose that the system is continuous.


texts: Finding linear convolution of two time series

texts:
PROBLEM

Two real, causal time series

$$f_k = a^k \quad \text{and} \quad g_k = b^k$$

where $a \neq b$, $|a| < 1$, and $|b| < 1$, are given for $k = 0,1,2,...$

Find the linear convolution $h_n$ of the time series $f_k$ and $g_k$.

ATTEMPTED SOLUTION

I think perhaps my attempted solution here can be improved upon. We have from the definition:

$$h_n = \sum_{k=0}^{n} f_k g_{n-k} = \sum_{k=0}^{n} a^k b^{n-k} = b^n \sum_{k=0}^{n} \left(\frac{a}{b} \right)^k$$

If we let $R = \left(\frac{a}{b} \right)$, the last term can be written as:

$$h_n = b^n \cdot \frac{1 - R^{n+1}}{1 - R}$$

or

$$h_n = \frac{b^n - \frac{a^{n+1}}{b}}{1 - \frac{a}{b}}$$

$$h_n = \frac{b^{n+1} - a^{n+1}}{b-a}$$

I don't see how I can improve upon this answer though, but since we are given certain conditions in the problem, I have a feeling that it is possible to get a more elegant solution.  I see that as $n \to \infty$, $h_n \to 0$, but is there any way I can "improve" on the answer for any $n$?