texts: How to prevent Signal drifting when changing frequency

texts:
When I recreate a signal it seems to look great. But when I try and increase it's frequency (which is done in a for loop and the variable new_freq=2) it starts to drift.

See Image below (The top image is 1hz and the bottom image is 2hz. I circled the image with the problem). I also noticed when I increase the sample frequency the problem gets even more noticeable. Notice the top one is at 8000 as the sample frequency and the bottom one is at sample frequency of 44100.

I've posted the for loop below any ideas why the variables aa_sig_rebuilt_norm_bin and aa_sig_combined_norm_bin are drifting so much?
Please note I'm using much more complex signals than just sine waves (if I were just using sine waves I would use the sinwave equation to increase the frequency. I used a sinewave as an example)

The whole for loop is base on rebuilding a signal using the equation AmplitudeCos(freqtime+phase) I did an fft/ifft to get all the frequencies/amplitudes/phases then just change the frequency to what I want

I do want to vectorize this for loop but at the moment I'm trying to fix the drift

new_freq=[2]; %increase frequency
fn_array=[];
array1=[xfreq_orig,yamp_orig,yamp_inv,phase_orig,mod(phase_in_deg,360),phase_in_rad,phase_adjindeg,phase_adjinrad]; %have degs only go up to 360

t_rebuilt=linspace(0,2*pi,fs);

for zz=1:1:length(new_freq); %

    zz
    %needs to be in for loop to reset variables for next new_freq
    aa_sig_rebuilt_norm=zeros(1,length(t_rebuilt));
    aa_sig_rebuilt_norm_bin=zeros(1,length(t_rebuilt));
    aa_sig_combined_norm=zeros(1,length(t_rebuilt));
    aa_sig_combined_norm_bin=zeros(1,length(t_rebuilt));
    sig_norm=zeros(1,length(t_rebuilt));
    sig_norm_bin=zeros(1,length(t_rebuilt));
    for kk=1:1:length(xfreq_orig);
        aa_sig_rebuilt_norm = array1(kk, 2)*cos (array1(kk,1)*t_rebuilt+(array1(kk, 4)));
        aa_sig_combined_norm = aa_sig_combined_norm + aa_sig_rebuilt_norm;

        aa_sig_rebuilt_norm_bin = array1(kk, 2)*cos ((new_freq(zz,1))*array1(kk,1)*t_rebuilt+(array1(kk, 4))); %binural section
        aa_sig_combined_norm_bin = aa_sig_combined_norm_bin + aa_sig_rebuilt_norm_bin;
    end;

    %have it export to file
    sig_norm=(aa_sig_combined_norm/max(abs(aa_sig_combined_norm))*.8); %normalize signal
    sig_norm_bin=(aa_sig_combined_norm_bin/max(abs(aa_sig_combined_norm_bin))*.8); %normalize signal

    wavwrite([sig_norm' sig_norm_bin'] ,fs,16,strcat(dirpathtmp,fn_LR_norm_bin)); %export file

end;


texts: Frequency conversion in IIR lowpass-to-lowpass transformation

texts:
We use
$\ z^{-1} \xrightarrow{} \frac{z^{-1}-\alpha}{1-{\alpha}z^{-1}}$
and
$ \alpha = \frac{\sin(\omega_c^{'}-\omega_c)/2}{\sin(\omega_c^{'}+\omega_c)/2}$
for a lowpass-to-lowpass frequency transformation, where $\omega'_c$ is the cut-off frequency of the prototype lowpass filter, and $\omega_c$ is the cut-off frequency of the transformed lowpass filter.
In practice we know the desired edge frequencies $\ \omega_s$ and $\ \omega_p$ and we are required to find the prototype lowpass cutoff frequencies $\ \omega_s^{'}$ and $\ \omega_p^{'}$.
For calculating $\ \alpha$ we have to know $\ \omega_c^{'}$ . If we calculate $\ \alpha$ we can have $\ \omega_s^{'}$ by $\ \omega_s^{'} = \angle{(\frac{e^{-j\omega_s}+\ \alpha}{1-\alpha e^{-j\omega_s}})}$
But I don't know how select a suitable $\ \omega_p^{'}$.


texts: why is moving towards higher frequencies so important in frequency spectrum?

texts:
As we know, as frequencies becomes higher, bandwidth becomes higher.And, according to channel capacity theorem, channel capacity increases with higher bandwidth.

Also,  energy is directly proportional to frequency(E=hf). So, if frequency increases, signals possesses higher energy and can travel far.

Which one of them would be more relevant to prove our need of higher frequency? Why not the other one?


texts: Equivalence between noise covariance of real and complex models of received signal

texts:
I have a question on the equivalence of two models (complex vs. real) of a received signal in ISI channel. Yet its simplicity, I am a bit confused.

Model #1: Complex
Assume we transmit a complex symbol $\overline{a}$ drawn from a high-order QAM constellation. On a vector form, we can write the receive signal as
$$\overline{y} = \overline{G} \: \overline{a} + \overline{w},$$
where $\overline{G}$ is the channel matrix (it is real matrix of dimension $N \times N$) and $\overline{w}$ is the complex noise samples with zero mean and cross-correlation matrix $E\{\overline{w} \overline{w}^H\} =\sigma^2 \overline{G}$.

I would like to work with real-valued components instead of complex-valued components. That said, we can write the following real model of the received signal.

Model #2: Real
$${y} = {G} \: {a} + {w},$$
where $y = \begin{bmatrix}
\Re\{{\overline{y}}\}\\
\Im\{{\overline{y}}\}
\end{bmatrix},$ $G = \begin{bmatrix}
\Re\{{\overline{G}}\} & - \Im\{{\overline{G}}\}\\
\Im\{{\overline{G}}\} & \Re\{{\overline{G}}\}
\end{bmatrix},$ $a = \begin{bmatrix}
\Re\{{\overline{a}}\}\\
\Im\{{\overline{a}}\}
\end{bmatrix},$ $w = \begin{bmatrix}
\Re\{{\overline{w}}\}\\
\Im\{{\overline{w}}\}
\end{bmatrix}$, $\Re$ and $\Im$ are the real and imaginary parts of complex numbers. In this particular question, $\Re\{\overline{G}\} = G$ and $\Im\{\overline{G}\} = 0$.

As can be seen, both models are equivalent and can be used at the receiver for detection. My question is what is the cross-correlation of the noise in the 2nd model in terms of $G$, i.e. what is $E\{w w^T\}$ in terms of $G$?

My trial is as follows: $$E\{w w^T\} = \begin{bmatrix}
E\{\Re\{\overline{w}\}\Re\{\overline{w}^T\}\} & E\{\Re\{\overline{w}\}\Im\{\overline{w}^T\}\}\\
E\{\Im\{\overline{w}\}\Re\{\overline{w}^T\}\} & E\{\Im\{\overline{w}\}\Im\{\overline{w}^T\}\}
\end{bmatrix}$$
In general, how can I relate this to $G$? My expectation is/was $E\{w w^T\} = \sigma^2 G$!!!


texts: IIR oscillator produces stable output in MATLAB, unstable on chip, how do I tune it?

texts:
I'm trying to make an oscillator using IIR filter and I'm having problems tuning it so that it's stable on the platform I'm using (ARM Cortex M4F and CMSIS DSPLib's arm_biquad_cascade_df1_f32). Note that this is my first time doing this and that I don't know much about control theory, so I could be missing something very obvious here.

Looking through some textbooks, I found the following formula for a transfer function of an oscillator:

$$H(z)=\frac{Asin(\omega_0)}{1-(2rcos(\omega_0))z^{-1}+r^2z^{-2}}  $$
where, as far as I understand it, A is the amplitude of the oscillator, $\omega_0$ is the normalized angular frequency, which is calculated as $\omega_0=\frac{2f_{real}}{f_{sampling}}$ and the r is parameter which sets the poles distance to the unit circle and decides if the system's output will be dampened, opposite of dampened (can't remember the word at the moment) or constant.

I designed an oscillator using following parameters I got from some other requirements:
sampling frequency $F_s=759493.7$, oscillator frequency $f1=25630$, amplitude $A=1$ (I plan to fine-tune this later), $r=1$.

This gives me then $\omega_0=\frac{2f_1}{F_s}=0.0674923$ and the transfer function of:
$$H(z)=\frac{0.0674411}{1-1.9954464z^{-1}+1z^{-2}} $$

Looking at the impulse response in MATLAB, I get the expected result:

So far so good. I then tried to implement this using arm_biquad_cascade_df1_f32. Here's the block diagram of the filter according to documentation:

Since I only have a single second order section in my oscillator, I'm using only one section as shown on the picture.
I set the coefficients to be:
$b_0=0.0674923$, $b_1=0$, $b_2=0$
$a_1=-1.9954464$, $a_2=1$

When I start executing this filter, the output is unstable and quickly goes to infinity. Manually experimenting with the parameter $r$, I managed to get a slowly decaying response with $r=0.5$. I suspect that what I'm seeing are the results of the MCU being only able to work with 32bit floating point numbers and lacking precision.

So my question is: How do I model the oscillator while taking into account the numerical precision errors?


texts: Laplace transform of $f\left(\frac{t - b}{a}\right)$

texts:
Consider the function $f\left(\frac{t - b}{a}\right)$. We want want to calculate its Laplace transform. There are two approaches:

Firstly,

let $g(t) = f\left(\frac ta\right)$.
Then $\mathcal{L}\left\{f\left(\frac{t-b}{a}\right)\right\} = \mathcal{L}\left\{g(t - b)\right\} = e^{-bs}G(s)$ and $G(s) = \mathcal{L}\{g(t)\} = \mathcal{L}\left\{f\left(\frac ta\right)\right\} = |a|F(as)$.
Therefore $\mathcal{L}\left\{f\left(\frac{t - b}{a}\right)\right\} = |a|e^{-bs}F(as).$

Secondly,

let $h(t) = f\left(\frac{t - b}{a}\right)$.
Then $\mathcal{L}\left\{f\left(\frac{t-b}{a}\right)\right\} = \mathcal{L}\left\{h\left(\frac ta\right)\right\} = |a|H(as)$ and $H(s) = \mathcal{L}\{h(t)\} = \mathcal{L}\left\{f\left(\frac{t - b}{a}\right)\right\} = e^{-\left(\frac ba\right) s}F(s)$.
Therefore $\mathcal{L}\left\{f\left(\frac{t - b}{a}\right)\right\} = |a|e^{-bs}F(as).$

So far so good. However, let $f(t) = e^t$. Then
$$F(s) = \frac{1}{s - 1}$$
and
$$\mathcal{L}\left\{f\left(\frac{t - b}{a}\right)\right\} = \frac{ae^{-\left(\frac ba\right)s}}{as - 1}$$
from Wolfram Alpha.

The problem comes from the fact that we introduce new data by shifting, i.e., the function is not zero for $t < 0$. What can we do then? Can we not use the time delay property?
What about the Fourier transform? The arguments above are valid for the Fourier transform for $s = j\omega$ and you do not have the requirement of $f(t < 0) = 0$ when applying the shift property. But when you set $f(t) = \cos(t)$ you get:
$$\mathcal{F}\left\{f\left(\frac{t - b}{a}\right)\right\}\bigg\vert_{\omega \ge 0,\ a > 0} = \frac{1}{2}e^{\left(\frac ba\right)j\omega}\delta(\omega - 1/a)$$
So it looks like it should be $e^{-\left(\frac ba\right)s}$ instead of $e^{-bs}$. But where have I made a mistake?


texts:
First the question(s):

How should I write unit tests for a digital filter (band-pass/band-stop) in software? What should I be testing? Is there any sort of canonical test suite for filtering?
How to select test inputs, generate expected outputs, and define "conformance" in a way that I can say the actual output conforms to expected output?

Now the context:
The application I am developing (electromyographic signal acquisition and analysis) needs to use digital filtering, mostly band-pass and band-stop filtering (C#/.Net in Visual Studio).
The previous version of our application has these filters implemented with some legacy code we could use, but we are not sure how mathematically correct it is, since we don't have unit-tests for them.
Besides that we are also evaluating Mathnet.Filtering, but their unit test suite doesn't include subclasses of OnlineFilter yet.
We are not sure how to evaluate one filtering library over the other, and the closest we got is to filter some sine waves to eyeball the differences between them. That is not a good approach regarding unit tests either, which is something we would like to automate (instead of running scripts and evaluating the results elsewhere, even visually).
I imagine a good test suite should test something like?

Linearity and Time-Invariance: how should I write an automated test (with a boolean, "pass or fail" assertion) for that?
Impulse response: feeding an impulse response to the filter, taking its output, and checking if it "conforms to expected", and in that case:

How would I define expected response?
How would I define conformance?

Amplitude response of sinusoidal input;
Amplitude response of step / constant-offset input;
Frequency Response (including Half-Power, Cut-off, Slope, etc.)

I could not be considered an expert in programming or DSP (far from it!) and that's exactly why I am cautious about filters that "seem" to work well. It has been common for us to have clients questioning our filtering algorithms (because they need to publish research where data was captured with our systems), and I would like to have formal proof that the filters are working as expected.


texts: Impulse Response / Frequency response Question

texts:
I have a major question. Please take a look.

I have this differential equation (DE):
$$
\frac{d^2y(t)}{dt}  +\frac{dy(t)}{dt} +4y(t)= \frac{dx(t)}{dt} +2x(t)
$$
And I have to find impulse response (IR) and frequency response (FR).

We can "translate" the given DE into:

$$
Y(\omega)(j\omega)^2 + Y(\omega)5(j\omega) + 4Y(\omega)= j\omega X(\omega)+2X(\omega)
$$

So i am reaching a point where $H(\omega) = Y(\omega)/X(\omega) = (j\omega +2)/[(j\omega)^2 +5j\omega + 4]$ .

The my main problem is that i dont know how to continue from this point, because in the numerator is that $j\omega$, otherwise i have my standard methodology to solve it.

So what am I supposed to do for this point ?

Thanks


texts: Is Periodic Convolution Same as Circular Convolution?

texts: I know exactly what is periodic convolution. But i don't know if circular convolution means to be the same thing!


texts: Reading the amplitude values of a FFT in ImageJ

texts:
Readings the output of the FFT of the picture of a circle in ImageJ at some random point $(163,128)$ I get $X_{\text{Re}}=-0.182$ and $X_{\text{Im}}=-3.854$, using the Complex plot (yellow dot). The value on the output  on the FFT plot is $32$ (cross cursor symbol):

I don't understand why the relation between this latter value ($32$), which I presumed it was the amplitude, and the real and imaginary components, i.e. $\vert X[k]\vert=\sqrt{X_\text{Re}^2+X_\text{Im}^2}$, is not fulfilled.

I had come across the power spectrum logarithmic quote in the ImageJ manual:

The frequency domain image is stored as 32-bit float FHT
attached to the 8-bit image that displays the power spectrum.

but I can't find a formula to translate the values between the output on ImageJ and the square root. For instance $\log 32 =3.466$, while $\sqrt{(-0.182)^2 + (-3.854)}=3.858$. I wonder if there is some normalization across the image, for example to explain this difference.

This is likely related to the Hartley transform used in ImageJ (page 39).


texts: Designing an FIR filter in Matlab with differing number of precursor taps and postcursor taps

texts:
I'm trying to fit an FIR filter to the measured frequency response (magnitude and phase) of a device. The frequency response is essentially a low-pass filter. I'd like to vary the number of taps to see how many are necessary to appropriately match the response, but also give differing number of precursor and postcursor taps in the design.

I've investigated Matlab's fdesign.arbmag and fdesign.arbmagnphase functions, but these seem to only give designs with the same number of pre- and post-cursor taps.

Here's some sample code with simplified frequency (F) and amplitude (A) values for reference.

F = 0:0.1:1;
A = [1 0.85 0.9 0.7 0.5 0.3 0.35 0.1 0.2 0.1 0];
filterOrder = 7;

d = fdesign.arbmag('N,F,A',filterOrder,F,A);
Hd = design(d);
fvtool(Hd)
tapWeights = [Hd.numerator];
disp(tapWeights)

The above code runs happily, and produces a low-pass filter that matches the frequency response reasonably well, with tap weights as follows:

[0.0030  0.0361  0.2161  0.4500  0.2161  0.0361  0.0030].

However, the central tap (the cursor, 0.45) is surrounded by three precursor and three postcursor taps. Is there a way to design, say, with one precursor and six postcursors.


texts: Sparse Bayesian Learning Algorithm in Python - MSE vs. SNR

texts:
I am implementing SBL in python. I have plotted a graph between MSE (mean squared error) and SNR (Signal to Noise ratio)
The graph must be decreasing, but mine is decreasing till the SNR is negative. As soon as it is positive, the graph shoots up.
I have checked the code many times, and even the scale of snr and mse.
I still can't find the mistake.

Is this increase possible or have I done blunder anywhere?


texts:
I have two cameras of which I know focal length, principal point, rotation and position. The cameras are in an ideal parallel stereo system.

I want to know with as few calculations as possible how much the images of these cameras overlap (let's say a percentage).

I am trying to follow a guide called Creating correct stereo pairs from any raytracer, but I cannot find how to set aperture and eye separation to find delta.

Can I do it with my current data? Or is there a better way to know how much the camera images overlap?


texts: Signal processing on the graphs: generalized euclidian distance

texts:
In signal processing (SP) often we need to compute sample-wise distance between two signals, e.g. computing MSE. SP on graphs concerns the case when the domain of the signal has some intrinsic structure represented as weighted undirected graphs. The weighs could represent, for example, the correlation between the signal values in each dimension.  I was wondering if there is a generalize notion of sample-wise euclidean distance for SP on graphs which takes into account the structure of the graph?

p.s.
“The Emerging Field of Signal Processing on Graphs” discusses the distances as open issues.


texts: Short lowpass filter that also extrapolates lines

texts:
I'm looking for a short lowpass filter that also extrapolates lines,
[0 1 2 3] --> 4,
so I need (correct me) $H([\ 0\ \ 0.25\ \ 0.5\ ]) \approx [ 1\ \ 2\ \ 0 ]$ .
How close can one get to this with 2 to 4 FIR and 1 IIR coefficient ?

Added: for a 3-term FIR, I want

Input     -> output
 1  1  1  -> 1  # const -> const
-1  0  1  -> 2  # extrapolate lines
 1 -1  1  -> 0  # low-pass

Solving these 3 equations gives the FIR [1.25 .5 -.75] .
I can do longer FIRs by least squares + fiddling. But how do I do FIR x 1-term IIR ?
Is there a general approach to filters that extrapolate lines ?


texts: How to get the orientation value of a rotated square?

texts:
Suppose we have a square shape rotated by $d$ degrees counterclockwise (or $-d$ degrees clockwise) in a binary image as the following:

I'm trying to rotate it by 'Orientation' value of regionprops using imrotate function.

But in this case, the major and the minor axis are the same (the ellipse here is a circle).

Hence, the Orientation value equal to $0$ degrees instead of $d$ (or $-d$) degrees.

What is the easiest way to rotate it so that its sides become parallel to the x-axis and y-axis?

(i.e. How to get the value of $d$?)


texts: Wavelets: How does the admissibility condition imply this $\Psi(0)=0$

texts:
I'm reading through some material on wavelet and I'm finding it difficult to see why the following is true.

Let $\Psi(\omega)$ is the Fourier transform of the mother wavelet $\psi(t)$

$$\int_{-\infty}^{\infty}\frac{|\Psi(\omega)|^2}{|\omega|}d\omega<\infty$$

then many paper on wavelet would immediate jump to, is obvious that:

$\Psi(0)=0$

But wouldn't the above yield a 0/0 condition?

I've also tried relaxing the limits and take a derivative on both side, but this would only imply that the mother wavelet is zero at some frequency $\omega$ not $\omega$ = 0. How do you rigorously prove the above relation?


texts: How to custom optimize cuFFT for a mini batch of multi-channel images?

texts:
I am reading a paper, which has the following paragraph.

  Current GPU implementations of the FFT such as cuFFT are designed to
  parallelize over individual transforms. This can be useful for
  computing a limited number of transforms on large inputs, but is not
  suitable for our task since we are performing many FFTs over
  relatively small inputs. Therefore, we developed a custom CUDA
  implementation of the Cooley-Tukey FFT algorithm which enabled us
  to parallelize over feature maps, minibatches and within each 2-D
  transform. Note that 2-D FFTs lend themselves naturally to
  parallelization since they can be decomposed into two sets of 1-D FFTs
  (one over rows and the other over columns), and each set can be done
  in parallel.

Unfortunately the paper doesn't bring further detail on this. As I could not get a feedback from the authors, I am asking the community,

How this implementation differs from the standard cuFFT implementation of the FFT?

The only thing that comes to my mind is that the standard cuFFT for images, when applied to a mini-batch, performs individual 2D FFT. Then, the only re-computation that could possible be avoided when considering a mini-batch of multi-channel images would be the re-calculation of the Twiddle factor $W_{N}^{k}$. Would there be another way to speed up a 2D FFT for this scenario?


texts: A path to get the foundation of SP and DSP for a pure math

texts:
I have a Ph.D. in pure math (interested in Harmonic analysis and operator theory). I am looking forward some proper references to lead me get the foundation of discrete/signal  processing more and more. Actually,  I had a  review of the  Heppenheim's books  (both signal and digital ones) and (rather) got what he is saying in these  (very nice) book. Now, I am going to develop my knowledge concerning this context and do need to cover  some more advanced ones.   Thanks in advances for you suggestions.
Probably based on my own field, I would  like to read on some texts whose approaches are focused  on  theoretical bases. However having some (proper) references which make me feel (realize) some real applications are in priority.


texts: Wavelet transforms are linear in nature. Then how good they are for time series predictions. Can they analyze nonlinear relations in data well??


texts: Is this a robust method for analysing correctness of a filtered signal? Is there a more robust method?

texts:
I have a recorded signal which contains several frequency components with stochastic phase and amplitude changes and want to extract the true signal with the other frequency components and noise removed. I have performed several filtering techniques to attempt to achieve this. However I need a robust measure of how correct my filtered signal is and I do not have a method of measuring the signal on it's own, without the noise and other frequency components, in order to validate it that way. One method I have applied is minusing the filtered signal from the raw signal in time space and then taking the fft/psd (power spectral density) of the remaining signal and I see that the peak is gone, is this a robust measure of checking the signal I am tracking is correct? Is there any other methods for analysing this without having a way of measuring the true signal?

Some examples of the raw and differences signals for a couple of different filtering methods are shown below: (blue is the PSD of the original raw signal, and green is the PSD of [raw - filtered])


texts: Most efficient way to downsample a signal by a factor of 2.5x

texts: I know that to downsample by a factor of 2.5x one can upsample a signal by a factor of 2 and downsample by a factor of 5. I am wondering what is the best and more efficient way of downsampling by a factor of 2.5x?


texts: Frequency Domain Interpolation: Convolution with Sinc Function

texts:
I am reading a paper, and I came across the following definition of sinc interpolation.

Warning. I don't have a strong background in signal processing. Also, I have no clue what that bar on $\bar{F}$ means. I don't know why that would be the conjugate. Would it actually be the conjugate?
Context. In this part, for a given kernel $f_k$ of size $k$, we want to expand $F_k = DFT\{f_k\}$ to  $F_N = DFT\{f_N\}$ have size $N$, without going to the spatial domain, padding and back to the spectral domain.
Let's discuss on a 1D scenario for notation simplification.
$$
G(u) = F(u) \ast
\left [
e^{\frac{-j 2 \pi u}{N}(\frac{k-1}{2})}
\frac{sin(\frac{\pi u k}{N})}{sin(\frac{\pi u}{N})}
\right ]
$$

Q1. I am assuming that $G(u)$ and $F(u)$ are discrete, having the respective sizes of $N$ and $k$. Is this assumption right?
Q2. Would that second term actually be the $sinc$ kernel, i.e. would the expression below be true? If not, what is their between that term and the sinc function?
$$
sinc(u) = \frac{sin(u)}{u} = \left [
e^{\frac{-j 2 \pi u}{N}(\frac{k-1}{2})}
\frac{sin(\frac{\pi u k}{N})}{sin(\frac{\pi u}{N})}
\right ]
$$

Another way I know to avoid using the DFT to compute $F_N$, is by representing $f_N$ in terms of $f_k$ as
$$f_n = \sum_{i=0}^{k-1} \delta(n-i) f_i$$
Thus, having that
$$DFT\{\delta[n]\} = 1$$
and
$$ DFT\{x[n-n_o]\} = e^{-j \frac{2 \pi}{N} k n_o} DFT\{x[n]\}$$
Hence
$$F_N(k) = \sum_{n_o=0}^{k-1} e^{-j \frac{2 \pi}{N} k n_o } f_{n_o}$$
I am not sure if that the convolution on the frequency domain $G(u)$,
and the impulse based composition $F_N(k)$ are similar approaches of doing the same thing. I did notice the similarity between
$$
e^{\frac{-j 2 \pi u}{N}(\frac{k-1}{2})}
\sim
e^{\frac{-j 2 \pi k}{N}n_o}
$$
But, if this is the case, then,
$$
\frac{sin(\frac{\pi u k}{N})}{sin(\frac{\pi u}{N})} \sim F\{\delta(k-n_o)\}
$$

Q3. Are these the same approaches? Is there any relation between these expressions?
$$\frac{k-1}{2} \sim n_o$$


texts: AR model order selection for half second EEG fragments

texts:
I am using MATLAB to evaluate power spectral density estimates of half second EEG signals, using modified covariance method. Can anyone suggest me how to select the AR model order for this process? Is there any function in MATLAB which can be used for selecting the best order using any model order selection techniques?

Thanks a lot for your help.


texts: How to detect algebraic loop in a system

texts:
I came across a system (screen below) that looks like it should result in a algebraic loop, but when writing the equations using the Z-transform, it obviously does not (calculation below too). But I still cannot figure out how such a system can function, especially if both H and G introduce no delay ? What am I missing here about the way these kind of systems function that would prevent the first + operation to add up with itself recursively ?

(The way I understand it is : the input values travel through the wires until the reach the output.)

Hope the question is not too vague.

To solve this system, we define the signal that is being added to $X(z)$ as $V(z)$, and the signal that is the result of $H(z)(X(z) + V(z))$ as $W(z)$. We get the following system of equality :

$Y(z) = H(z)W(z)$

$W(z) = H(z)X(z) + H(z)V(z)$

$V(z) = G(z)W(z) + G^2(z)Y(z)$

From 3 and 2 we get
$W(z) = H(z)X(z) + H(z)G(z)W(z) + H(z)G^2(z)Y(z)$  $\iff W(z)(1 - H(z)G(z)) = H(z)X(z) + H(z)G^2(z)Y(z)$
 $\iff W(z) = \frac{H(z)X(z) + H(z)G^2(z)Y(z)}{1 - H(z)G(z)}$

Then merging with 1, we have that $Y(z)(1 - \frac{H^2(z)G^2(z)}{1 - H(z)G(z)}) = \frac{H^2(z)X(z)}{1 - H(z)G(z)}$
$\iff Y(z)(\frac{1 - H(z)G(z) - H^2(z)G^2(z)}{1 - H(z)G(z)}) = \frac{H^2(z)X(z)}{1 - H(z)G(z)}$

$\iff Y(z) = X(z)\frac{H^2(z)}{1 - H(z)G(z) - H^2(z)G^2(z)}$

Then we can derive the overall transfer function as $\frac{Y(z)}{X(z)} = \frac{H^2(z)}{1 - H(z)G(z) - H^2(z)G^2(z)}$


texts:
I am dealing with a problem where I need to make a decision on a 500khz  signal under 100usec. The signal is noisy and I am detecting a peak in the incoming signal. Currently I do a 7 step mean filter (down sample by 7) and a moving average of 8 taps following that. This delays my signal 56 samples roughly 112 usec. (2 usec* 7 * 8) If I reduce the filter taps the noise starts to confuse my detector and it starts to fail. Noise is white Gaussian noise, there are no dominant frequencies in the noise.

I am not just interested in the presence of the peak (that would have been a simpler problem) but I am also interested in rise and fall time of the peak. The peak base duration could be between 50 samples (100uSec) to 5,000 samples (10msec). In slow cases the decision speed doesn't matter but in high speeds, the decision speed does make a difference.

My current detector is crude but very efficient. I basically look back filtered signals in time to see if certain thresholds are met or not to make a decision if there is a peak. Once I suspect there is a peak, I find the rise and fall time. This whole operation takes less than 50usec and very optimized. I loose another 100usec in time due to filter memory and I wanted to see if I could get a better detector design.

I have considered several options, such as derivative of the signal (gave up due to noise), matched filter (due to wide frequency range, difficult to design a filter that would work well etc.)

I am looking for ideas to optimize my decision time from its 150usec to 100usec range by reducing the filter delay but not impacting the filter quality.


texts: How to choose good features for my machine vision application?

texts:
I am trying to create an application (with OpenCV3) that can distinguish sidewalks from streets by a real-time camera that is embedded in a glass. I have 3 question about this project:

Which features are better to use? (For example cars and road lines for street, people for sidewalk).
Which OpenCV functions may be usable for this project (I know this is a very bad question, but I am newbie and seeking some idea and guide).
How many hours of camera capture do I need for this? Can one do a rough estimation?

Thank you in advanced!


texts:
I have a question regarding the polyphase DFT filter bank implementation in this page. (https://cnx.org/contents/Peqc-TK2@16/Uniformally-Modulated-DFT-Filterbank)

In figure 2, to analyze the kth filter bank branch, the signal $x(n)$ was multiplied with $e^\dfrac{j2\pi kn}{M}$. But to downconvert a signal to baseband and low pass filter it, the signal should be multiplied with $e^ -\dfrac{j2\pi kn}{M}$. I made this change and continued derivation, I ended with getting IDFT block instead of getting DFT block as shown in Figure 7.

I referred multiple books and papers for this. Everywhere I found a DFT block in the block diagram. But, I couldn't find where I am doing wrong. Please help me in knowing the correct block diagram.


texts:
When I apply differerent thresholding, wavelet denosing functions to non stationary time series which has been detrended via Loess regression and demean it. I expect that when this processed series are submited to denoising / thresholding will result in a clean series with smaller values than the submited signal and not to values at any point which are above those of the signal, Is my thinking correct.

On another hand could it be thought as per those values in a procesed signal which lie above the processed signal as if the procesed signal would ought  to be above those levels instead than below those levels. Of course the functions that described the signal is an aproximation so fiting erros should have to be expected.


texts: How are pulse trains generated in a radio transmitter?

texts:
When simulating a PSK signal in MATLAB or Python, I often create an impulse train where each impulse is modulated with a symbol. This modulated impulse train then passes through a pulse shape filter to yield the PSK signal.

However I am wondering if this is indeed how PSK signals are generated in real radio electronics hardware. Is there an electronics module which generates modulated impulses which passes through an analog filter? If so, how narrow are such pulses typically?

I know the block diagram representation of PSK implementation in hardware often shows dataflow split into two paths, one for In-phase and one for Quadrature-Phase. Each path passes through a Root Raised Cosine filter before combining back again. However it is not clear to me how this RRC module is implemented in hardware.


texts: How can I automate the calculation for P and I coefficients of an FPGA-based digital PLL?

texts:
I am working on designing an FPGA-based PLL through an NI myRI0-1900 FPGA and LabVIEW software. I have been able to create a functioning PLL with a PI loop filter, and but I found functioning P and I coefficients through trial and error for a 1kHz signal, However, when I try to have my program compute the P and I coefficients with equations listed below, the values are too large for the PLL to be stable.
As background on my algorithm, I have a pipeline of various loops setup where I read an external sample through an ADC, mix it with NCO signals to create I and Q signals, send these through an LIA algorithm to recover the phase difference between the NCO and ADC, send this error signal through a PI control, then send the post-PI signal back to the NCO so that it can increment/decrement its phase (frequency) towards the external signal that is being tracked. I output this NCO signal through a DAC.
Now, for a 1kHz external signal, I have found that a P coefficient of around 3.50E-6, and an I coefficient of around 1.00E-8 works pretty well. These coefficients scale the phase difference between the NCO and ADC, and the result is summed up and sent to the phase accumulator. The way I found this was by starting with an I coefficient of 0, and a very small P, then I made the P larger and larger until it worked relatively well. Afterwards, I kept the P constant, and I then made the I coefficient very small before making it larger.
However, I want to calculate these P and I values for my system so that I may automatically adapt their values to work well for the frequency of the ADC signal. The first equation below is one that I found for calculating the Kp, while the second is for the ENBW, of which Kp is a function of. My equations were found from the following link: https://wirelesspi.com/phase-locked-loop-pll-in-a-software-defined-radio-sdr/

For (what I believe to be) the sampling rate, Fs, I found it through the following. I set the loops in my pipeline to all take 120 ticks to iterate, where 1 tick = 25ns. Thus, each loop takes 3 microseconds, and I can manage 333.3 kSa/s - a sampling rate of 333.3 kHz.
For the w in the Bn, I used (2pi * f), where f is the frequency in Hz of my ADC signal (I have a separate algorithm that can track this frequency well, so I don't need to manually input this). For testing, I use a 1 kHz ADC signal.
For the Bn (the ENBW), I used the equation for it below, but with a damping factor of 0.7071. And assuming that f = 1kHz, then my Bn evaluates to 1060.66.
For the K0 and KD, they are 1 and 1/2, respectively.
Finally, I plug these numbers into the equations above so that I can solve for the Kp, but my answer, is 0.0170, which is far larger than the 1E-7 that works well. How may I achieve an answer around the 1E-7? Is my math process logical? Could some of my variables be incorrect?
Please let me know of any questions or concerns. I would be obliged to assist.


texts: Revert anayltic signal(length(N/2)) to real signal (length(N))

texts:
As a beginner in signal processing, i'll try to explain my problem most thoroughly.
I'll firstly explain the idea of the transformation the real valued data has undergone.
This includes the ideas and reasons why it does work and the way to revert the procedure. Then i'll explain my difficulties in reverting it.

First of all a property of the FFT of a real signal:

Given an $N$ data point real valued signal $x(t)$, it has $\frac{N}{2} + 1$ unique Fourrier coefficients $X(f_i)$ with  $i \in {0,..,N-1}$. The other $\frac{N}{2}-1$ coefficients can be retrieved by inverting the spectrum of the coefficients $X(f_1)$ to $X(f_{\frac{N}{2}})$.
So in some sense all the information of my signal is stored in the first $\frac{N}{2}+1$ of it Fourrier coefficients. Keep that in mind, because this property i'm going to exploit to retrieve the original signal from it's analytic representation.

Now to the theory of the procedure the data has undergone:

Let $X_a (f_i)$ be the analytic representation of the Fourrier coefficients $X(f_i)$ of $x(t)$.
Then $X_a(f_i)=0$,  if $f_i < 0$, and for the Fourrier Coefficients of the original signal $x(t)$ we know that $X(f_i)= \frac{X_a(F_i)}{2}$with $i \in 1,...\frac{N}{2}$. So $\frac{N}{2}-1$ coefficients carry no additional information about the signal. This allows a downsampling to $\frac{N}{2}+1$ frequencies, by cutting those $X_a(f_i)$ off, with $f_i <0$. And no information is lost, as the original signal was real. To make sure you can follow me http://en.wikipedia.org/wiki/Analytic_signal explains it in detail. Let's call the resulting complex signal of length $\frac{N}{2} +1$ $x_c(t)$.

The way to retrieve the original real signal would be:

If i'd want to retrieve my original signal all i'd have to do is invert the Fourrier Cofficient vector $[X_a(f_i)]$, $i \in 1,N-1$ and append them to my frequency spectrum.
Resulting in the spectrum: $[X_a(f_0),...X_a(f_{\frac{N}{2}+1}), X_a(f_{\frac{N}{2}}),X_a(f_{\frac{N}{2}-1}), X_a(f_{\frac{N}{2}-2}),...X_a(f_1)]=FFT(x(t))$ of my original signal $x(t)$.

Now to my situation:

I do get something similar to the results of above modification of signals.
The major difference is that i don't get all $\frac{N}{2}+1$ coefficients of the complex signal $x_c(t)$. But what i do get is the complex signal from $0$ to $\frac{N}{2}-1$. So what i'm lacking is the coefficient $X_a(f_{\frac{N}{2}})= \sum_{k=0}^{N} e^{i\pi k}x_a(k)$ of the Fourrier transform of my Fourrier pair $(X_a(f_i),x_a(t))$. This is a real valued Fouerrier coefficient of the signal $x(t)$ at the nyquist frequency.

So what way i would be able to get the best approximation of my original signal?

Thanks in advance!!

PS: Hope this format is way better than before.


texts: OpenCV denoising a 3x3 pixel pattern noise

texts:
This picture

shows two photos captured by a camera from a black photographic paper. The cross is marked by laser. The left one shows a 9 pixel pattern of noise.

This gets in the way of auto-focus process.

Backgroud： My boss asked me to improve the auto-focus algorithm of a camera to a higher precision (say from 1mm to 0.01mm). This auto-focus process is a preparation stage for laser marking.

The original algorithm uses "Sobel" to calculate sharpness and compare the sharpness of photos at consecutive camera distance to see which one corresponds to the distance nearest to focal length.

Sobel(im_gray, grad_x);convertScaleAbs(grad_x, abs_grad_x);
Sobel(im_gray, grad_y);convertScaleAbs(grad_y, abs_grad_y);
addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad);
for (int i = 0; i < grad.rows; i++)
    for (int j = 0; j < grad.cols; j++)
       sharpness += = grad.at<unsigned char>(i, j);

This algorithm works fine for complicated photo (with higher brightness and more info), despite the noise, the sharpness value changes monotonically. But for simple photo (with less brightness and less info), the sharpness value doesn't change monotonically.

I first noticed brightness variance gets in the way of calculating the correct sharpness so I used histogram equalization (already tried "BrightnessAndContrastAuto", not working), and it improves the result to some extent.

equalizeHist(im_gray, im_gray);

After inspecting the problematic shapness values, I realized the noise is another interfering factor. So I used GaussianBlur both of size 3x3 and 5x5 to denoise (already tried "fastNlMeansDenoising", not working ) before histogram equalization. Still there are problematic sharpness values ( certain values break the monotonic trend).

GaussianBlur(im_gray, im_gray, Size(5, 5), 0);
result:
-0.2    41.5362
-0.18   41.73
-0.16   41.9194
-0.14   42.2535
-0.12   42.4438
-0.1    42.9528
-0.08   **42.6879**
-0.06   43.4243
-0.04   43.7608
-0.02   43.9139
0       44.1061
0.02    44.3472
0.04    44.7846
0.06    44.9305
0.08    45.0761
0.1     **44.8107**
0.12    45.1979
0.14    45.7114
0.16    45.9627
0.18    46.2388
0.2     46.6344

To sum up,my current algorithm is as follows:

GaussianBlur(im_gray, im_gray, Size(5, 5), 0);
equalizeHist(im_gray, im_gray);
Sobel(im_gray, grad_x);convertScaleAbs(grad_x, abs_grad_x);
Sobel(im_gray, grad_y);convertScaleAbs(grad_y, abs_grad_y);
addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad);
for (int i = 0; i < grad.rows; i++)
    for (int j = 0; j < grad.cols; j++)
       sharpness += = grad.at<unsigned char>(i, j);

Question: Could someone tell me how I can remove the noise by adjusting the sigma or size parameter of GaussianBlur or using another denoising algorithm?


texts:
I made a simple RF sensing using USRP N210. I am trying to detect LoRa transmission.
A LoRa Node is operating at 915 MHz with Spreading Factor 8 and bandwidth 500 kHz.
I have used a USRP UHD Source with sampling rate 500 kHz, I plotted a Waterfall diagram to show the real time visualization.
Only when I tune the USRP center frequency to 930 MHz I see some LoRa spreading spectrum. However it does not match the bandwidth at which it is operating.
The variation in center frequency maybe due to clock mismatch, however I am not sure about the bandwidth issue.
Any reason why the result is showing like this?


texts: Audio Bit Depth "mapping" from DAW to Audio card: is this correct?

texts:
Let say I'm generating a 1 kHz sine wave within my DAW, using some synth (Sytrus in my case). I normalize it, so it play at max "digital" amplitude 0db.

Thus, any sample of the signal would gets a Floating Point values (in 32 or 80 bit of precision, using FL Studio 32bit; but that's irrelevant right now).

This means that all values (since the signal is normalized) goes from -1.0 to 1.0 max.

Now, the signal go through ASIO Drive and reach my sound card (an M-Audio FireWire Solo), 24-bit (fixed-point representation). Due to ENOB, it will use 21-bit, thus the max value would be 1048576 (which is 100000000000000000000 in binary).

Is correct to state that the value 1.0 is mapped to 100000000000000000000? And -1.0 to 000000000000000000000?

I'm really not sure about this. Does this mapping happen? Is it correct the range I've used (-1.0/1.0 => 000000000000000000000/100000000000000000000)?

Can you help me to understand this "mapping", if any?


texts:
I am trying to simulate example 8.2.2 from Hayes, Statistical Digital Signal Processing and Modelling, on MATLAB.

Let $x(n)$ be a WSS process consisting of random phase sinusoid in unit variance.
$$ x(n) = A\sin(n\omega_{0} + \phi) + v(n)$$

$A = 5 $, $\omega_{0} = 0.4\pi$, $N = 256$

Can anyone help me figure out how to generate the frequency vector such that the peak appears at $0.4\pi$? I am able to achieve the spectrum that is shown in the example, but my x-axis can only be called frequency bin as of now.


texts:
Consider we have QPSK signal with carrier frequency 10kHz. Generally, we demodulate  or use matched filter on the the QPSK signal and recover the transmitted bit or the symbols. If the QPSk signal is noisy can we use band pass filter before demodulation, where the pass band  is around 10 kHz? The QPSK signal has discontinuity when the bit/symbol changes, so are we going to loose valuable information if we band pass the signal before matched filter? Is there an appropriate band width of the band pass filter which can be applied so that matched filter still works after the band pass filter?

EDIT: More importantly can a band pass filter prior to matched filter show better results? If so under what conditions?

This question is also asked in: https://electronics.stackexchange.com/posts/444921/edit


texts: I have a desired filter magnitude response, i.e. $|H(j\omega)|$. How can I find the time-domain coefficients of a filter $h=[h_0, h_1, ..., h_{L-1}]$ that has a similar magnitude response such that $h_0=1$?


texts: Matlab plot of QPSK system doesn't agree perfectly with theoretical BER curves

texts: Does anyone know if there is a simple explanation on the fact that the theoretical bit-error rate (BER) curves of a Quadrature phase-shift keying (QPSK) system are approximately 1 dB shifted from the simulated curves?


texts: What does the phase of a FFT bin of an audio signal represent?

texts:
I currently run real time audio through an FFT and the library (vDSP) returns magnitude and phase values (polar coordinates) for data in the FFT bins.

Does the bin with the highest magnitude always represent the fundamental frequency?

What exactly can the phase of the frequency bins be used for in regards to audio? What does it represent? Would that be used for audio identification, e.g. matching amplitude and phase pairs within the same bins of different audio segments?


texts: Detrend data with no clear secular trend prior to Fourier analysis?

texts:
I am completing Fourier analysis on many different time series of sediment particle flux exiting an experimental flume. Data is collected at a resolution of 1 Hz for durations ranging from ~5,000 to 50,000 seconds. Flux ranges from 0 to over 1,000 particles. The figure below shows an example time series that I am analyzing - the x-axis has units of seconds and the y-axis has units of particles/second:

I am familiar with time series and Fourier analyses, but I am not an expert. A colleague told me that I should detrend all of my time series before performing the Fourier analysis. I have completed the analysis without, and with detrending the time series and I see no obvious difference in the resultant spectra; this does not surprise me because I see no secular trend, for example, in the data shown in the example figure above. This leaves me with several questions. First, should I detrend the example time series shown in the figure above? If I should, why (or why not)? Second, there are at least several ways I can think of to detrend the example time series (e.g. subtracting a polynomial fit, subtracting the series mean, etc.), do people have any suggestions for a time series like the example one shown above? Last, are there clear criteria I can work with in making a decision of whether detrending is necessary prior to completing a Fourier analysis? Thanks.


texts: Difference between discrete time fourier transform and discrete fourier transform

texts:
I have read many articles about DTFT and DFT but am not able to discern the difference between the two except for a few visible things like DTFT goes till infinity while DFT is only till N-1. Can anyone please explain the difference and when to use what? Wiki says

  The DFT differs from the discrete-time Fourier transform (DTFT) in
  that its input and output sequences are both finite; it is therefore
  said to be the Fourier analysis of finite-domain (or periodic)
  discrete-time functions.

Is it the only difference?

Edit:
This article nicely explains the difference


texts:
I'm trying to filter an image vertically to get the edges, in MATLAB, but I get very different results from convultion and correlation.

CODE:

vf = fspecial('prewitt');

iyconv = imfilter(im, vf, 'replicate', 'conv');
iycorr = imfilter(im, vf, 'replicate', 'corr');

result in the image below,

why does the convultion only outputs the lower part of the mouth, and on contrary the correlation teh upper?


texts: Visualizing the measure of each FFT frame as an image in an audio signal

texts:
i wrote a function in MATLAB which will divide a
audio waveform (a speech) into smaller windows with overlap .The output will be
a matrix X, each column of which contains the windows which i export.
Then i calculate the FFT of each column and i visualize the measure of each FFT frame as an image, using the "imagesc" command. I saw a shape that is symmetric
to the horizontal axis. Why i have this symmetry?.


texts: Calculating the true values of biquad filter coefficients from normalized form

texts:
I have a C code in which the IIR filter(BiQuad) uses only 4 (normalized) coefficients per stage (a2/a0,a1/a0,b2/b0,b1/b0) instead of 6 coefficients (a0,a1,a2,b0,b1,b2). I know that the value of a0 is always 1. So, it is easy to find the true values of the a2,a1 coefficients (since a0 value is 1).  But, i wanted to know the true values of b0, b1, b2.

So, I just want to know is there any way to retrieve/derive the true values of "b" coefficients?  One of my friends told me that we can get the values by using Matlab / octave? But, I have no idea how to do it?


texts: A guy is taking pictures of my home and family, how do I decode his license plate?

texts:
I had no idea where to post this.

I'm trying to decode a license plate and take it to the police station. The police said that they'll try to decode it, with no promises. If they had a full license plate, there would be an investigation. There's a man, which is taking pictures of my house for two weeks now, mainly during night. We are all really scared so I thought that someone in the web will help me.

I have a set of 5 images with the best resolution I could possible come with my camera.

Original link to images.

I've tried multiple approaches, mainly I read about OCR and the text recognition and tried online solutions, but couldn't came up with a good result because the image his car is in a really bad rotation and these systems say that the photo is too blurry. I know some photoshop so I've tried messing with the contrast, making a high-pass, filtering the image.

I came up with first two digits which are probably WI or WL but I'm really not sure.

I read that this kind of Q/A is not a place for solving problems like this directly, but I really don't know what to do here. I live in Poland. If you could help me, I'd be grateful.


texts: At high SNR i am able to detect the burst by taking the magnitude of the data and setting the threshold. for low SNR it it difficult to set the threshold?


texts: How does this digital signal controlling a switch in the circuit affect the output voltage?

texts:
Suppose you have a circuit which has the input signal $x(t)=2\sin (ω_ot + \pi/6)$. The switch in the circuit is controlled with a digital signal of the form: $s(t)=\sum_{k=-\infty}^{+\infty} (u(t+ε-kT_s) - u(t-ε-kT_s))$, $\frac{2\pi}{T_s}=800\pi$, $ε\to 0$, so that when the signal equals 1 the switch is closed and the output signal equals the input signal and when it is open the output signal is 0. Note that $u(t)$ is a step function evaluated as $u(0)=1/2$.

The task is finding the Laplace Transform of the output signal.
The digital signal form to me looks like a very thin rectangular impulse series of width $2ε$ and a period of $T_s$.

My question is: does the output signal in time domain equal the product of these two signals so it translates to the convolution of their respective laplace transforms or is something else going on that i'm not seeing?


texts: fft result order compared to direct implementation of DTFS using text book

texts:
To find the complex Fourier coefficients of this sequence, then The $k^{th}$
coeff. $c[k]$ is given by the DTFS formula

$$
c[k]=%
%TCIMACRO{\dsum \limits_{n=0}^{N-1}}%
%BeginExpansion
{\displaystyle\sum\limits_{n=0}^{N-1}}
%EndExpansion
x[n]\exp(-in\frac{2\pi}{N}k)
$$

(Lets forget about the $1/N$ scaling for now). My question is on the ordering
of the result.

For example, given $x=[1,1,0,0]$, hence $N=4$. Then applying the above gives

$c[0]=2,c[1]=1-i,c[2]=0,c[3]=1+i$

but Matlab's  fft  gives

c=fft([1 1 0 0]);

$c[0]=2,c[1]=1+i,c[2]=0,c[3]=1-i$

So matlab's $c[1]$ is the formulas $c[3]$ and Matlab's $c[3]$ is the formulas
$c[1]$. So the order seems to be swapped around.

Ofcourse they are still complex conjugate of each others. So both answers are correct.

My question is on the order of terms and why they come out this way.

Any thought on what that is, and why the result is not in the same order as
the formula gives? And if it is possible to make fft give the same order as the formula?

add

I found the problem. I used transpose to change row result from fft to column to make it easy to see. But I did not use the correct tranpose.

When I transposed the result, which was a row, to a column to easier to see, the terms got switch around. Here is an example

z=[1 2+1i 3 4+1i];
z'

   1.0000 + 0.0000i
   2.0000 - 1.0000i
   3.0000 + 0.0000i
   4.0000 - 1.0000i

I should have used non-conjugate tranpose:

z=[1 2+1i 3 4+1i];
z.'

   1.0000 + 0.0000i
   2.0000 + 1.0000i
   3.0000 + 0.0000i
   4.0000 + 1.0000i

So, terms are in correct order all along.

User error. sorry.


texts: Complex bandpass filter giving quadrature signal

texts:
I have found a technique detailed on page 34 & 35 of this thesis.

In this, the author states a complex bandpass filter can be derived by first making a prototype real valued IIR filter, then setting the complex conjugate poles equal to each other. He then states the resulting complex filter will have a quality factor half that of the real valued one but the same centre frequency. The resulting filter is then more efficient than a combination of bandpass filter + Hilbert transform.

I can find no reference to this technique anywhere! Can anyone point me towards a reference explaining the mathematical concepts of this or an example of it's implementation so I can understand it better? How would you rate this technique compared to a bandpass+hilbert transform, or is there an even better way? I am only looking to achieve a quadrature signal for further processing, in this case frequency shifting.


texts: Don't understand what is meant by signal dimension

texts: I don't understand the concept of dimension of a signal.  I ran into it in an explanation of Shannon Capacity, and in a paper on spread spectrum. I was hoping somebody could explain with an example.  Does it apply to analog as well as digital?  For instance is AM two dimensional considering time and amplitude?  Or is QPSK two dimensional because it is a combination of a sin and cosine term?  Or does multilevel signaling like Pulse Amplitude Modulation have as many dimensions as discrete levels it can take, or would dimensionality refer to the number of possible symbols it can represent in a pulse?


texts:
How do we show  $y_0(n) = y_1(n)$
when $h_k[n] = h[n] \cos(\frac{2\pi}{L} k n )$


texts: Approximate the change in perceived gain from applying transfer function to audio signal

texts:
I have an audio signal that I am applying an analogue transfer function $H(s)$ to. I would like to approximate the change in gain ($\Delta \text{ Gain}$) as perceived by the listener for an arbitrary audio signal sent through the filter $H(s)$.

I was thinking something along the lines of:

$$
\Delta \text{Gain} = \frac {\displaystyle\int_{0}^{\pi} \lvert H(\omega)\rvert d\omega} {\pi}
$$

This is based on an assumption that the formula above gives a sensible approximation of gain across the spectrum by calculating the averaging gain.

Is my thinking sensible or is there some proper theory that will give a better answer that I can refer to?


texts: Extra energy when altering frequency amplitudes

texts:
How can I convert a time signal (audio) into the frequency domain, multiply frequency amplitudes by a vector of scalars, and convert it back into the time domain, without messing up timing information (ringing?)?

Some context:

I am calibrating ultrasonic speakers. I have a frequency roll-off curve of the attenuation dB for each frequency, from a reference point. I now want to compensate my output using this curve.  Here is an example that was gathered experimentally:

I can then multiply my output signal in the frequency domain by this attenuation vector, and convert back into the time domain. For the most part this works, however, there is some extra energy at the wrong times, and I am not sure why. Here is what it looks like:

Here is some python code to demonstrate what I have. To make this a compilable example I try to approximate the attenuation vector with a sawtooth for variation.

    import numpy as np
    from scipy.signal import chirp, sawtooth

    def smooth(x,window_len=11):
        """smooth the data using a window with requested size."""

        s=np.r_[x[window_len-1:0:-1],x,x[-1:-window_len:-1]]

        w = np.hanning(window_len)
        y=np.convolve(w/w.sum(),s,mode='valid')
        return y[window_len/2:len(y)-window_len/2]

    fs = 5e5
    duration = 0.2
    npts = duration*fs
    t = np.arange(npts).astype(float)/fs

    # my output stimulus
    x = chirp(t, f0=5000, f1=1e5, t1=duration)

    X = np.fft.rfft(x)

    # stand-in attenuation vector
    variation = sawtooth(np.arange(npts/2 + 1)/500)
    attendB = np.linspace(0, 30, npts/2 + 1) + variation

    # attempt to minimize ringing?
    attendB = smooth(attendB)

    H = 10**((attendB).astype(float)/20)

    # signal adjusted to calibration
    A = X * H
    a = np.fft.irfft(A)

    # ==== plot ====
    import matplotlib.pyplot as plt

    plt.subplot(211)
    plt.specgram(x, Fs=fs)
    plt.title('original')
    plt.subplot(212)
    plt.specgram(a, Fs=fs)
    plt.title('adjusted')
    plt.show()

I can eliminate the extra energy by increasing the smoothing. However, this also reduces the accuracy of the calibration, as assesed by comparing the desired and recieved frequency response. Is this a trade-off I have to deal with, or am I going about this the wrong way? Alternatively, is it a feasible solution to implement this as a filter in the time domain?


texts: How to Apply the SSIM Measure on RGB Images?

texts: I want to compare the similarity of two images by looking at its structure and colors. I need a measure that takes both structural and color fidelity into account. When I checked the formulation of original paper, it is said only x and y mean and variance is measured. Does SSIM account for structure only or does it take color similarity into account too?


texts: Need information about following channel model

texts:
The following research paper is for blind channel equalization and the author has modeled the channel as 7 tap weights

https://ieeexplore.ieee.org/document/1096877

On page 3 it has shown the channel tap weights which they have used it. I want to know information about the channel? Is it the multipath fading channel or what kind of channel they are using? If somebody can help? and can I simulate the following channel in MATLAB,if yes then how?

The channel impulse response is given in figure below:


texts: Using SURF algorithm to match objects on MATLAB

texts:
I am trying to find the difference between two images, using Matlab. The classic built in function that Matlab provides for this is because the two images don't have the same dimensions (The objects in the images are the same, but in the second image other objects are introduced).
i need to use a metric or function can calculate the number of matching feature between two images and give me a value to decide according to threshold ..

source = imread('source.png');
target = imread('target.png');
source = rgb2gray(source);
target = rgb2gray(target);
  sourcePoints=detectSURFFeatures(source,'MetricThreshold',100.0,'NumOctaves',1,'N   umScaleLevels',6);
 targetPoints=detectSURFFeatures(target,'MetricThreshold',100.0,'NumOctaves',1,'NumScaleLevels',6);
     [sourceFeatures,sourcePoints]=extractFeatures(source,sourcePoints,'SURFSize',64);
     [targetFeatures,targetPoints]=extractFeatures(target,targetPoints,'SURFSize',64);

  boxPairs = matchFeatures(sourceFeatures, targetFeatures);

  matchedSourcePoints = sourcePoints(boxPairs(:, 1), :);
  matchedTargetPoints = targetPoints(boxPairs(:, 2), :);

  % IS there any metric can used to make accurate decision if there is a match or not instead of percentage because its not accurate as required
  numPairs = length(boxpairs); %the number of pairs
  percentage  = numPairs/100;

     if percentage >= 0.40
     disp('We have this');
       else
     disp('We do not have this');
     disp(percentage);
    end

IS there any metric can used to make accurate decision if there is a match or not instead of percentage because its not accurate as required


texts: What is the Roll-Off factor of a Root Raised Cosine Filter?

texts: When designing a root raised cosine filter on Matlab, there is an option to set its "roll-off factor". What does this mean? I have been looking around for a while but I can't seem to find a clear explanation. Any help will be appreciated.


texts: Is there a name for the procedure of taking the FT over separate consecutive small time-blocks?

texts:
Suppose we have a continuous time-interval $I=[a,b]$, and a signal $x \colon I \to \mathbb{R}$.

A procedure that is sometimes carried out (e.g. when doing bispectral analysis) is to partition $I$ into $k$ small sub-intervals $[a\!=\!a_0,a_1],[a_1,a_2],\ldots,[a_{k-2},a_{k-1}],[a_{k-1},a_k\!=\!b]$ and take the Fourier transform of $x$ over each of these intervals,
$$ \hat{x}(n,\xi) \ := \ \int_{a_{n-1}}^{a_n} x(t)e^{-2\pi i \xi t} \, dt \, , \hspace{8mm} n \in \{1,\ldots,k\}. $$

Is there a name for $\hat{x}(n,\xi)$ (e.g. something like "time-segmented Fourier transform")?


texts: What is the minimum sampling rate of a $\sin(\pi t)$ signal? When the sampling frequncy is twice that of the frequency, the spectrum is not present and in time domain all the samples we get is 0. In this case does the sampling rate should be greater than $2 f_\text{s}$? Then how does the Nyquist rate fit in this?


texts: Document image vanishing point detection and evaluation

texts: It is a natural idea to substitute our scanner with mobile phone, and perform OCR with the phone at the same time. If this can come true, two problems must be tackled: one is related to document image binarization, and the other is related to geometric distortion correction. Among all the distortions, projective distortion is most common, and in order to correct this kind of distortion usually the horizontal vanishing point and vertical vanishing point must be identified. There are many different ways to obtain the vanishing points, and different methods can lead to different vanishing points. Then my question is given several candidate vanishing points (horizontal vanishing points, for example) how can we select the best one? Of course we can get the projective transform model based on each vanishing point, and then correct the distorted image. Visual evaluation the corrected image can tell which vanishing point is better. But could I find the best vanishing point just before the correction? Thanks!


texts: What are the spike removal techniques in matlab without using filters

texts:
output from wavelet filter using daubechies 4 wavelet.

Using wavelet filter this is the output obtained. The problem is elimination of the spikes at 0.023,0.043,0.063 and so on. Please note: no predefined filters present in simulink and dsp toolbox are to be used. Kindly suggest an alternative method to remove the spikes.


texts: Construct a signal that is multiplied by a white noise?

texts:
Can we reconstructs a signal after it is being multiplied (not added) by a random noise (not with the normal distribution)?

Lets say I have S=10*sin(2*pi*5*t) for t=[0:.001:1] and I have a random noise V for the same time t. How Can I reconstruct S from X=S.*V (element wise product)?

Is is theoretically possible? I read this post about the Multiplicative noise but still I need help.

If the noise is truly random, doesn't mean that it can ruin the signal completely?

Thanks,

Background of my question: there is a machine learning method called "Non-negative matrix factorization" that can be used to find the components of a signal (assume signal is a combination of those components). I have seen this method as able to find the right components even after the combined signal was multiplied by a white noise!!


texts: How to find a know signal in another signal which contains other signals along with the signal i need in python

texts:
I am working on BPSK with sound waves a carrier waves.

Actually I am modulating my data with some known sync bits along with the information I need to send. So the things I will be having at demodulation side is these sync bits and carrier wave.

So I am modulating these sync bits with carrier and cross correlating this modulated (over sync bits) wave with received wave at the transmiter. By doing this I want to find the exact time position (where these sync bits appear in received wave).

For this I am first crosscorelating received wave and my sync wave then, when I plot it I wil surely get a maximum where the sync wave in both signals coincide.

But I am not sure if this maximum is the position I need (when there is a DC offset or large amplitudes in the received signal, it can also create an extreme value)

So to overcome this, I autocorelated my sync wave with itself and took the
absolute difference between the all the values of crosscorelated matrix and
autocorelated value. Then I assumed which ever value has the least value as the
synced location.

This is also not working (I think as iam not sure that
the location iam getting is midpoint of sync or starting of sync). Is this
approach correct?

Or are there any other approaches to find the starting sync position in received wave?

I also needed help in knowing whether if we use the first method (wher evr maxima comes in crosscorelation taking tht as sync location) is this location I got, is sync starting location or midpoint of sync?


texts:
I have two questions related to this image;

Is it possible to  identify any spatial domain features in the frequency domain?

My understanding: what I read around they are mostly the same as spatial domain but shows $\sin$ or $\cos$ ripples for every position in the frequency domain but not sure if it correct something like this:

Second question: when I have information about the images, the frequency spectrum and histogram, how do I select the compression method? Do I look for specific pattern or do I need something else? Or is it something entirely else?


texts: Expanding piecewise polynomial using Daubechies wavelet

texts:
What is the best Daubechies wavelet (i.e. the number of vanishing moment) to expand a signal $\boldsymbol{x} \in \mathbb{R}^n$?
$\boldsymbol{x}$ consists of $m$ pieces of polynomial with $d$ degree. The criterium is to make the DWT signal as sparse as possible.

Update:
The goal of sparsifying the signal in wavelet domain is denoising. Let $\boldsymbol{W}$ denote DWT.
$$
\boldsymbol{y} = \boldsymbol{Wx}
$$
Apply a soft-thresholding to $\boldsymbol{y}$,
$$
\hat{\boldsymbol{y}} = \text{sign}(\boldsymbol{y})(\max(\boldsymbol{y}-\lambda,0))
$$
Choose $\lambda=\sqrt{2\log n}$ according to Ideal spatial adaptation by wavelet shrinkage.
The sparsity is defined by $\| \hat{\boldsymbol{y}} \|_0$.


texts: simulating directional interference to evaluate model performance

texts:
I have a model for audio processing. The model receives as input, a source, convolved with a room impulse response (RIR). I would like to test the performance of the model against inputs containing directional interference. The sources and interferences are simply audio recordings (for example human speech, a dig bark, car engine, etc.). both source and interference are convolved with two different RIRs (with respect to angle) and then a gain $A$ is applied to the noise in order to control the desired SIR.

The signals power: $P_s(t)=mean(x^2(t))$

The interference (noise) power: $P_n(t)=mean(n^2(t))$

The amplified interference power: $P_{An}(t)=mean(A^2n^2(t))=A^2mean(n^2(t))=A^2P_n(t)$

And if we want to isolate $A$, we have:
$$SIR=10 \log\left(\frac{P_s(t)}{A^2P_N(t)}\right)$$
$$A=\sqrt{\frac{P_s(t)}{10^{\frac{SNR}{10}}P_N(t)}}$$

Now, considering I am working from a dataset of audio files with variable length, will this not cause a problem due to the averaging process? For example, if the interference is of length $T_1$ and the source is of length $T_2>T_1$. The interference will be of worst than the desired SIR in the interval $0<t<T_1$ and better in the interval $T_1<t<T_2$.

Is my thought process correct?
Is there a known method of dealing with such a problem?
How do I set the correct SNR for such an experiment?


texts: I am a beginner in digital image processing, recently I read a paper on color image contrast enhancement, In that paper authors have implemented their method in HSV color model. In my work I have implemented that paper in MATLAB using RGB color model. I just want to know that whether it will make any difference or not?


texts: Reconstruction of audio signal from Spectrogram

texts:
I have a set of songs for which I extracted the magnitude spectrogram using a Hamming Window with 50% overlap. After extracting the spectrogram, I did some dimensionality reduction using Principal Components Analysis (PCA). After reducing it to lower dimensionality, I reconstructed the spectrograms from lower dimensions. So now, there would be some error between the original spectrogram and the reconstructed spectrogram. I would like to convert this spectrogram back to the audio signal and play it, so that I would be able to know when reconstructed from lower dimensions, how does the audio sound.

Is there any function available in say Matlab. to convert a magnitude Spectrogram to an audio signal ??


texts:
In the figure there is represented a step response of a mechanical system. I created a step variation in the excitation of a DC generator. This lead to a step variation in the torque developed by that generator. I measured this torque with a arm connected to the stator and to a load cell.
Is this thing normal?

I tried to identify the transfer function of this system have as output the plot from the figure and a step change as input. I used IDENT from MATLAB and got a transfer function with 3 zeros and 3 poles with a fit of 85%. I used this transfer function with a sin wave input and computed the phase shift between the input and the output. This shift is very small, 2-3°. Is this thing normal?
I see that my system has a big delay from the step response but with sin wave response the delay is very small.
Is it possible that the procedure for obtaining the transfer function is not correct?


texts:
Assuming that filtered signal $y(n)$ is given  as

$$
y(n)=x(n)\star h(n)=\sum_{m=0}^{2N-1}x(m)h(n-m), \quad n \in[0,1,\ldots, 2N]
$$

where $\star$ is convolution parameter. $x(n)$ is discrete signal of lenght $2N$ and $h(n)$ is filter of the same lenght as $x(n)$. If I want to take for example $N$-point FFT of $y(n)$ how it would look like

\begin{align}
DFT_{N}(y(n))=\sum_{n=0}^{N-1}(x(n)\star h(n))&e^{-j\frac{2\pi nk}{N}}=\sum_{n=0}^{N-1}\sum_{m=0}^{\mathbf{2N-1}}(x(m)h(n-m))e^{-j\frac{2\pi nk}{N}}\\
&\textrm{or}\\
DFT_{N}(y(n))=\sum_{n=0}^{N-1}(x(n)\star h(n))&e^{-j\frac{2\pi nk}{N}}=\sum_{n=0}^{N-1}\sum_{m=0}^{\mathbf{N-1}}(x(m)h(n-m))e^{-j\frac{2\pi nk}{N}}\quad ?
\end{align}


texts: Mathematical model of a signal in Compressive Sampling

texts:
Currently I am reading a paper on Compressive Sampling, and trying to understand each and every parts of it. When I came across the mathematical model of the signal in paper, I got confused.  I have mentioned the part of paper for your convenience

Consider the following mathematical model for a class of discrete multitone signals. Let $W/2$ be a positive integer that exceeds the highest frequency present in the continuous-time signal $f$. Fix a number $K$ that represents the active tones. The model contain each signal of the form
$$ f(t)=\sum_{\omega \in \Omega} a_{\omega} e^{-2\pi i \omega t},\hspace{5mm} for \hspace{2mm} t \in [0,1)$$
Here, $\Omega$ is a set of $K$ integer-valued frequencies that satisfies
$$ \Omega \subset \left \lbrace  0, \pm 1 , \pm 2, \ldots , \pm (W/2-1),W/2\right \rbrace$$
and
$$ \left\lbrace a_{\omega}:\omega \in \Omega\right\rbrace$$
is a set of complex-valued amplitudes. We focus on the case where the number $K$ of active tones is much smaller than the available bandwidth $W$.

Now my questions are:

I think there should be $\pm W/2$ in the set $\Omega$.
Does the signal model consider both the positive and negative value of frequency in a single signal?
What will be the signal $f(t)$ when $\Omega = \left\lbrace 0, \pm1, \pm2\right\rbrace$?

Thanks.


texts: Reconciling Continuous and Discrete Complex Domains

texts:
Having taken some courses in Systems and Stability dealing mostly with continuous time signals, I am accustomed to thinking about the Laplace and Fourier transforms dealing with complex and pure imaginary signals respectively. For example, if I transformed $x(t)$ and evaluated its magnitude and phase at 0.5+0.5j, I would looking at the response of the system having injected it with $\exp(.5t)\exp(j0.5 \pi t)$

Recently, I have been working in the discrete domains of the DTFT (continuous in the transform domain), DFT, and Z. Here, we have complex exponentials mapping to the unit circle. Now I am struggling at a high level to reconcile these continuous and discrete domains. If I look at a DTFT of a discrete time signal and evaluate it for some input $\exp(0.5  j  \hat{\omega} \pi  n)$  where $n$ is some index and $\hat{omega}$ is a relative frequency based on the sampling rate of the continuous time signal, I end up somewhere on the unit circle (not on the imaginary axis) even though the signal is a purely imaginary exponential.

The questions I have are

1.) How does a complex signal (real and imaginary)$ x[n] = \exp(0.5n) \cos(j .5 \pi \hat{\omega}n)$ map into the DTFT/DFT and Z frequency domain? I am guessing somehow real part does not map to DTFT/DFT but does to Z?

2.) Why the concept of a multidimensional space for these discrete frequency signals (DTFT/DFT) when the imaginary axis (Fourier domain) worked fine for continuous signal? Why do we need a unit circle that repeats when we could map the same function to a straight line that repeats every $-\pi$ to $\pi$?


texts: Magnitude response of mirrored (with respect to unit circle) poles and zeros

texts:
I just want to check that my understanding about the following paragraph from Optical Filter Design
and Analysis by Christi K. Madsen, Jian H. Zhao is correct:

A filter’s magnitude response is equal to the modulus of its transfer function,
$|H(z)|$, evaluated at $z = e^{j\omega}$. Based on the pole/zero representation of $H(z)$, only the
distance of each pole and zero from the unit circle, i.e. $|e^{j\omega}-z_m|$ or $|e^{j\omega}-p_n|$, affects the magnitude response. Consequently, a zero that is located at the mirror image
position about the unit circle, i.e. $1/z_m^*$, cannot be differentiated from $z_m$ based on
the magnitude response.

Let us assume a filter with just one zero $c_1=|c_1|e^{j\phi}$ so that its transfer function is:
$$
H(z)=1-c_1 z^{-1}=1-\lvert c_1\rvert e^{j\phi} z^{-1}
$$
Its mirrored zero is $c_2=1/c_1^*=\lvert c_1\rvert^{-1}e^{j\phi}$ and its transfer function is
$$
H_m(z)=1-c_2 z^{-1}=1-\lvert c_1\rvert^{-1}e^{j\phi} z^{-1}
$$
Evaluating the transfer function at $z=e^{j\omega}$ and computing $H(e^{j\omega})H^*(e^{j\omega})$ we get the power response:
$$
\big\lvert H(e^{j\omega)}\big\rvert^2=\big\lvert 1-\lvert c_1\rvert e^{j(\phi-\omega)}\big\rvert^2=1 +\lvert c_1\rvert^2-2\lvert c_1\rvert\cos(\phi-\omega)
$$
and
$$\big\lvert H_m(e^{j\omega})\big\rvert^2=\bigg\lvert 1-\frac{1}{\lvert c_1\rvert}e^{j(\phi-\omega)}\bigg\rvert^2=1 +\frac{1}{\lvert c_1\rvert^2}-2\frac{1}{\lvert c_1\rvert}\cos(\phi-\omega)
$$
$\big\lvert H_m(e^{j\omega})\big\rvert^2$ can also be expressed as:
$$
\big\lvert H_m(e^{j\omega})\big\rvert^2=\frac{1}{\lvert c_1\rvert^2}\Big[1 +\lvert c_1\rvert^2-2\lvert c_1\rvert\cos(\phi-\omega)\Big]=\frac{1}{\lvert c_1\rvert^2}\lvert H(e^{j\omega)}\rvert^2
$$
which is just the power response of the first filter scaled by a factor of $\lvert c_1\rvert^{-2}$. Is this analysis right?


texts: why did convolution coding achieve BER less than Reed-Solomon?

texts:
I tried convolutional coding and Reed-Solomon (RS) (block coding technique) for wireless channel where the input data is bitstream.

Convolutional coding achieved lower BER comparing with RS. If the SNR of channel decrease around 15dB, convolution code's BER becomes more than that of the system without channel coding, where RS achieved a small improvement in the BER.

I wonder if any one has an explaination for what happened ?


texts: Adjustment of window length with sliding/moving RMS method for frequency drifts

texts:
I'm using a sliding RMS mechanism to compute RMS of a signal, i.e. with a window size of N, I add the squared value of the new sample $x[n]$ to the running total while deducting the squared value of the $x[n - N]$ sample and then performing a square root to get the RMS value.

This method works fine when a cycle's worth data in the signal under question lines up exactly with the length of the window. For ex,

Let the window length $N = 512$, frequency of the signal $f=100 \ \mathrm{Hz}$ and sampling frequency $f_s= 51200  \ \mathrm{Hz}$.

With the above settings, every set of 512 samples would have a cycle's worth data of the signal and the computation works fine.

Now, the issue begins when the frequency of the signal deviates from $100  \ \mathrm{Hz}$ giving more or less number of samples in the same 512 samples window which throws off the accuracy of the sliding RMS algorithm.

This happens because the division by 512 to get the RMS, is no longer valid due to the fact that this particular cycle of the signal is getting complete before the end of the 512 samples window. However, the running squared total would already have the contributions from the previous samples which were divided by 512 while the samples of this cycle would require a different window length.

Is there a way to compensate for the addition/lack of samples due to the frequency drifts while using this technique?


texts: Improve contrast when image has a flood of white balancing

texts:
I have an image taken a night time.

I apply _EqualizeHist to it. But the result is a high level of whiteness running through the image.

This is the image:

I had asked this question in a slightly different way and was given a link to improve the white balancing of the image.

This was the original question

This is that link:

enter link description here

I have got as far as this in my code but now I am stuck as to what to do next.  I would be grateful if anyone can suggest the next step?

This is my code:

            Image<Bgr, byte> frame = new Image<Bgr, byte>(file);
            frame._EqualizeHist();
            Image<Hsv, byte> hsv = new Image<Hsv, byte>(file);
            Image<Gray,byte> maskLight= new Image<Gray,byte>(hsv.Width,hsv.Height);
            Image<Gray, byte> maskDark = new Image<Gray, byte>(hsv.Width, hsv.Height);

            Emgu.CV.CvInvoke.cvThreshold(hsv[2], maskLight, 128, 255, THRESH.CV_THRESH_BINARY);
            Emgu.CV.CvInvoke.cvThreshold(hsv[2], maskDark, 0, 127, THRESH.CV_THRESH_BINARY);

            Bgr bgrLightest;
            MCvScalar scalarLightest;
            frame.AvgSdv(out bgrLightest, out scalarLightest, maskLight);

            Bgr bgrDarkest;
            MCvScalar scalarDarkest;
            frame.AvgSdv(out bgrDarkest, out scalarDarkest, maskDark);

UPDATE:
I have tried to implement the suggestion kindly goven by sansuiso.

This is the code:

 Image<Bgr, byte> rgb = new Image<Bgr, byte>(@"D:\789.jpg");
            pictureBox1.Image = rgb.ToBitmap();

            for (int x = 0; x < 360; x = x + 24)
            {
                for (int y = 0; y < 288; y = y + 24)
                {
                    rgb.ROI = new Rectangle(0, 0, 360, 288);
                    int xx = x;
                    int yy = y;
                    if (x > 0)
                    {
                        xx = xx - 12;
                    }
                    if (y > 0)
                    {
                        yy = yy - 12;
                    }
                    rgb.ROI = new Rectangle(xx, yy, 24, 24); //360*288
                    rgb._EqualizeHist();
                }
            }
            rgb.ROI = new Rectangle(0, 0, 360, 288);
            pictureBox2.Image = rgb.ToBitmap();

And this is the resulting image:

Obviously, I am not doing this right.  Can anyone see if my code is wrong please?


texts:
So my question is this:
How to convert sampled real audio signal to it's IQ components for IQ modulation?

For instance:  WHen I have my DSP or FPGA receive a audio signal through a ADC, which is just the RAW A/D value.  Now I want to run this through a DAC to IQ modulator to get let FM modulation.
How would I convert the raw A/D value into IQ?  How do i break this signal down to In-phase and quadrature component? Do I do FM modulation in the DSP/FPGA and get the IQ from that or just split the audio baseband into it's IQ components?

Added:

I'm in the process of converting FSK transmitter from older obsolete design to newer  design.  So as I'm studying IQ, i was wondering what would happen if I  wanted to send a analog sine wave through the IQ modulator, like LTC5599.  How would I convert a analog sine wave to I and Q send it as input to the LTC5599?


texts:
I'm implementing affine transformations on images. Currently I'm doing rotation, but general transformation will be added later.

Basically each pixel is mapped by the rotation matrix R:

$\begin{bmatrix} cos(a) & -sin(a) \\ sin(a)  & cos(a) \end{bmatrix} $

The problem is that mapping back does not always come back to a grid point, so I basically rounding it using a brute force approach. What is a better approach (similarly to Bresenham's line drawing algorithm)?


texts: Where did the length of time’s period disappear in Periodic Fourier Series Discrete Time

texts:
In continuous time Periodic Fourier Series has smallest n as possible, since it is an integral and a length of the repeating time (period time) which is T0. In discrete time however we don’t have units of time at all. Explain in your own words the intuition of avoiding time units in Discrete Time Fourier Series of a signal periodic in time.

Time T0 should be devided by N and the time intervals between N0 N1 and N2 should all be T/N. But, that T0 could be more than 2pi! Could you please explain the 2pi/N? What are the units of 2pi/N? The units of 2pi/T in contniuous time were 1/second. N is an integer, it shall have no units, it shall be the numbers of parts we devide some time T0 by. No? Yes? I'm confused. Could you help? Thanks ahead.


texts: Biquad Filter Transfer Function Frequency Response

texts:
$H(z) = G\cdot\displaystyle\frac{2b_0\left(1-z^{-2}\right)}{1-2a_1z^{-1}-2a_2z^{-2}} + 1$

I have a data sheet with the above transfer function, I need to calculate its frequency response in code. I have the functions to calculate $b_0$, $a_1$, $a_2$ and $G$, but it has been a loooooong time since I have handled $H(z)$ transfer functions and I can't for the life of me remember how to work it out.

I have googled around and it mentions jw this and that and I have tried everything Ive found but I'm not getting a frequency response anything like what is expected.

I have a sampling rate of $48000\textrm{ Hz}$ and want to calculate the frequency response from $0-24000\textrm{ Hz}$ in $1\textrm{ Hz}$ steps.

Any help would be very much appreciated.


texts: Why do we use scaling factors in DCT? Are they important?

texts:
I don't understand the use of scale factors, why do we need them? Can we not use them or are they essential?

The wikipedia page on DCT II shows this:
https://en.wikipedia.org/wiki/Discrete_cosine_transform


texts:
I'm playing with the built in OpenNI access within OpenCV 2.4.0 and I'm trying to measure the distance between two points in the depth map. I've tried this so far:

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>

using namespace cv;
using namespace std;

Point startPt(0,0);
Point endPt(0,0);

void onMouse( int event, int x, int y, int flags, void* )
{
    if( event == CV_EVENT_LBUTTONUP) startPt = Point(x,y);
    if( event == CV_EVENT_RBUTTONUP) endPt   = Point(x,y);
}

int main( int argc, char* argv[] ){
    VideoCapture capture;
    capture.open(CV_CAP_OPENNI);
    //capture.set( CV_CAP_PROP_OPENNI_REGISTRATION , 0);
    unsigned t0=clock();
    if( !capture.isOpened() ){
        cout << "Can not open a capture object." << endl;
        return -1;
    }
    unsigned elapsed=clock()-t0;
    cout << "initialized in "<< elapsed <<" s. ready!" << endl;
    namedWindow( "depth", 1 );
    setMouseCallback( "depth", onMouse, 0 );
    for(;;){
        Mat depthMap;
        if( !capture.grab() ){
            cout << "Can not grab images." << endl;
            return -1;
        }else{
            Mat show,real,valid;
            if( capture.retrieve( depthMap, CV_CAP_OPENNI_DEPTH_MAP ) ){
                depthMap.convertTo( show, CV_8UC1, 0.05f);
            }
            capture.retrieve(valid,CV_CAP_OPENNI_VALID_DEPTH_MASK);
            if( capture.retrieve(real, CV_CAP_OPENNI_POINT_CLOUD_MAP)){
                unsigned int sp = valid.at<unsigned char>(startPt.x, startPt.y);
                unsigned int ep = valid.at<unsigned char>(endPt.x, endPt.y);
                if(sp == 255 && ep == 255){
                    Vec3f s = real.at<Vec3f>(startPt.x, startPt.y);
                    Vec3f e = real.at<Vec3f>(endPt.x, endPt.y);
                    float dx = e[0]-s[0];
                    float dy = e[1]-s[1];
                    float dz = e[2]-s[2];
                    float dist = sqrt(dx*dx + dy*dy + dz*dz);
                    putText(show,format("distance: %f m\n",dist),Point(10,10),FONT_HERSHEY_PLAIN,1,Scalar(255));
                }
            }
            circle(show,startPt,3,Scalar(255),3);
            circle(show,endPt,3,Scalar(192),3);
            line(show,startPt,endPt,Scalar(128));
            imshow("depth",show);
        }
        if( waitKey( 30 ) >= 0 )    break;
    }

}

but I have a few issues:

Unless I check for values in the valid depth mask first the program
crashes sometimes (I imagine due to bad data)
As far as I understand the point cloud map returns XYZ data in meters (CV_32FC3), but the numbers I see on screen look wrong.

Am I retrieving the xyz values and doing the distance calculations correctly ? What am I missing out ?


texts: Could a DCT be used for an audio magnitude spectrum rather than DFT?

texts:
From what I understand, the DCT has half the bin size as a DFT of the same size N.  The DFT also includes phase information, but often this is not needed when only the magnitude spectrum is desired.

Could the DCT be used to provide a magnitude spectrum with twice the density (half the bin spacing) of the DFT or would out of phase information be lost?
How about with a 50% overlap?


texts: Early estimate the sign of the drift in a generalized Wiener process

texts:
I posting here my problem, perhaps somebody can point me how to proceed further :)

[The challenge]

I have an electronic system that can be modeled as a Wiener process with a drift $\mu$:

$ X_t = \mu t +  \sigma W_t $

$E[X_t] = \mu t$ , $Var[X_t] = \sigma \sqrt t$

where the value of the drift $\mu$ is unknown and can be either positive or negative.
The index $t$ can be seen as the time evolving form the initial time $t_0$, where $X_0 = 0$.

In my physical system I can only observe the $X_t$ evolution over time $t$.

My goal is to minimize the amount of time $t_{detection}$, required to estimate the sign of the drift $\mu$, with a given confidence interval $CI$.

[The current (naive) approach]

The system signal-to-noise-ratio is: $SNR(t) = \frac{\mu \sqrt t}{3 \sigma}$
for a CI of $3 \sigma$ = 99.7%

Intuitively, if I wait long enough, I could reach any arbitrary SNR level as the signal power is proportional to $t$, whereas the noise power only to the $\sqrt t$.

However, in my scenario my $t_{detection}$ is constrained, and with the current values I am off by a factor of x100 outside specification with this approach.

[The question]

Is there a way to reduce the $t_{detection}$ time for the same $CI$ confidence interval?

I am not familiar with Kalman filter, but I suspect it may help here?
Or perhaps by looking at the derivate of $X_t$?

[Remarks]

You are talking to an analog designer. Please bear with me... and thank you for any help!


texts: effect of high pass filtering and low pass filtering on background color

texts:
Consider we have an image like this:

After applying a Low Pass Filter (say Butterworth), the result is :

And after applying a High Pass Filter (Butterworth), the result is:

The text book (Gonzalez) explains everything clearly. But I still cannot catch the point why the background in LPF is white(gray) and in HPF is black. according to the book, it is because of convolution that averaging a neighbor pixel to calculate the center pixel. I know how convolution works, sliding a small kernel, but why the result from LP filtering has different background in comparison with HP filtering?
I think for HPF, it is because of High Pass Filtering in frequency domain is analogous to differentiation in the spatial domain? so all constants become zero (black)? what about Low pass filtering?
All pictures are from Gonzalez's Digital Image Processing,3rd Edtion,2008.


texts: What does it mean to plot a PAM signal over a number of symbols?

texts:
Our course has been using the book Introduction to Communication Systems by Upamanyu Madhow for our communications course. There is a question in the book on page 87 Software lab 2.1 which is

Consider a pair of independently modulated signals, $u_c(t) = \sum_{n=1}^{n=N} b_c[n]p(t − n)$ and $u_s(t) = \sum_{n=1}^{n=N} b_s[n]p(t−n)$, where the symbols $b_c[n], b_s[n]$ are chosen with equal probability to be $+1$ and $-1$, and $p(t) = I_{[0,1]}(t)$ is a rectangular pulse. Let N = 100.

Use Matlab to plot a typical realization of $u_c(t)$ and $u_s(t)$ over 10 symbols. Make sure you sample fast enough for the plot to look reasonably “nice.”

I want to ask what is the meaning of plotting $u_c(t)$ and $u_s(t)$ over 10 symbols.

Link for the book - https://www.ece.ucsb.edu/wcsl/Publications/intro_comm_systems_madhow_jan2014b.pdf


texts:
I'm using a complex-valued baseband signal as my input for subband adaptive filtering. Therefore i have a complex input spectrum.

My problem is now, how to split my complex spectrum into $N$ equally spaced subbands?

I know i could use a DFT filter bank with impulse responses of

$$\displaystyle h_i(n) = p(n)e^{(j2\pi i/N)n} ,\quad i = 0,1,\ldots,N-1$$

where $p(n)$ is the impulse response of my lowpass prototype filter.
But what bothers me is that $H_0(z)$ will be real valued and so $|H_0(e^{j\omega})| = |H_0(-e^{j\omega})| $ holds, and hence the complex spectrum isn't split right into $N$ subbands.

Am I missing something there, or is it not possible to use DFT filter banks for complex-valued input signals?
Are EMFBs (exponentially modulated filter bank) a workaround to solve this problem?


texts: Is this HW question even valid? (linear systems)

texts:
The question is:
Are the following systems linear time invariant?

$y(t)=x(t)$, with $x(t)=u(t)$ (unit step function)
$y[n]=x[n]$, with $x[n]=\delta[n]$ (Dirac delta function)

The reason I am asking is because I don't see the relevance of the values given to the input functions. LTI is a property of the system not its inputs, so I don't understand what is meant!

Is it a restriction?
In that case how would I check for linearity? One probably can't, right?


texts:
I am trying to extract amplitude of specific frequency in Matlab FFT. Is it possible to use the abs(mag)... But I do not know in which sample to look for mag(245) should give me amplitude for the frequency of that sample...

How to extract that amplitude-magnitude for $120$ Hz using mag?

I will add simple code:

Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 1000;                     % Length of signal
t = (0:L-1)*T;                % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t));     % Sinusoids plus noise
f=(0:L-1)*Fs/L;
x=fft(y);
mag=abs(x);
mag(1)=0;
plot(f(1:L/2),(2/L*mag(1:L/2)));
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')


texts: Possible RF Mixing for Increasing Frequency of a Pulse Train

texts:
I am planning to build a low-power DC/AC inverter circuit along with MOSFETs and the full-bridge configuration. The MOSFETs are going to be controlled via two 4047s on the both side of the inverter.
According to my needs, the switching frequency should be 382 kHz. However, according to the 4047’s datasheet from Texas Instruments; in order the 4047 to work properly, the maximum output frequency is calculated as nearly 270 kHz and it is way below the targeted switching frequency.
Consequently, I’ve thought about mixing the 270 kHz rectangular pulse train with a local oscillator. According to my Fourier transform calculations, frequency of the output signal of the mixer becomes 382 kHz by using 112 kHz oscillator.
Is this solution is applicable?


texts:
Problem:
In Walter G.Carrara's book on synthetic aperture radar, the equation is presented:
$\Phi(K_X, K_R) = -K_XX_t - R_B\sqrt(K_R^2 - K_X^2) +K_RR_S $  (10.30)

And this is said to come from substituting the value for $X_a$ using the Principle of Stationary Phase:
$X_a = -R_BK_X/\sqrt(K_R^2 - K_X^2) + X_t $ (10.28)

into the phase of the fourier transformed signal:
$\Phi(K_X, K_R) = -K_RR_t - K_XX_a + K_RR_s $ (10.29)

What I have tried:
Substituting 10.28 into 10.29 as mentioned, I got:
$ -K_RR_t + K_X^2R_B/\sqrt(K_R^2 - K_X^2) - K_XX_t + K_RR_s $

The following identities may be useful:

$R_B = \sqrt((Y_a - Y_t)^2 + (Z_a - Z_t)^2)$ is minimum range to scatterer

$R_t = \sqrt((Xa - X_t)^2 + R_B^2) $


texts: Construct a correlation matrix using the covariance method

texts:
I want to compute the autocorrelation matrix by using the covarience method.

X(n) is the harmonic process $X(n) = \sum\limits_{i=1}^3  A_i e^{jn\omega_i} + V(n)$

$V(n)$ is unit variance noise.

$ |A_i| = 2$ for $n = 1,2,3$

The phases of $A_i$ are uncorrelated random variables that are uniformly distributed between $–π$ and $π$.

what I understand:

$R_{x(n)} = E[x_{n}\cdot x_{n}^H]$
I should use a levinson or schur algorithm
I need to compute random samples of the random process ( $randn(100,1$) )
I should use a for loop to compute the sum

What I don't understand:

why is the auto correlation matrix a 7 x 7 matrix?
how do I compute the auto correlation matrix


texts: When I double bit rate I do not see a difference in I_spectrum and Q_spectrum, but why?

texts:
I wanted to compare two different I-Q spectrum plots of a basic transmitter, one in which I doubled the bit rate. I expected a different result, that of possibly a higher/faster graph. It looks sort of the same, but that the doubled bit rate has more noise? I am not understanding the results here.
Bit rate of 1MHz

Bit rate of 2MHz


texts: Is there such thing as harmony independent timbre characteristic of a sound?

texts:
I was wondering if any of you know about any technique to extract a harmony (e.g. harmony in a shape of a chromagram) independent timbre characteristic of a sound frame.

What I'm after is a version of spectrum that will make all the piano notes look almost the same despite the fact they occupy different parts of the actual frequency spectrum.

Googling that didn't give me much yet.

Thanks a lot in advance!

EDIT: Great folks in comments pointed out some ambiguity in my question. I'm interested in a metric that is independent of the notes themselves, but captures the whole set of timbral characteristics that could help describe the instrument independently of the note content. It could be a psychoacoustical metric. I'm really curious if anyone knows anything that could fit this task. Thanks a lot!


texts: Finite length truncated exponential sequence $\mathcal Z$-transform, zeros over circle explanation

texts:
I'm looking at an example on how to obtain the $\mathcal Z$-transform from a finite length truncated exponential sequence, namely:
$$x[n] =
\begin{cases}
a^N &\text{for} & 0 \leq n \leq N-1\\[2ex]
 0 & \text{otherwise}
\end{cases}
$$

The $\mathcal Z$-transform from that sequence is:
$$
\frac {1}{z^{N-1}} \cdot \frac {z^{N} - a^N}{z - a}
$$

It can be seen that there are $N-1$ poles at the origin and $N-1$ zeros at $z = a$ (because the pole in $z=a$ is cancelled by a zero). My doubt is on the location of the zeros over the $z$-plane.

I know that the $N-1$ zeros at $z = a$ can be expressed as:

$z = a\cdot1\ \text{and}\ 1 = e^{j2\pi k}$ so:
$$
z_k = ae^{j2\pi k}\quad\text{with}\quad k = 1,2,\ldots,N-1
$$
Yet in the example I'm looking at, they say that the zeros are located at
$$z_k = ae^{j\frac{2\pi k}{N}}\quad\text{with}\quad k = 1,2, \ldots, N-1$$
So they are spaced at $\frac{2\pi}{N}$ instead of being all at the same place and I don't understand where that $N$ came from.


texts: Method to remove small unwanted region and fill holes for specific image

texts: I have a binary image that maintains some unwanted region (small white dot) and hole regions (in figure 1). My idea is that to fill the object after I will remove the unwanted region but I don't now exactly wich method can help me


texts: Log vs. linear frequency scales of Fourier and wavelet transforms

texts:
I'm trying to understand the difference between the output of a Fourier transform and a wavelet transform. A Fourier transform is done via the following function:

$$\hat{f}(\xi) = \int^\infty_{-\infty}\ f(t)\ e^{-2\pi i t \xi}\ dt$$

Whereas a wavelet transform is going to use this:

$$F(a,b) = \int^\infty_{-\infty}\  f(x)\psi^*_{a,b}(x)\ dx$$

Now, spectrograms use a windowed Fourier transform. When looking at a signal over time, you can get a graph showing you which frequencies were present at any given time. The frequencies are scaled linearly. However, scalograms use a wavelet transform to obtain the same information. I've frequently seen the output scaled logarithmically (in frequency).

Is there something about wavelets that make their output fundamentally logarithmic? I'm having a hard time seeing it in the above formulas. It seems like you set $\xi$ or $a$ & $b$ give you the frequency you want, and you could calculate results for any frequency you desire.


texts:
When performing a conventional digital beamforming I see in some textbooks they show beam patterns as

where the arrival angle ranges between -90 to 90 degrees. But then other places show the full 360 degree view sometimes in a polar plot like this

My question is, when doing a simulation is it ever warranted to ignore signals with angles of arrival greater than 90 degrees? For example, if my signal of interest has an angle of arrival of 30 degrees and an interference signal is at -80 degrees (difference between these is |-80 - 30| = 110 degrees), is it really like the first figure where the gain plot only exists between -90 to 90 degrees?

EDIT: My simulation setup.


texts:
I was reading section 4.3.3 from chapter 4 of "A Wavelet Tour of Signal Processing",

"...Let $\bar{f}(t)$ be a continuous time signal defined over $[0,1]$. Let $f[n]$ be the discrete signal obtained by a low-pass filtering of $\bar{f}$ and uniform sampling at intervals $N^{-1}$.

Its discrete wavelet transform can only be calculated at scales $N^{-1}<s<1$,..."

Why is this so? I don't understand


texts: How to calculate mean and Variance of Gaussian-distributed random noise?

texts:
I have been given a Gaussian-distributed random noise n(t) which has an average power of 5 mW.
How can I calculate the mean and variance of noise n(t)? Any suggestions? Thanks!