texts: Can we do image classification using bag of features and classifier other than SVM

texts:
I developed code for image classification using SURF features , bag of features as instructed in https://www.mathworks.com/help/vision/ug/image-category-classification-using-bag-of-features.html but here it uses only SVM classifier. How can I do same classification with this bag of features using other classifiers.
Please support.
Thank You


texts: How to filter a regular ticking out of a digital (on/off) signal?

texts:
I have a digital on/off signal sampled at a regular interval.  There was a problem with the sensor that produced the signal which has sometimes caused a regular on/off ticking when the sensor should be in the off state.  I.e. sometimes when the readings should be zero, there is a square wave instead (but with an unequal mark:space).

How would I go about designing a filter to remove this square wave (i.e. output a zero if there is this regular ticking occurring, output the input value otherwise)?

The ticking has a frequency of around 16 minutes, the events that the sensor was observing might last anything from one minute to a few hours.  I expect that this means that perfect recovery of the correct data is impossible, but I’d like to get as close as possible.

I would think some kind of notch filter is what I need, but everything I’ve found so far seems to be about filtering analogue signals.

(My memory of signal processing courses is a bit patchy, hopefully I’ve used the right terms here).

EDIT:

Thanks for your comments so far.  I've attached an image illustrating what I am trying to achieve.  Also I wrote the wrong frequency for the regular ticking - it's actually 16 minutes, not 8, but I doubt that affects the overall approach.

@Jan - yes, ideally I would just have a better sensor, but this is the data I have for now, I don't currently have the option of switching to a different sensor.

EDIT 2:

The data processing is happening offline, so non causal solutions are fine.


texts:
I wonder how I can convert dBA (A weighted) to dB and vice versa.
can anybody provide any kind of table or online conversion app?
thanks
following formula comes from https://en.wikipedia.org/wiki/A-weighting
:\begin{align}
  R_A(f) &= {12194^2 f^4 \over \left(f^2 + 20.6^2\right)\ \sqrt{\left(f^2 + 107.7^2\right)\left(f^2 + 737.9^2\right)}\ \left(f^2 + 12194^2\right)}\ ,\\[3pt]
    A(f) &= 20\log_{10}\left(R_A(f)\right) - 20\log_{10}\left(R_A(1000)\right) \\
         &\approx 20\log_{10}\left(R_A(f)\right) + 2.00
\end{align}
how can I inverse this formula?
I also must mention that I have a specific frequency and I just want to convert this specific frequency SPL


texts:
I've been playing around with making images better and removing all the unwanted disturbances from it. I found out a major concern would be removing the unwanted reflections that might come.

I've gone through a paper that uses ICA to get rid of these reflections. What other methods would work?

Say I have an image:

Another image:

Converted it into CMYK

How should i remove this semi black portion?


texts: Sparsity Representation of a Signal Using the DCT Matrix

texts: I have a signal $\mathbf x$, and I need to know how to obtain the matrix which is the corresponding sparsity basis $\mathbf\Psi$ such that $\mathbf x = \mathbf{\Psi\theta}$, where $\mathbf\theta$ is sparse. I know that the suitable basis for my signal is the DCT basis. Given the signal, how can I obtain its DCT basis using MATLAB?


texts: Digital Audio Mixing Fundamental. What will be the data rate of mixed audio?

texts: I have voice data at 128 kbps coming from three different sources. I'm looking for mixing all three voices together and sending it back to speakers. What methodologies are there for mixing digital audio bit streams and what will be the mixed voice data rate? will it be 128*3 or just 128 only?


texts:
Suppose I have a wave with $20 \textrm{ kHz}$, $100 \textrm{ kHz}$ and $300 \textrm{ kHz}$. Sampling frequency used is $1000 \textrm{ kHz}$. I apply the discrete wavelet transform on the wave like dwt(wave,'db2'). I will get one level of approximation and detail coefficients. According to the basics, the detail coefficient will have  $300\rm k$ component and approximation coefficient will have the $100\rm k$ and $20\rm k$ components

But when I did fft on the output(on approximation and detail), I didn't get what I expected.

Could anyone post some MATLAB code with which I can verify it?
And also tell whether I am doing the procedure correctly?
Also if anyone could explain the practical side of this tool?


texts: Signal deconvolution from exponential and linear tail

texts:
I would like to deconvolve the signal shown in the plot below from its linearly decaying tail and the exponential levelling. That means that after the deconvolutin, the tail should be at a constant value of ~410 mV. Does anyone have an idea how to approach this problem?
I uploaded the data here:
https://nextcloud.mpp.mpg.de/nextcloud/index.php/s/RwXEzEa6bxHTByR

Thank you very much in advance!


texts: confusion about poles and zeros of Lead compensator?

texts:
I was reading about lead compensator from a website but i am not able to understand how they have extracted zero and pole from transfer function of lead compensator as shown in attached photo?

or they have extracted/calculated wrong values of zeros and poles?


texts: Creating derivative images, based on original, that can only be visually understood when stacked

texts:
I've been thinking about this for a while. What I have been trying to accomplish is a way of taking an image (png specifically, or any other format that allows transparency) and generating N derivative images. Each derivative image would, theoretically, be as difficult as possible to visually connect to the original. If I processed an image of a mountain into three images, none of the three images should suggest to you that it is a mountain. However, if all three images were stacked on top of each other, what you should see, with as minimal corruption or loss of detail as possible, is the original image.

Different approaches I've considered are splitting an image by color, and stacking the different colors. This works okay when N is a large number. It works poorly when N is small. Quantization helps, but can be tremendously lossy at small Ns, where it would help most.

Replacing (N-1)/N pixels with noise or transparency in each layer works well at higher levels of N, but a bit poorly at N=2 or 3 because the top layer reveals the subject of the image.

It seems that dealing with the top-most image is where things become really difficult. I'm not really sure how to approach this.


texts: Maximising each element in a matlab array

texts: Is it possible to construct an array A, without looping, where A(i,j) = max(B(i),C(j)) and B and C are column vectors?


texts:
I study condition for fix if filter is a linear phase,but it's not clear in my mind!

I have this $h(n)$:
$$h(n) = \begin{cases} \left(\frac{1}{2}\right)^{n} & 0<n<N-1 \\[2ex] 0 & \text{elsewhere} \end{cases}$$
I got the $H(z)$:
$$
H(z) = \frac {\left(\frac{1}{2}\right)^{N}{z}^{-N}-1}{\frac{1}{2}{z}^{-1}-1}
$$
Now, for the phase linear what I do ? I think to verify palindrome property for this $h(n)$, but how ?? or I can finally say that to the form that has definitely not linear ?


texts: How to manipulate attenuation in Parks MClellan algorithm?

texts:
I am using GNU Radio C++ source code in my app (pm_remez()) for generating FIR filters coefficients.
Input parameters here are: bands[], des[] and weight[].
How I can manipulate stop band attenuation in pm_remez() function?


texts: How to check the FFT results of a sine wave?

texts:
I have been given an audio file (sine wave) 1000Hz as an input to my FFT algorithm.
I have got 8192 power spectrum samples in a array.

What is the best and easiest way to check whether my output is right or wrong?

If I give a silent audio file then the output is zero for all samples.
In a sine wav the o/p increases from 20 (0th sample) to 26059811 (743rd sample) and decreases gradually to 40.

If I get an idea of the output range then I can prove technically whether the FFT is working.

Any ideas would be helpful.

Refer to this link for any technical doubts.


texts: Will signal get distorted if channel bandwidth is lesser than the signal bandwidth?

texts:
This statement is given in the book "digital communicatinon by Taub schilling "

Now one point I am unable to understand that if the channel bandwidth is lesser than the signal bandwidth,how it is possible that the signal will not get distorted? can someone explain this to me in simple word Please?


texts: How to take acoustic measurements of a clasroom

texts:
I'm an electrical engineering major and I have a question regarding a project I'm working on.

I'm supposed to design 3 band-stop filters on MATLAB for echo cancellation/suppression.

My problem is not filter designing, but with taking acoustic measurements of a classroom since I have little or no information in that area.

The supervisor suggested taking coefficients using impulse response invariant! I could not find something solid or a method while searching online.

  So my question is, what is the simplest way of taking acoustic
  measurements of a normal size room/classroom? How to find the
  coefficients through impulse response invariant method?

All suggestions are appreciated, current tools I have (dynamic mic, speakers, audio interface (Focusrite Scarlet 2i2), RoomEQ wizard, MATLAB/Simulink, FPGA DE2 board with cyclone)

I tried using RoomEQ wizard and followed their tutorial but did not work properly or maybe I`m not getting the whole picture.


texts: How do I use the step and ramp functions to create a specific signal?

texts:
I am trying to figure out how to use the step $u(t)$ and ramp $r(t)$ functions to create the function $f(t)$ below:

$f(x) = \begin{cases}0 & \text{for } t < 0 \\ t & \text{for }-1 \lt t \lt 1 \\ 2 & \text{for }t \gt 1 \end{cases}$

The step function $u(t)$ is defined to be 1 when $t \gt 0$ and $0$ otherwise.

The ramp function $r(t)$ is defined to $t$ for $t \gt 0$ and $0$ otherwise.

So here is my thought process:

$f(t)$ has a line with a slope of 1 from [-1,1]. This looks just like the r(t) function shifted to the left by one. Hence, r(t+1). However, the problem arises after $t = 1$.  $r(t+1)$ continues on with a slope of 1 infinitely, but the graph below flattens out at $t=1$. Somehow, I need to cancel out the slope of 1 by adding with a slope of -1. The only way I can get a slope of -1 is by negating $r(t)$ and shifting it to the right by 1.

This yields $r(t+1) - r(t-1)$. This will cancel out the positive slope 1 for t > 1, but this creates a problem on left side because the slope of -1 continues on to negative infinity.

I feel like I'm over thinking this problem.

I would appreciate it if somebody could explain this problem in the simplest possible way.

Also, somebody told me there is an easy way to solve problems like this by looking at where the discontinuities are and where the slopes change.  The discontinuities imply using an amplitude with u(t) and slopes imply using amplitude with $r(t)$.

Would appreciate all / any advise.

Thanks.


texts: Equation of wave in Linear frequency modulation?

texts:
We know that we have the following equation for wave.
$$g(t)=A\cos(\omega t+\theta_0)=A\cos(2\pi ft+\theta_0)$$
The equation of frequency with respect to time will be:

$$f(t)=\frac{Bt}{\tau}+f_c-\frac{B}{2}$$
Then:

\begin{align}
g(t)&=A\cos(2\pi (\frac{Bt}{\tau}+f_c-\frac{B}{2})t+\theta_0)\\
&=A\cos(2\pi(f_c-B/2)t+\mathbf{2\pi}(B/\tau)t^2+\theta_0)
\end{align}

Then why that bold 2 is omitted in this answer?
$$f(t)=A\cos(\theta(t))=A\cos(2\pi(f_c-B/2)t+\pi(B/\tau)t^2+\theta_0)$$


texts: I am studying the effect of time offset in OFDM system, I am interested in calculating the power of the ICI on each subcarrier, I am a bit confused about how to do it in Matlab, so how can I measure the power of ICI on a specific subcarrier in Matlab?


texts: How to detect all the connected neighboring pixels which have same color value in opencv

texts: I should be able to input a pixel position and get all the same coloured(in my case it should be black) pixels which are connected to it. How to do this in opencv with c++. Simply the output pixels should be connected to each other with color black. FindContours() method does not work as it cannot be feeded with a pixel.


texts: How well can discrete wavelet packet transform reduce noises that are similar to the input signal in the same frequency band?

texts:
If I had 50Hz noise coming from power line, and signals in the same frequency range (EEG for example 0.1Hz to 100Hz). If my sampling frequency is 30kHz but I downsample my signal to 937kHz and use the discrete wavelet packet transform (with Daubechies wavelet) for denoising purposes.
My frequency content now is 0-937kHz in level 0 and divided to the power of 2 with respect to the level (as in the binary tree).

I have two questions:

If my 50 Hz noise is high in amplitude comparison to my signal of interest, looking at node of "43.94Hz-59.59Hz" frequency band at level 6, If I perform thresholdolding the noise would still be present in the signal as it would have high amplitude, correct? While to remove it completely I would need to zero out all coefficients in that band.
If my 50Hz is smaller in amplitude than my signal of interest, performing thresholding could theoretically remove the noise while keeping my signal of interest, correct? (theoretically because it depends on the threshold level and method)

Please correct me if I am wrong along the process. I am still trying to understand the benefits and drawbacks of wavelets.


texts: Can i increase the SNR of the signal by increasing the processing gain by correlation?

texts: If I am having a 13 bit pattern and sending it at IF frequency on the transmit side. On the receive side after IF conversion I am sending it to ADC. After digitizing the signal and removing the IF by filtering I am passing through a correlator. So if the pattern is 13 bits does SNR increase by $10\text{log}_{10}(13)$ dB? The more the length of the pattern the better the SNR?


texts: difference between conventional analog butterworth filter and that implemented through IIR

texts: I am confused what is difference between conventional analog butterworth filter and that implemented through digital technique using IIR


texts: Is the following system LTI (finite speed of signal propagation)?

texts:
I wonder if the following acoustic system is i) considered to be linear time-invariant, and ii) if it is fully described by it's frequency response?

A speaker produces waves at the input location of a duct system with a branch and the output is measured after the branch point. The anechoic terminations completely absorb the sound waves, and it is assumed that only 1D low frequency waves exist.

So the system, when subject to the input
$$ x(t) = e^{j \omega t}, \quad t \ge 0 $$

experiences the output
$$ y(t) = \left\{
  \begin{array}{l l}
    0 & \quad 0 \le t < t_0 \\
    A e^{j \omega t} & \quad \text{$t_0 \le t<t_1$}\\
    A e^{j \omega t} + B e^{j \omega t}& \quad \text{$t \ge t_1$}
  \end{array} \right., $$

where A and B are complex constants depending on the duct geometry, and $t_1$is the delay time due to the side branch geometry.

Yes the system itself is not changing with time, however due to the finite speed of sound there is a transient period before the reflection from a side branch has occurred.

The frequency response at $\omega$ (a complex number capturing only magnitude and phase relationship between input and output) would be related to the final part of the piecewise defined output (steady state part) and offer no information about the time $t_1$. So, for example, a second system which had a longer side branch may have the same frequency response yet a different value of $t_1$. Therefore my argument would be that the FR is inadequate to characterise the transient behaviour of the system. Is this correct?


texts: Getting the $\mathcal Z$-transform of the moving average summation

texts:
I'm getting started with signal processing, and I'm stuck on a problem that asks me to take the $\mathcal Z$-transform of the following causal, DT-LTI system:
$$\sum_{k=0}^M b_k  x[n-k] $$

I'm not really sure how to take the $\mathcal Z$-transform with the summation in there. Can anyone point me in the right direction?


texts: Procedural wave generation, frequency shift issue

texts:
sorry for the long post but I want to try and get all the details in here in hopes it will help.

I've been working on building a procedural audio system for use in XNA projects. First this is general structure of the procedural system.

WaveFragments: generate the actual wave forms for a specified duration, based on frequency using a phase accumulator.

Waves: complete wave forms, generated by joining wave fragments together.

DynamicWaves: use a wave fragment to generate small buffers of waveform data, which are pushed into a DynamicSoundEffectInstance to be played.

My problem is (I think) with my wave generation. At first it seems to work OK, but then after a certain time the sounds frequency alters slightly, and then back again later.
for example a tone of C3 (130.81f) will increase frequency slightly (but noticeably) at around 20 seconds and then back again later on at 77 seconds. (I've not yet had the patience to see if it shifts again later, I've gone as far as 3 minutes without it shifting up again.

I'm going to assume its a issue with the way I'm generating the wave data with my phase accumulator.

Here is my generation of the PhaseDelta based on provided frequency.

 _PhaseDelta = (float)((Math.PI * 2 * _Frequency) / (float)samplesPerSecond);

and here is the calculation I use for the generation of the wave.

for (int i = 0; i < numSamples; i++)
{
     _PhaseAccumulator = MathHelper.Lerp(_PhaseAccumulator, _PhaseAccumulator+_PhaseDelta, _PhaseSmoothness);
     data[i] = (float)Math.Sin(_PhaseAccumulator) * _Amplitude;
}

Thanks in advance for any input that anyone might have. It may be the most glaringly obvious fix, but at this point after hours of dull single tones my brain is two melted to be getting anywhere with fixing this now.

Now I've tried it without lerping the accumulator (obviously produces the clicks at the start) but still produces the shift. I've also tried lerping the phase delta gradually to its new value, again to no avail.
 (EDIT: i have also tried throwing lerp out of the window and just adding the phase delta each sample, again no dice).

So, my question is, any ideas on why this weird pitch shift is happening? In practicality it isn't a huge issue, the system was only ever intended for short notes to be stacked together for old video game style music, or a tone that would likely change frequency often. But I'd feel more comfortable knowing that the wave generation is accurate and wasn't accumulating some error somewhere sending it way of track.


texts: Does accurate translation estimation using a camera matrix mean the orientation estimation will also be accurate?

texts:
Pose Estimation of single camera and planar pattern:

If I have an appropriate camera matrix with intrinsic parameters that allows me to calculate translation of the camera relative to a chessboard, for example, and it does so very accurately, does that mean my rotation calculations will also be accurate?

This may also be considered in the context of the camera calibration documentation for opencv.

References to your answers would also be appreciated.

EDIT:
thanks to @tbirdal for the links
"Pose and position" is an incorrect phrase. Pose is a combination of position and orientation.


texts:
I suspect I have a very basic misconception so I'm trying to clarify that here:

A signal should be filtered before it is sampled, correct? That is, I always sample an analogue signal at some sampling frequency after it has already been filtered.

However, MATLAB's butter function acts on sampled data. See the example code here:

[b,a] = butter(6,0.6);
dataIn = randn(1000,1);
dataOut = filter(b,a,dataIn);

But once you've sampled, the aliases are mixed up with the original signal so isn't this a very problematic way of doing things?


texts: time scaling and shifting of cosine in Fourier transform

texts:
I've met some problems when calculating the Fourier transform of $\cos(at+b)$. I want to use the shifting and scaling properties to solve this problem. First, when I look up in the book and some online resources, I saw a post about the Fourier transform of the signal $x(3t-6)$, where it tells me that $x(3t-6)$ is scaling $x(t)$ by $3$ and shift it by $2$, which I will get the answer that
$$F\{x(3t-6)\} = \frac13 X(j\omega/3)exp(-j2\omega)$$
This indicates that the Fourier transform of $x(at+b)$ is $$\frac{1}{|a|}X(j\omega/a)\cdot \exp(j\omega b/a)$$

Thus, I apply the conclusion to the Fourier transform of $cos(at+b)$ is

$$\frac{1}{|a|}\exp(j\omega b/a)\,\pi\, [\delta(\omega/a−1)+\delta(\omega/a+1)]$$

How do I proceed to the right answer which is

$$\pi [\exp(jb)\delta(\omega-b)+\exp(-jb)\delta(\omega+b)]$$ ? I appreciate your help.

(I'm new here so I haven't figure out how to type the fractions or exponentials, sorry for the bad typing)


texts: Loss of precision due to low-pass filtering in physical units

texts: Suppose I have a $10{\times}10$ pixel image, where each pixel represents 1 mm in physical units, and I apply a Gaussian low-pass filter with $\sigma = 5$. Can I make any statements such as "the maximum level of precision in the original image was 1 mm, while it is $x$ mm in the filtered image."


texts: How to determine the symbol rate of a 2-FSK signal?

texts:
Let's say that I have a 2-FSK signal recorded so that the SNR is around 20 dB and the noise seems to be more or less white. The distance between tones is greater than the minimum distance needed for non-coherent reception.

How would I go about determining its symbol rate?

I had some ideas, but it was a while since I actually had contact with FSK, so I'm probably forgetting something very obvious.

My initial idea was, since I have a recording, to use say spectrogram in Matlab and see how long each of the tones last. The downside here is that I need to be reasonably lucky with my data. I couldn't set up spectrogram parameters properly, so that end of each symbol is clearly visible on the time-frequency plots.

My next idea was to see if using analytical signal and getting the envelope would help. I don't think I obtained anything useful with that.

Later on, I tried to generate a signal of the same frequency as one of the symbols and then run a cross-correlation. I sort of expected the xcorr to be high when we're on the symbol of the same frequency as the one I'm using and not so high when we're not. What I got as the output is a sinusoid, but I couldn't figure out how to interpret it.


texts:
I have a set of IQ data. From those data I'm trying to get the amplitudes and the frequencies of my signal as I then want to plot them vs. time.

I am able to obtain the amplitudes by squaring both my I and Q values, summing them up and taking the square root of the sum; however, I am struggling to obtain the frequency.

I understand that I need to take a FFT to get from the time domain to the frequency domain but I'm not sure on what values I should apply the FFT. Should I do it individually on Is and j*Qs and then sum them up. Should I do it on the sum Is + j*Qs (which just gave me a new array of complex numbers of the form x + j*y). What role my center frequency / sampling frequency are going to play into that?

For context: I'm doing this using Python. (And I'm obviously pretty new to all of this.)


texts: Why am I not getting the intended coefficients in this 2D Fourier demonstration?

texts:
I am trying to demonstrate how the 2D Fourier decomposition of an image works with Matlab and a very, very simple example.

I create a 4 x 4 pixel image with cosine basis vectors as such:

%Basis vectors with coefficients:

f = @(x, y,a0,a1,a2,a3,b0,b1,b2,b3,c0,c1,c2,c3,d0,d1,d2,d3)...
a0*cos(0*x + 0*y) + a1*cos(0*x + 1*y) +...
a2*cos(0*x + 2*y) + a3*cos(0*x + 3*y) + ...
b0*cos(1*x + 0*y) + b1*cos(1*x + 1*y) + ...
b2*cos(1*x + 2*y) + b3*cos(1*x + 3*y) + ...
c0*cos(2*x + 1*y) + c1*cos(2*x + 1*y) + ...
c2*cos(2*x + 2*y) + c3*cos(2*x + 3*y) + ...
d0*cos(3*x + 1*y) + d1*cos(3*x + 1*y) + ...
d2*cos(3*x + 2*y) + d3*cos(3*x + 3*y)

%Matrix of image space:
[X,Y] = meshgrid(0:3);

%Creating the image from Fourier space by assigning coefficients:

F = f(X,Y,1,1,-1,1,1,1,1,6,3,1,1,1,7,1,1,1);
Fourier = fft2(F);

F =
 27 -5.53409 3.93452 -10.2602
 -0.177994 -12.1365 8.43196 1.46219
 3.50819 6.86722 2.91194 -3.6156
 -18.1397 2.3525 -6.23362 5.35198

Fourier =

 (5.72275,0) (3.14567,1.38924) (36.7478,0) (3.14567,-1.38924)
 (5.46847,-14.2485) (33.0684,2.46052) (43.5603,-51.0061) (11.87,-9.05285)
 (43.9012,0) (44.1778,-31.8071) (63.0469,0) (44.1778,31.8071)
 (5.46847,14.2485) (11.87,9.05285) (43.5603,51.0061) (33.0684,-2.46052)

The image is:

Now I naively want to get back the coefficients with Fourier = fft2(F), but it is not happening - to begin with, there are imaginary components, which I presume are part of a phase shift I did not introduce (I only used cosines in the creation of the original image).

What are my mistakes and misconceptions undermining this demonstration?

I see that the basis vectors can actually be expressed as complex numbers, e.g.

$$\cos(3x + 1x) = \frac 1 2 e^{-3 i x - i y} + \frac 1 2 e^{3 i x + i y}.$$

Yet, predictably, expressing the function with complex terms does not change much - below is the function expressed with complex terms for access:

f = @(x, y,a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4)...
a1*(1/2*exp(-0*i*x-0*i*y) + 1/2*exp(0*i*x+0*i*y)) + a2*(1/2*exp(-0*i*x-1*i*y) + 1/2*exp(0*i*x+1*i*y)) +...
a3*(1/2*exp(-0*i*x-2*i*y) + 1/2*exp(0*i*x+2*i*y)) + a4*(1/2*exp(-0*i*x-3*i*y) + 1/2*exp(0*i*x+3*i*y)) + ...
b1*(1/2*exp(-1*i*x-0*i*y) + 1/2*exp(1*i*x+0*i*y)) + b2*(1/2*exp(-1*i*x-1*i*y) + 1/2*exp(1*i*x+1*i*y)) + ...
b3*(1/2*exp(-1*i*x-2*i*y) + 1/2*exp(1*i*x+2*i*y)) + b4*(1/2*exp(-1*i*x-3*i*y) + 1/2*exp(1*i*x+3*i*y)) + ...
c1*(1/2*exp(-2*i*x-0*i*y) + 1/2*exp(2*i*x+0*i*y)) + c2*(1/2*exp(-2*i*x-1*i*y) + 1/2*exp(2*i*x+1*i*y)) + ...
c3*(1/2*exp(-2*i*x-2*i*y) + 1/2*exp(2*i*x+2*i*y)) + c4*(1/2*exp(-2*i*x-3*i*y) + 1/2*exp(2*i*x+3*i*y)) + ...
d1*(1/2*exp(-3*i*x-0*i*y) + 1/2*exp(3*i*x+0*i*y)) + d2*(1/2*exp(-3*i*x-1*i*y) + 1/2*exp(3*i*x+1*i*y)) + ...
d3*(1/2*exp(-3*i*x-2*i*y) + 1/2*exp(3*i*x+2*i*y)) + d4*(1/2*exp(-3*i*x-3*i*y) + 1/2*exp(3*i*x+3*i*y))

If I run imshow(ifft2(Fourier)) I do get the original image with the initiall 4 x 4 setup.

So I assume I am on the right track, but I can't match the coefficients in the 2D DFT.

I have been able to do it for the DC component:

g = @(x, y, a1)...
dot(F(:), (a0* cos(0*x + 0*y))(:))
g(X,Y,1)
% ans = 5.72275

Which performs the Frobenius product of the image matrix multiplied by the matrix of the DC component:

$$a_0 \cos(x + y).$$

The result is 5.72275.

But I haven't been able to do the same with, say, the coefficient for

$$b_3\cos(x +3y)$$

with

q = @(x, y, b3)...
dot(F(:), (b3* cos(1*x + 3*y))(:))
q(X,Y,6)
% ans = 449.363

which yields 449.363, while there are no coefficients greater than 80 in the Fourier matrix Fourier. Evidently I am messing up treating the complex values correctly...


texts: What do you mean by noise vairance and mean in an image?

texts:
I know the sudden variation in the intensity level of an image is termed as noise. But I couldn't understand what do mean and variance of noise in an image refer to? What is the role of noise variance? As far as I have observed till now, most of the noise reduction algorithm's results vary depending on noise variance. Can someone help me in understanding the concept of noise mean and variance?

As I am very new to image processing, it would be better if someone could give a more elementary explanation. Thank you in advance!


texts:
Is there a verb for removing the mean or DC component of a signal? I am trying to name a flag for doing just that.

"Normalize" can mean many things, so I don't think that would be a good choice.


texts: Compressive Sensing with Square Measurement Matrix

texts: If my measurement matrix have same number of row and column and the unknown vector is sparse can I still use Compressive Sensing to get better reconstruction with fewer measurement?


texts: Instantaneous power estimation by discrete hilbert transform - how far does it smooth?

texts:
In my research area, instantaneous power in a specific frequency band is commonly estimated by the following procedure:

Apply a bandpass filter on the raw signal (e.g. 80-90Hz bandpass).
Estimate the analytical signal by DFT (in Matlab: hilbert())
Take the absolute of the result.

I'm wondering how far this procedure smooths. In other words, if I perturb x(t) and then recalculate the instantaneous power, what is the most distant point that will be affected? I understand that the answer will depend on the particular bandpass filter applied. Is there an easy way to approach this?


texts: CDMA : Calculating M from m1 * w1, m2*w2, etc M as Walsh Code, M as Orthogonal COde


texts: Does anyone know a complete reference or book on matrix completion?


texts: Is there such a thing as band-limited non-linear distortion?

texts:
So if you generate a square wave by just switching a signal between two values, at sample boundaries, it produces an infinite series of harmonics, which alias and produce tones below your fundamental, which is very audible.  The solution is Band-Limited Synthesis, either using additive synthesis or band-limited steps to produce waveforms that are the same as if you had band-limited the ideal mathematical square wave before sampling it:

http://flic.kr/p/83JMjT

But I just realized that if you apply large amplification to a digital sine wave and then clip it digitally, it will produce the same square wave shape, without the Gibbs phenomenon ripples.  So it's then also producing aliased distortion products, right?  So any non-linear distortion in the digital domain that produces harmonics outside of the Nyquist limits will produce aliased distortion products?  (Edit: I've done some tests and confirmed that this part is true.)

Is there such a thing as band-limited distortion, to simulate (in the digital domain) the effects of distorting (in the analog domain) before band-limiting and sampling?  If so, how do you do it?  If I search for "bandlimited distortion" I find some references to Chebyshev polynomials, but I don't know how to use them or if they only work for sine waves or what:

  This instrument does not attempt to generate band-limited distortion. Those interested in band-limited distortion should investigate the use of Chebyshev polynomials to generate the effect. Hyperbolic Tangent Distortion

  "Chebyshev polynomial" -- shaping functions with the important property that they are intrinsically band-limited i.e. they do not introduce spurious spectral harmonics due to overlapping etc. Wave Shaper


texts: Is there a name for the result of summing the bins of an FFT?

texts:
Is there a name for the result of summing the bins of a DFT?

I don't mean to sum the squares of the bins, but to simply add the magnitude of the frequency bins together to get a single result.

Is there a special name that describes how this result would relate to the signal in the time-domain?

The best I can think of would be the total power across the DFT bandwidth, but I believe that is calculated by taking the root of the sum of the squares of the bins, per Parseval's theorem.


texts: How do I correctly receive a signal using a signal analyzer?

texts:
For the past few weeks, I have been trying to send a Zaddof Chu signal using a vector signal generator, and receive it using a signal analyzer. Both devices are made by R&S.

However, the signal I receive is extremely distorted even at very high SNR's. I would really appreciate any hints at where the issue could be originating from.

Here is a the I and Q signals of the 21 samples ZC sequence, upsampled by 8 transmitted at $10\textrm{ kHz}$ base bandwidth and $2.4\textrm{ GHz}$ carrier frequency.

I signal:

Q signal:

And here is the received signal sampled at $1.6\textrm{ MHz}$.

Received I signal:

Received Q signal:

EDIT:

After using the same clock for both devices, and using a coaxial cable to connect them both, I was able to receive an almost perfect real part, but the imaginary part is very distorted.


texts: assume that I have a set of image and segmented image of a object in image (training set). Now, I want to measure features of object in image based on the training data. But I don't know how many features in image. And which is best feature for image segmentation? Gradient feature or entropy feature or ....Could you explain help me ?


texts:
I have a dataset of audios(namely TIDIGITS, collected at Texas Instruments, Inc.) and they are in .wav format. However, when I try to read them from python, I get the following error:
Error: file does not start with RIFF id

Error is thrown from the following line:
import wave
...
f = wave.open(/path/to/audio/example.wav, "rb")

I searched on the Internet, and it looks like the problem is that "wave" library does not support NIST formats and the audio are in the NIST SPHERE format, according to the dabaset's website:
https://catalog.ldc.upenn.edu/ldc93s10
So I transformed them into .wav using "sox" program:
find . -name '*.wav' | xargs -I@ bash -c "sox @ @"

The command reads though all of my ".wav" files and then applies
sox name.wav name.wav

to transform them to RIFF format.
However, now when I play the files in my media player, I get no sound.
The waveform of the audio becomes as follows:

Where it should be something like this:

I think the problem lies at the sox command.
Can anyone help me to convert all of my data to a RIFF format, so that I could read them from the "wave" library?
EDIT: Also, now I noticed, that when I apply the sox command to only one file, the file is converted to "RIFF" format and the waveform is similar to the second image, however when I apply them to all of them with the above described command, the audios loose their sound.
Thank you in advance!


texts:
Consider a random process with auto-correlation function:
  $$r_{\rm dd} [k] = \beta^{\lvert k \rvert}\quad\text{where}\quad 0 < \beta < 1.
$$
  Suppose also that the observation is:
  $$
x[n] = d[n] + v[n]
$$
  where $v[n]$ is uncorrelated white noise with variance $\sigma^2$.

  Design a first order Wiener–Hopf filter to reduce the noise in $x[n]$ of the form

  $$W(z) = w(0) + w(1)z^{-1}$$


texts:
I am new to DSP? Where is a good resource for open source DSP algorithms?

MATLAB is great at making protos but once we move to C coding, it takes time and we end up making too many mistakes. I would guess there must be good repositories of C codes for various implementation of filters etc. Any pointers would be good.


texts:
How wavelet transform is different from STFT.

I'm not able to understand what is resolution in frequency domain means?


texts: Is there a relationship between Average energy of transmission and power saving

texts:
As mentioned  in many books, the average energy of transmitted symbol is given by:

$E_s = (2/3)(M - 1) $

where $M$ indicated the modulation order.
Suppose that we are using in the first scenario $SISO$ system, and we need to transmit 8bit/channel use, so the needed modulation is $256QAM$ which is equivalent to $E_s = 170$.  now suppose that we are using $MIMO$ system with two transmitters antennas and two receiver antennas, so to transmit the data rate of  8bit/channel use, we need to transmit 4bit/channel use in each antenna, we will need to use $16QAM$, so the needed $E_s = 10$ in each antennas, which is in total 20.

can we say, the power saving for transmitting 8bit/s/Hz in case of using MIMO system is 170/20  ?

Is that right? thank you


texts: Compressive Sensing: Reconstruct Gap in Antenna Array

texts:
I have an antenna array with $N$ elements spaced half a wavelength apart.
I have a second, identical antenna array that is the distance $D$ apart from the first one.

Could I use compressive sensing to reconstruct the full antenna array?

If so, how big can $D$ be and what are my limitations?


texts: Recorded an audio file using microphone via Windows Sound recorder, but has 2 channels that are slightly different. Why are they different?

texts:
I recorded sounds using a plug in microphone on a Windows 7 laptop. I used the Windows Sound recorder to record the sounds. It was only one microphone, but when I load the sound file into Audacity, it loads 2 channels. This is to be expected, but the sound files are slightly different (subtracting them from each other in MATLAB doesn't result in a zeroed signal).

Shouldn't they be copies of one another?  I didn't use any special effects etc.

Thanks


texts:
I'm newbie in DSP (maybe the question title is misleading for this reason, I apologize for this, please feel free to edit it) but not in programming. I want to experiment with Fourier (or FFT) transformation. Basically I need the generator which will give me signal looking like this:

I would also like to add/remove to/from this signal some noise, This is example for sine wave but I hope you get the point.

Is this possible for someone whom only knowledge about Fourier transformation is that is composition of sines and cosines with the aim of being able to create signal of any shape? I've been searching for some code snippet where I can change parameters and see how the signal is changing but my google-fu was not enough for this. Preferred language is python (where i can import module and call function) or R or something multi platform (open source) and simple and fast. Thank you.


texts:
I'm new to DSP and am trying to design a low pass filter in matlab using firpmord(F,A,DEV,FS,'cell') and firpm() using the following given paramters:  passband Fpass=4 MHz and stopband Fstop=6MHz, with attenuation of at least 60dB and the sampling frequency of Fs=20MHz.
My question is, since the passband ripple is not given, what vector should I pass as DEV to firpmord(F,A,DEV,FS,'cell')?
My code in matlab so far is as below:
Fp = 4e6; Fs = 6e6; Fsamp=20e6;
As = 60;
c = firpmord([Fp Fs], [1 0] , [0.01  10^(-As/20)], Fsamp, 'cell');
h=firpm(c{:});


texts: Question regarding transfer functions and prerequsities for finding the real impulse response

texts:
The transfer function of a system is given by:

$$\large H(s) = \huge \frac{V_{out}(s)}{V_{in}(s)}$$

In digital domain the principle is of course the same, just replace laplace transform with z-transform and voltages with amplitudes. The transfer function, when converted to time domain, solves the impulse response of the system when conditions are met.

My question is about the prerequisites for finding the real impulse response using this method (other than LTI properties). Obviously, if a signal with a shorter length than the impulse response is used for the analysis, the real impulse response can't be solved for. However, is it enough to have a signal the length of the impulse response, regardless of what the input is? (Using dirac delta as input will of course solve the impulse, but what about other cases such as $sin(t)$?)

I can at least answer the question when it comes to fourier transform and related frequency response $H(w)$. In that scenario the signal indeed needs to be zero padded properly or we will have circular convolution. I am assuming the case is then the same for laplace transform. Thus, is it correct to say that for the $H(s)$ to yield the correct transfer function, the time signal representing the input needs to be zero padded by the length of the impulse (-1)?


texts:
First of all sorry if this is a stupid question, but I am an absolute beginner in this field and have been trying for days now.
I'm working on a java program that uses fft to analyze audio files.
To test the results I'm getting from the fft I drew some spectrograms, which are working perfectly for WAV files. But I get weird effects when using mp3 or mp4 files. I use the Jtransform library from wendykierp.

This is what it should look like.

And this is what is looks like.

It is also half the width of the wav spectrogram (due to compression?).
If yes can this be compensated for?

The samples seem to be correct:

From my program:

From Audacity:

And here are the spectrograms for the Mp3 and Mp4 of a 1khz Sinus wave.

Mp3:

Mp4:

EDIT:

The suggestion to test with octave helped quite a bit. I changed the code to just take the first half of the FFT output and added channel separation for the samples of the mp3. Now I get the correct specrogram for mp3 files.

But there are still two problems:

The first is that the mp3 spectrogram has only 1/4th of the width and 1/2 of the height of the wav specrogram because of the sample count. It also seems to be cut of[f] a bit at the top. Can I solve the width problem by just interpolationg new samples or is there a better way?

The second is that mp4 files still look like above, which probably has more to do with the samples or channel layout than the FFT itself (?)


texts: Help in viewing the output of a neural network

texts:
I used nftool in Matlab 2012 and trained a network. I gave the training inputs as x=[250:1] and targets as t=[250:1]. I used 10 hidden layers. I trained the network and got the results and exported the data to workspace. I finally got net as the variable in the workspace. I want to realize this network in hardware. So, I want the exact weights and bias values. I searched the net and typed net.IW and got 10 values, net.LW and got yet another 10 values and net.b and got 11 values. My network diagram is as shown below:

If IW is the Input Weight and LW is the Layer Weight, I realized the network diagram as shown below:

I got 10 values for IW, which would fit into 10 hidden layers, and 10 values for LW, which will fit into 10 hidden layers according to my realization. I got 11 values for bias, which will fit in to my network, since there are 11 (b) blocks in the network.
But, i am missing one IW and one LW value.

I want to know whether there is a mistake in my realization of the output of the network or I missed any of the values. Please help.


texts: I've read the explanation in http://urchin.earth.li/~twic/Golomb-Rice_Coding.html and http://en.wikipedia.org/wiki/Golomb_coding , however, I still not get the intuition why it is efficient and when it is useful.


texts:
I am aware that complex discrete-time signals are of the form:
$$
x(n) = a(n) \cdot e^{j\omega n T}
$$
However, I have not yet worked with complex signals, only real ones. What are some practical examples of complex signals? Answers with plenty of detail are appreciated.


texts: Extracting positive frequencies of discrete-time signal

texts:
Convolution in the time domain is the same as multiplication in the frequency domain.

My data is sampled at 200 Hz, which means that the Nyquist frequency is 100 Hz, and all frequency content is <= 100 Hz. If I take a rectangle function in the time domain, with 1s everywhere below 100 Hz, FFT it, and convolve my data with that, it shouldn't make a difference. Indeed, the FFT of the rectangle function is sin(pi*x)/(pi*x), which is 0 at all integers except the origin.

When FFTing something like cos(2*pi*x/40), a sine wave at 5 Hz, you get two peaks. One at 5 Hz as expected, and one at -5 Hz. This can be thought of as two spirals e^(2*pi*i*x/40)/2 and e^(-2*pi*i*x/40)/2, one rotating counterclockwise, the other clockwise. When added, their complex parts cancel out, leaving only a real sine wave.

I want to extract only the part of my data with positive frequencies. For example, cos(2*pi*x/40) should become e^(2*pi*i*x/40)/2. This should reasonably make the data contain complex samples.

I thought to do this by creating a rectangle function with 1s where 0 <= x <= 100 Hz, FFTing that, and then convolving my data with the result. The resulting function (according to WolframAlpha) is 0.5 * e^(-pi*i*x) * sin(pi*x/2)/(pi*x/2) (graph, real part blue, imaginary part red). The problem is that the imaginary part is always zero at integers, which is weird. Since my data is real, and this function is always real at integers, the result of convolution must be entirely real, which contradicts the previous paragraph.

What is going on here? And how do I actually get what I want?


texts:
I am trying to extract finger print from this image by using green LED backlight but when it convert to binarize image most of finger print is gone.

gray= green

I use this fomular to convert from this color image

to this gray image

I use otsu for binarization. So Which preprocessing I should use before convert to binarization to emphasis the finger print.


texts: Do negative frequencies count towards null-to-null bandwidth?

texts: I am aware that negative frequencies do not normally count towards the bandwidth when transmitting in the baseband. However when specifically asked to look at the null-to-null or zero-crossing bandwidth, should the negative frequencies count? For example, in the sinc plot below, is the bandwidth 1 or 2?


texts: Similarity or Relation between Walsh Hadamard Transform and Slant Transform

texts: Is there any relation between Walsh Hadamard Transform and Slant Transform? Or is there any common property or similarity?


texts: How to Get Rid of Ripples from a Gradient Image of a Smoothed Image?

texts:
I have a gray scale UINT8 image. When I smooth it with a Gaussian filter and then compute the gradient image with a Sobel filter in OpenCV, ripples would appear.

The first image is what happens when I use a 25x25 Gaussian filter with sigma value 4 and compute the second order derivative in the x direction with a size 3 Sobel filter.

The more I smooth the image, the more significant the ripples become.

The second image is what I got when I use a 49x49 Gaussian filter with sigma value 7. The Sobel filter is the same as the first image.

Why is the Gaussian filter creating more noise when it's suppose to get rid of them? How should I deal with this?


texts: Understanding Magnitude Spectrum of Images

texts:
I am facing problem in reading Fourier domain of a given image. I don't understand what to interpret from it. For instance, consider this image.

Ok, so there is a dot in the middle, with some striking vertical and horizontal lines and there are also some circulating white lines which are low in intensity. What do I interpret from them? I basically converted the image to a monochrome image and then took the fourier transform of the monochrome image and displayed it along with original RGB image. Please help me to understand this. I tried every other resource but nothing got into my head. What are the uses of this interpretation? Also, in one of the answers here on DSP stackexchange, the images of sine and cosine were taken and then converted to spectrum which resulted white dots in it. I don't want to know that. I know that these dot represents the frequency component present in the sine and cosine. I want to understand everything with respect to my image only.

Thanks in advance!!


texts: Does this FFT algorithm give correct IFFT when the input does not contain symmetry?

texts:
This FFT function is from Numerical Recipies in C and I am using it in my java projects. The source code is given below:
void fft_function(double datain[], int nn, int isign)
{
    // input
    // datain[0]: ignore
    // datain[1]: Re1
    // datain[2]: Im1 (=0)
    // datain[3]: Re2
    // datain[4]: Im2 (=0)
    // ....
    // output:
    // datain[0]: ignore
    // datain[1]: Re1
    // datain[2]: Im1 (= 0, dc value)
    // datain[3]: Re2
    // datain[4]: Im2
    // ....
    // nn = FFT size (power of 2)
    // isign : 1 -> FFT, -- -> IFFT

    int n;

    double temp_data;
    int  mmax, m, j, istep, i;
    double wtemp, wr, wpr, wpi, wi, theta;
    double tempr, tempi;

    n=2*nn;
    j = 1;

    // This is the bit-reversal section of the routine.
    for (i=1;i<n;i+=2) {        // for (i = 1; i <= n; i += 2) {
        if (j > i) {

            temp_data = datain[j];
            datain[j] = datain[i];
            datain[i] = temp_data;
            temp_data = datain[j+1];
            datain[j+1] = datain[i+1];
            datain[i+1] = temp_data;
        }
        m = n/2;
        while (m >= 2 && j > m) {
            j -= m;
            m = m/2;
        }

        j += m;
    }

    //Here begins the Danielson - Lanczos section of the routine.
    mmax = 2;
    //Outer loop executed log2 nn times.
    while (n > mmax) {
        istep = mmax *2;
        //Initialize the trigonometric recurrence.
        theta = ((double)isign*6.28318530717959f) / (double)mmax;       // theta = 6.28318530717959f / (double)isign*mmax;
        wtemp=Math.sin(0.5f*theta);
        wpr = -2.0f*wtemp*wtemp;
        wpi=Math.sin(theta);

        wr = 1.0f;
        wi = 0.0f;
        //Here are the two nested inner loops.
        for (m = 1; m < mmax; m += 2) {        // for (m = 1; m <= mmax; m += 2) {
            for (i = m; i <= n; i += istep) {
                //This is the Danielson-Lanczos formula:
                j = i + mmax;
                tempr = wr * datain[j] - wi * datain[j + 1];
                tempi = wr * datain[j + 1] + wi * datain[j];
                datain[j] = datain[i] - tempr;
                datain[j + 1] = datain[i + 1] - tempi;
                datain[i] += tempr;
                datain[i + 1] += tempi;
            }
            //Trigonometric recurrence.
            wtemp=wr;
            wr = wr*wpr - wi*wpi + wr;
            wi=wi*wpr+wtemp*wpi+wi;
        }
        mmax = istep;
    }

}

This gives perfect results when doing something like a = FFT[real array], IFFT[a] = real array, that is, if I do an fft of a real array, I get an imaginary array with the required symmetry. If I input the same imaginary array and get an IFFT, I get the real array back.
However, I need to find the IFFT of a complex array that will not necessarily have the positive and negative symmetry of a complex array that results from taking an FFT of a real array. For example, I would like to find a the IFFT of something like this:
0.12 + 0.023i
0.15 + 0.2i
0.235+ 0.006i
-0.562 + 0.36i
-0.663 - 0.566i
0.23 - 0.56i
0.889 - 0.226i
0.001 + 0.221i

I think this algorithm will not work in that case, and I am not getting the same results as a matlab IFFT for the same input.

Am I correct that this algorithm does not work when the complex array does not have the required symmetry?
What can I do to find the IFFT in such a case? Can it be done by an easy modification to this code or is it more complex?


texts: Power Spectral Density and Fast Fourier Transform basic question

texts:
I am new to signal processing and I am trying to get the basic concepts right.
I have a signal and I performed the FFT of the signal in MATLAB. I also did the PSD of the signal in MATLAB using the psd command.

So I am confused about:

1) When we get the FFT of the signal, It's basically showing what frequency components are inside the signal. So it's a plot of frequency against what? It is amplitude in volt right(took the abs value of the signal)? What if I want to plot dbV against frequency should I just do a mag2dB conversion on the abs value? Is the following right?

Code I tried:

Fs = 16000;
t = 0: 1/Fs : 2*(Fs-1)/Fs;
y1 = sin(2*pi*500*t );
fshift = (fftshift(fft(y1)));
f = -8000 : 1/2 : 7999;
figure;
plot(f,mag2db(abs(fshift)));

2)Now for the PSD, I used the dspdata.psd of MATLAB and I get a plot. On the plot, I get my frequency component but the max amplitude (in dB) is not the same as the max amplitude (in dB) of the FFT plot. Why is that? Is it because dsp is using 10log 10 and mag2dB is using 20 log 10?

3) In the PSD plot I am getting two plots one blue one which is quite visible and a green one, smaller in amplitude, what is this green one?

Code below:

Fs = 16000;
t = 0: 1/Fs : 2*(Fs-1)/Fs;
y1 = sin(2*pi*500*t );
psd1=spectrum(y1,1024);
hpsd = dspdata.psd(psd1,'Fs',Fs); % Create a PSD data object.
figure;
plot(hpsd); % Plot the PSD


texts: How to determine the frequency of a waveform?

texts:
I am getting data from a sensor which gives 64 samples per second. If I take 64 as the sampling frequency, what would be the frequency of the signal?
I have applied a Fourier transform on the signal. I got a double sided spectrum with X-axis ranges from 0-64, if I take a positive side of the spectrum I want to determine the frequency of those points.

Image1: plot of samples for 1 sec
Image2: FFT of 1 sec signal


texts: Image Processing/Analysis for Eye blink detection

texts:
I am working on a eye blink detection project in Matlab. By this moment I have been successfully extracted the images of pupil of eye from the real time video captured via a web cam.

But I am stuck at the process to differentiate the open eye pupil to the closed eye lid state.

Open eye pupil

2.closed eye lid

Could you please suggest me any image processing function or algorithm to differentiate between the two states.

(Attached images are the original/actual images extracted from the program on which image processing is to be done.)


texts:
I have read in some dsp texts that when ROC includes unit circle,system is stable

But i am bit confused in difference between stability and marginal stability depending Upon ROC

Especially i am confused by part c of below dsp.se question

Z transform stability

Where in part C, ROC is 1/3 < |z| < 1 and analysis answer of part c is written as "non-causal & marginally stable" . I am confused by marginal stability. why it is marginally stable?If our ROC is changed to 1/3 < |z| < 1.1, will now it becomes stable or will it still remains marginally stable?


texts: How to apply a 2D -2D homography matrix to an image?

texts:
I have a mini project to do about homography, but I am really a beginner in Matlab. I have calculated the homography matrix easily by taking a set pixels from both images but the problem is how to apply this matrix to all pixels of the original image (I think it's difficult to treat each pixel individually).

Here is the original image :

I want to apply the homography to this image (I have already extracted the homography matrix) to get a frontal view of the cover.

So with my weak knowledge of Matlab, I applied the following operations:

I get 4 points from the corners of the original image and the corresponding points in the output image
I have estimated the homography :

 0.9638   -0.0960   52.5754
 0.2449    1.3808  -17.0081
-0.0001    0.0013    1.0000

then I have applied it on the image using this poor Matlab code:

function [Ired] = affect(I,P)
I1=im2double(I);
for i=1:308
i
for j=1:288
v1 = [j;i;1];
v2 = P*v1;
v3 =v2/v2(3,1);
if (v3(1,1) <0 || v3(2,1)<0 || v3(3,1)<0)
   continue;
else
Ired(round(1+v3(2,1)),round(1+v3(1,1)))=I1(i,j);
end
end

end

and the result is the following:

but the problem with this code is it takes a lot of time (sometimes 10 minutes) to perform the operation on the image, especially if the size of the image is high. Is there a way to implement this code without loops to make it faster?
I get these black dots all over the image, I can do a dilation but the image will be distorted, do you have an idea how to eliminate this dots without distorting the image?

I cannot use predefined Matlab functions in this project.


texts: How to set sigmas and kernels for 3D-Laplacian of Gaussian filters to blob detection in Matlab?

texts:
I have written code according to a paper for Lung CT images, but its output wasn't correct. I think it is because of the setting of its parameters.
The paper is about a multi-scale method using a Laplacian of Gaussian (LoG) filter for estimation of nodule size and location. For nodule location and size estimation, the algorithm generates nodule candidates in a small region of interest around the nodule, and the best candidate is selected through a rule-based method.

In the paper, the size parameter of the kernel is directly related to the diameter of a candidate nodule as given by this expression d^2 = 12*sigma^2. So, for the task of identifying possible candidates, 150 normalized LoG kernels of incrementally increasing size corresponding to the diameter range from 3.0 to 30.0 mm were used. However, I couldn't set other sigmas based on the diameter of the nodules according to that formula(d^2 = 12*sigma^2).
How can I set the parameters in the following code?

Code:

% Algorithm parameters
  load image  % image is 3D as image(x: row, y: col, z: slices).
% Initial sigma used to generate the Gaussian Filters
  initial_sigma = 1;
% Number of scales that are going to be generated
  number_scales = 7;
% Threshold that indicates whether a blob is considered or not
  threshold = 1;

  sigmas = initial_sigma.*(sqrt(2).^[0: number_scales-1]);
  imageSize = size(image);
  dimX=imageSize(1);
  dimY=imageSize(2);
  dimZ=imageSize(3);
  % Reserve memory for the space-scale volume
  scale_space_volume = ones([size(image) number_scales]);
  % Generate the scale-space volume using different gaussians
  for i = 1 : number_scales
      filter_size = 2 * ceil(sigmas(i) * 2) + 1;

     % Create the 3D laplacian of gaussian filter
      H = fspecial3('log', [filter_size filter_size filter_size], sigmas(i));

     % Apply the filter to the image and store it in the volume
       scale_space_volume(:,:,:, i) = sigmas(i)^2 * imfilter(image, H, 'replicate');
     % imshow(scale_space_volume(:,:, 85, i));

  end


texts: How can I enforce aliasing with Audacity?

texts:
I would like to hear how aliasing sounds like. How can I get this with Audacity?

(I was told that I should adjust the Fourier coefficients in Audacity. I have no idea where I can do so / how I should adjust them.)


texts: Build a filter such that its periodized version equals to x on signals with period m

texts:
I have the following task:

Assume that $h$ is a filter with finite support $[0..(m−1)]$ for some $m>0$. Let $x$ be a circular extension of $h$.

Prove that $x\in l_\infty$.
When is $x\in_1 $?
Build a filter $y\in _1 $ such that its periodized version $y^m$ equals to $x$ on signals with period $m$.

I answered two first questions but cannot figure out the solution for building filter $y\in l_1$ such that its periodized version $^$ equals to $x$ on signals with period $m$.
Could someone help me?


texts: Sequential Form of the Least Squares Estimator for Linear Least Squares Model

texts:
I'm currently working on a project in which I need to find the tilt of a surface. Let's assume I'm only concerned with a single dimension tilt (i.e. slope) to begin.

I currently have the ability to calculate parameters of Affine Functions as described in Line of Best Fit (Least Square Method). However, this requires me to batch all the data prior to performing the calculation.

Is there instead a sequential / iterative form for computing the least squares linear fit such that I'm not required to batch the data prior to performing the calculation? Instead I would like to continuously update the least squares slope for each new data point that is received. The motivation to this is that I could avoid saturation / overflows due to batching data.

If you still don't understand what I'm asking, refer to this web page here which outlines a recursive form for calculating the mean - Heiko Hoffmann - Unsupervised Learning of Visuomotor Associations - PhD Thesis - Iterative Mean. The advantage of using this method is that you don't need to keep any large sums going thus avoiding potential overflows, and instead, you simply weight the new data against the previously calculated mean.


texts: calculating SNR from dbfs (using spectrograms)

texts:
I've the spectrogram of both noise and signal (both 5 seconds). Below image shows an example of the signal spectrogram:

The colour of the spectrogram shows the intensity in dbfs (from 0 dbfs to -120 dbfs). Now, I'd like to calculate the SNR value from these two spectograms. But, I'm not sure how to do it. What I did is:

dbfs_new(x) = dbfs(x) + 120 where x is the value of each pixel (between 0dbfs and -120 dbfs).

This makes sure that higher intensity has higher value and not lower value.

calculated RMS for both signal and noise using their spectrogram:

RMS_signal = (SUM(dbfs_new(x)^2)/m)^.5 where m is the total number of pixels
 RMS_noise = (SUM(dbfs_new(x)^2)/m)^.5 where m is the total number of pixels

and, finally:

SNR = RMS_signal - RMS_noise (in dbfs)

But, I'm not sure what I've done is correct! Can I calculate SNR from dbfs? If not what do I need to do?

Appreciate your help.
Thanks


texts: How does phase relate to motions in an image?

texts:
There is lots of research based on exaggerating motions by decomposing an image into complex sub-bands using pyramid representations such as the complex steerable pyramid and manipulating phase signals to amplify motions. This avoids the estimation of optical flow

Examples:

[1] http://people.csail.mit.edu/nwadhwa/phase-video/

[2] https://link.springer.com/chapter/10.1007/978-3-319-49409-8_8

I am interested in this research. I don't have an image processing background. My question is how does phase relate to motion in an image? Why does manipulating phase not affect colors in an image?


texts: A digital low pass Butterworth filter that has been designed using Bi-linear transformation has been a pole at $z=0.6$. It is also known that the filter's attenuate (at digital frequency) $\omega = 1.2$ is about $44$ dB. Find the filter order. Give at least one other pole of the digital filter (in Z domain).


texts: Effective Nyquist frequency / signal resolution for overlapping time averaged signal samples

texts:
Say that I have a continuous signal. If I sample the signal at sampling rate f_sample, then the highest signal frequency that I can resolve without worrying about aliasing, etc. is the Nyquist rate f_Nyquist = 0.5 * f_sample, so arguably I could interpret this as meaning that the time resolution of my signal is dt_min = 1 / f_Nyquist = 2 / f_sample. Fine.

However, the above is for instantaneous sampling. How does the picture change if each of my samples involves averaging over a given finite time period t_width, with the possibility that successive time periods overlap by a time t_overlap? (See picture. Equation for t_overlap in the picture ignores cases where overlap extends beyond that of nearest neighbors, but it's easy to generalize.)

I.e., in the case that t_width = t_overlap = 0, I have f_Nyquist = 0.5 * f_sample, dt_min = 2 / f_sample, as above. For the case that t_width, t_overlap != 0, is there still a simple statement that I can make regarding f_Nyquist, or more importantly some generalization of f_Nyquist which is relevant to the quantity that I am actually interested in, namely the time resolution of my signal t_min? Is there a simple equation for something that is interpretable as t_min that could be used in such a situation?

Extra:

The above is the main thing I am interested in. However, just to add one more generalization in case anyone happens to know it: If the averaging weight function over t_width is not uniform, but is instead something more complicated (e.g., Gaussian), is there still a relationship or theorem that can help me figure out what t_min is?

Thanks for any help!

P.S.

If my interpretation of the Nyquist rate is wrong or anything, let me know and I'll correct it in the post.
I think this is the right StackExchange site for this question, but if there is another that anyone knows of where an answer is more likely, please suggest it.


texts:
I am in the process of implementing MFCC and I'm unsure about the DCT part.

This is how I implemented it (using DCT II).

//some coefficients
let k = Math.PI/numFilters;
let w1 = 1.0/Math.sqrt(2);
let w2 = Math.sqrt(2.0/numFilters);
let numCoeffs = numFilters;
let dctMatrix = new Float32Array(numCoeffs*numFilters);

// compute the dct matrix
for(let i = 0; i < numCoeffs; i++){
    for (let j = 0; j < numFilters; j++) {
        let idx = i + (j*numCoeffs);
        if(i === 0){
            dctMatrix[idx] = w1 * Math.cos(k * (i+1) * (j+0.5));
        }
        else{
            dctMatrix[idx] = w2 * Math.cos(k * (i+1) * (j+0.5));
        }
    }
}

// apply it on the logged energies.
let mfccs = new Float32Array(numCoeffs);
for (let k = 0; k < numCoeffs; k++) {
    let v = 0;
    for (let n = 0; n < numFilters; n++) {
        let idx = k + (n*numCoeffs);
        v += (dctMatrix[idx] * loggedMelBands[n]);
    }
    mfccs[k] = v;
}

I'm getting 26 values (which is the number of filters I defined), both negative and positive values, where the first value is always has highest magnitude and the rest are in the range of -1 and 1.

Does this implementation seem correct to you?


texts:
Since both fft ,freqz are used for finding the frequency response of digital filters.
the frequency response using freqz function is given below

and frequency response using fft function is

it seems to be that in case of fft it is mirror image of freqz response.
also i want to find value of freq response at pi/8 how can i find it using any of fft or freqz method.


texts: I want to detect circles in the image below but this approach, of using cv2.approxPolyDP on contours and counting the sides of the polygon, doesn't work here since some of the circle is missing. Is there a faster way of detecting shapes in this case than using the Hough Transform?


texts:
I am confused with regard to how bandwidth increases with increase in number of bits transmitted for given duration.

1) Usually say in PCM system, when we increase the number of bits (n) for a given sampling frequency (fs), the bitrate increases and minimum transmission bandwidth thus increases.

Rb = nFs  and Bandwidth = Rb/2.

2)While in M-ary schemes,when the number of bits is increased the bandwidth decreases because in time domain  the signal is expanding,so obviously in frequency domain the overall width should reduce.

I am not able to understand the context in which either is true!


texts: Guess stability based on filter coefficients

texts:
is it possible to guess the stability of a filter with given coefficients a and b? I know that the right way would be to calculate the pole positions and check if they are in the unit circle but I think I read that there also is another method.

Cheers


texts: How does the PSK demodulator differentiates one carrier from the other in CDMA

texts:
I'm trying to understand the way in which CDMA works. Once the transmitter bit sequence is spread it is modulated for instance using a PSK modulator. Lets assume BPSK is used. I'm particularly interested in the case in which there are 2 transmitters each with its own spread sequence, orthogonal to the other, so they don't mutually interfere . Assuming they both transmit to the same receiver at the same time using the same carrier frequency and BPSK modulation. How is the receiver capable of demodulating the BPSK signal in order to recover the bit sequence from both receivers so it can be passed to the respective de-spread stages where the original messages can be recovered?

To me the transmitters' information is divided in code, but codes can only be separated once they are bits not while they are "pass band symbols", right? And before they can be successfully recovered as bits, isn't there a lot of interference at the BPSK demodulating stage where phases from 2 BPSK carriers are being received at the same time? How can the BPSK demodulator demodulate useful bits under that circumstance?


texts: Help in sketching a CT signal with discontinuities

texts:
This is the Original signal:

And I'm supposed to sketch
$[x(t) + x(-t)] .u(t)$
I know that unit step signal will make the signal starts from 0 to $+\infty$
My problem is at key point (0) and key point (1)


texts: Proving that this process is weakly-stationary

texts:
Let $X(t) = Acos(2\pi f_c t)$ be a random process where $A$ is a uniform random variable within $(-1,1)$. I'm trying to prove this is a weakly(i.e. wide sense) stationary process. I need to show two conditions

Constant mean.
Autocorrelation $R_X(t_1,t_2)$ only depends on the time difference $t_2-t_1$.

First one is easy. However, I can't prove the second condition. I've tried the following,

$R_X(t_1,t_2) = E[X(t_1)X(t_2)] = E[ Acos(2\pi f_c t_1) *  Acos(2\pi f_c t_2)] =  cos(2\pi f_c t_1)* cos(2\pi f_c t_2)*E[A^2]$

Using trig identities,

$=1/2(cos(2\pi f_c (t_1+t_2)-cos(2\pi f_c (t_1-t_2))*E[A^2] $

Where $E[.]$ is the expectation operator.

I'm stuck here, how can I do this?


texts: How would I spectrally rotate/invert an audio signal (Matlab or Python)?

texts: So I have a 4.5 minute wav audio clip. I want to spectrally rotate the frequencies such that the spatio-temporal characteristics of natural speech are retained, while having the new audio be unintelligible. Any tips? I found https://ccrma.stanford.edu/~jos/sasp/Spectral_Rotation_Real_Signals.html, but I'm not getting anywhere with it.


texts: T wave analyis and extraction using discrete wavelets

texts:
I'm doing a project in T-wave extraction from ECG signal. Initially I completed the preprocessing steps like noise removal and baseline drift cancellation. Then I need to extract T wave using discrete wavelet transform. I tried different wavelets for different level in wavelet, but I'm not able to extract the T wave.

Can you help me with MATLAB coding?


texts:
I am a big fan of fft convolution. So, I mostly try to avoid non-fft convolution.

Suppose, I am trying to convolute an image with another image. Suppose the first image is $512\times 512$, and, the mask image is $520\times 255$. How would we convolve them in the frequency domain?

Two major issues are to be addressed here,

to apply fft, images must have dimensions which are the multiple of power of 2. Our image and mask may or may not have dimensions of power of 2
to apply the fft, the dimensions of the image and the mask must be equal.

So, in order to address both issues, we can do any one of the following,

we can take the max of the width and heights of both image and the mask, round them to next power of 2 and, pad them.
we can take the sum of the widths and heights of the image and mask, round them to next power of 2 and, pad them.

Questions:

So, in both of the cases we are actually obtaining oversized output images with padding. Am I right?
Suppose, I pad an image and get it FFT-filtered (Sharpened/Blurred/... and so on). So, I obtain a filtered image with padding. Now, I need to remove the padding to obtain the filtered image without padding. Am I correct?
If YES, should I just crop the image?
Or, is there any better way possible altogether from the ground up?

Suppose, this is the original image ($512 \times 512$),

And, suppose, the following is the filtered image with padding ($1024 \times 1024$),

Now, I want to obtain this,

How should I remove padding from this image?
Should I just crop, or, is there any better technique to get around this problem from start?


texts: How does the Meyr-Oerder Timing Algorithm work?

texts:
I`ve came across a Paper for this Algorihm for estimating the Symbol-Timing from Meyr and Oerder, which I want to understand. The Algorithm uses blocks from the samples and calculates the Timing Estimation for the difference between the Transmitter-Clock and the Receivers clock. By squaring the blocks we are getting a peak in the spectrum which is our symbol timing.

My questions are:

Why are we getting the symbol timing by squaring the signal block?
What does the Fourier-transformation do to the squared signal-block?


texts: How to estimate the frequency at certain time of linear sine sweep?

texts:
experts.
I have a question concern "linear sine sweep".
Here is the equation of linear sine sweep(from Wikipedia Chirp).
$$ x(t) = sin\biggl[ 2\pi( f_0 +\frac{f_1-f_0}{2T}t)t\biggr] $$
where,

$f_0$ is start frequency
$f_1$ is end frequency
$T$ is total length of excitation time.

In my case, I would like to calculate the excited frequency at certain time frame.
Let me calculate it through an example.
$f_0 = 20 \text{ Hz}$ , $f_1=200 \text{ Hz}$, $T = 60\text{ s}$.
In this case, above equation can be written as below,
$$ x(t) = sin\biggl[ 2\pi( 20 +1.5t)t\biggr]. $$
If we estimate the frequency at time 30 s, I think we could calculate as 65 Hz.
For checking this is right or not, I checked the power spectrum by selecting time through 29.5 s  - 30.5 s for frequency resolution 1 Hz.
However, from the power spectrum, the frequency was 112 Hz.
There is difference between simulation value and calculated value almost twice.
Also, I just checked 1 second(29.5 s - 30.5 s) Fourier transform absolute value, it also displayed the peak frequency as 112 Hz.
What is the correct value?
If the calculated value, 65 Hz, is wrong, is there any comment for correcting this?
Thank you in advance.
If there is any comment or question, please let me know.


texts: How should a moving average handle missing data points?

texts:
I'm writing a program that averages the user's weight across different days. I'm planning to use a 5-point moving-average (current day, two before and two after). Sometimes, a data point is missing for 1-2 days. How are these cases usually handled?

(if there's a better low-pass filter I could use, I'd love suggestions)


texts: Maximum Likelihood Detection of Signal Vectors in Gaussian Noise

texts:
Consider a binary-input additive white Gaussian noise channel.

Let $\mathbf{x}_0 = (\sqrt{Es},\sqrt{E_s},⋯,\sqrt{E_s})$ and $\mathbf{x}_1 = (-\sqrt{E_s},-\sqrt{E_s},⋯,-\sqrt{E_s})$, be two codewords of length $d$. Suppose $\mathbf{x}_0$ is transmitted and the received vector is given by $\mathbf{y} = \mathbf{x}_0 + \mathbf{n}$, where the noise vector $\mathbf{n}$ is an i.i.d. Gaussian random vector with  mean zero and variance $\frac{N_0}{2}$ . Suppose that maximum-likelihood decoding is employed. The pairwise error probability $P_d$ is the probability that the decoder chooses the incorrect codeword $\mathbf{x}_1$ as the decision instead of the originally transmitted $\mathbf{x}_0$. Show that  $P_d=Q(\sqrt{\frac{2dE_s}{N_0}})$, where $Q(x) = (\frac{1}{\sqrt{2 \pi}})\int ^{\infty}_{x}e^{-\frac{t^2}{2}}dt$

I know how to calculate the error probability for bpsk in the other type,but not codewords type,does anyone know how to calculate the probability for codeword type?


texts: How can internal energy be calculated in the active contour model when the spline/contour is Piecewise linear?

texts:
I have been trying to understand the active contour model and I have started writing a Python script to implement the model myself.  Based on the following slide from these lecture notes I found that the spline could be based on discrete points, which I have.

But if the overall energy is calculated by

where $v_s=\frac{dv}{ds}$ and $v_ss=\frac{d^2v}{ds^2}$, then how is this supposed to work when $v(s)$ is a piecewise linear function? I was thinking the first derivative might worked just using the simple $\frac{\Delta v}{\Delta s}=\frac{\text{rise}}{\text{run}}$, but if I'm going with that then second derivatives will all be zero?
My points are the following, shown with a parametric equation overlaying it based on two sinusoidal regressions in both axes:

but of course this is way smoother than the actual points and thus my second derivatives aren't going to help me determine the total change in concavity that the internal energy is supposed to represent.
I can't find anything about this online either. Any ideas?
This video says to just use the truncated Taylor series for derivatives to calculate them, but we only have the points, not an actual function, so I'm not sure how they want us to use that formula?


texts: Detecting a frequency pattern in the frequency domain

texts:
I am looking to detect a combination of frequencies in the frequency domain. For example, here is my spectrum:

And I'm trying to detect the pilot tone. I have the FFT of the pilot tone:

which zoomed in looks like this:

I tried doing a cross-correlation in matlab:

trainingfft = fft(trainingfreq);
datafft = fft(idat);
Hxcorr = dsp.Crosscorrelator;
CorrResult = step(Hxcorr,datafft,trainingfft);

But ended up with this:

I really am looking to detect the presence of the three peaks anywhere in the spectrum. I think the cross correlation isn't working because of the presence of the noise floor, so I was thinking about using some kind of threshold checker to clean up the noise but really am looking for an elegant solution.

Is there an elegant way of doing this?


texts: Bandwidth range for Fast Fourier vs principal component analysis?

texts:
I've read somewhere that the Fast Fourier is only applicable to those processes exhibiting bandwidth. Where as principal component analysis can be applied to a process exhibiting any finite  bandwidth. Why is this?

The band width is simply the difference in the upper and lower frequencies in a contentious set of frequencies? So, for the Fast Fourier only a set of basis functions of discrete frequencies (i.e. $\sin(2\pi f x)$) are considered, but why does the bandwidth ($f_\text{max}-f_\text{min}$) need to be infinitesimal? Why can it not be finite? Is is due to the fact that the duration of the sine wave is infinite and therefore the bandwidth infinitesimal? Or have I miss understood? I cannot find this information anywhere.


texts: Fourier Transform Problem - absolute value, time-saving tricks, etc

texts:
I am given the following signal:

$$[e^{-at}cos(w_{o}t)]u(t),\ a>0$$

Then I am told to find the Fourier Transform, which tells me I need an answer of the form:
$$X(jw)=\int_{-\infty}^\infty \! x(t)e^{-jwt} \, \mathrm{d}t.$$

I know I can reset the bounds of my integral with the unit step function, so my equation becomes
$$X(jw)=\int_{0}^\infty \! e^{-at}cos(w_ot)e^{-jwt} \, \mathrm{d}t.$$

From here, can I essentially solve this out and get a correct answer, keeping $w$ and $w_o$ as separate variables?

I also know I can solve it by using the relation
$$x(t)=a(t)b(t)\xrightarrow{\mathscr{F}} X(jw)=\frac{1}{2\pi}A(jw)*B(jw)$$

So, essentially, I can figure out a transform for each part and convolve to find my answer?

From the book examples, it seems $cos(w_ot)$ can be broken down into $\pi\delta(w-w_o)+\pi\delta(w+w_o).$ If we convolve this with the result from the transform of $e^{-at}u(t)$, a correct answer should be obtained.

It is known that $X(jw)$ when $x(t)=e^{-at}$ is $\frac{1}{(a+jw)}$

Therefore, since impulses sift through the other function in a convolution to get the nonzero values, is the following a correct result? $$\frac{1}{2\pi}(\pi)(\frac{1}{(a+j(w-w_o))}+\frac{1}{(a+j(w+w_o))})$$

$$=\frac{1}{2}(\frac{1}{(a+j(w-w_o))}+\frac{1}{(a+j(w+w_o))})$$

Thank you, sorry for the long question!


texts: Block diagram of M-PSK modulation and demodulation

texts:
I have come across this quadrature modulator block diagram in many books and websites:

I've read that the quadrature modulator allows to realize many different digital modulations, including multivalued phase modulations: BPSK, QPSK, 8PSK etc. So this seems to be a general block diagram for these types of modulations. But the block diagram shows that the modulator uses low-pass filters (LPF).  From what I've read, these modulations mostly use raised cosine/root raised cosine filters. Why do most of the block diagrams show blocks with this particular filter? Is it simply because it's a generic diagram?
Now about the demodulator, I have this block diagram:

Will it work for any M-PSK modulation (BPSK, QPSK, 8-PSK, 16-PSK etc.)? Or is it only valid for QPSK? Won't the block diagram look different for e.g. BPSK modulation? Will the general block diagram for M-PSK modulation look the same? And if not, what would such a diagram look like?
I know that the received signal is fed to the input of a demodulator consisting of two low-pass filters and that they have to match the transmit filters used in the transmitter. As before, do they have to be low pass filters? Can't they be RC/RRC filters?
Also, are there different carrier recovery circuits and symbol timing? Is there a general principle of these circuits that obeys the demodulator principles (I know of two different systems: coherent and differential), the same for the decision system (which I do not know exactly what it is and how it works)?


texts: FFT of a signal with 0 added between samples

texts:
I'm having a rough time doing the following question from a HW. Given a sequence of your choice, what happens to the DFT if we add a 0 between every sample? I.e. if we have x[n] = [A,B,C], we turn it into x[n] = [A,0,B,0,C,0].

My initial thought was that the sampling frequency would double, similar to when we zero pad at the end of the signal. To do some analysis, I used the following MATLAB code.

Fs = 300;            % Sampling frequency
T = 1/Fs;             % Sampling period
L = 1500;             % Length of signal
t = (0:L-1)*T;        % Time vector

S = 0.7*sin(2*pi*50*t); %Signal - sine 50 Hz
z = zeros(1,3000);
z(1:2:end) = S; %Zero interp
z_fft = fft(z);
z_abs = abs(z_fft/(L*2));

P = z_abs(1:L*2/2+1);

P(2:end-1) = 2*P(2:end-1);
f = Fs*(0:(L*2/2))/(L*2);
plot(f,P);

Which yields the following plot:

That is different from the result when I add the same number of 0's but to the end of the sequence:

So I got confused, what is the result of adding the 0 between every sample? Does that doubles the frequency of my signal? What about that peak on f = 125Hz? Or am I making something wrong on my simulation?

Thanks for your time!


texts:
I'm new in the field of image processing and I'am trying to implement a watermarking algorithm (for medical images in DICOM format) based on this paper.

As written in the paper, this algorithm is based on the algorithm described by Ni, Shi, Ansari, and Su in the paper "Reversible data hiding" but it avoids modifying the histogram.

Despite having read and reread the paper several times, I did not understand the watermark insertion algorithm that is as follows:

Read the host image $I_o$
determine the color depth $k$
extract the first $k$ pixels and store their LSBs in a variable $S$
calculate the histogram of the remaining pixels of $I_o$: the histogram values will be $f(0), f(1), ..., f(2^k - 1)$ for the $k$ bit-depth image
determine a list of levels $l_0, l_1, l_2, ..., l_n$ such that $f(l_i) \geq f_{min}$ and $f(l_i + 1) = 0$, where $f_{min}$ is a minimum value that allows to reduce the levels encoding overhead
compute the list of delta values $\Delta_i = l_i - l_{i-1}$ with $i = 1...n$
encode $l_0$ in the LSBs of the first $k$ pixels
compute the bit string $B$ as the concatenation of $W_L$, $S$, $L$, $n$, $\Delta_1, \Delta_2, ..., \Delta_n$, $PayloadData$, $Signature$ where:

$W_L$ is the bit length of the following watermark, represented on 32 bits
$L$ are 8 bits expressing the bit length of the encoding of each $\Delta$
$n$ is the 16 bit representation of the number of the $\Delta$ values
$PayloadData$ are the data to be stored in the image (eventually encrypted)
$Signature$ is the digital signature of the host image along with the $PayloadData$

insert the bits of $B$ into the pixels (in raster scan order from the $(k+1)$-th pixel) having a gray level $l_0$, and then using the pixels with levels $l_1, l_2, ..., l_n$ in raster scan order: the insertion of a bit of value $b$ into $a$ pixel of gray level $l_i$ will assign the gray level $l_i + b$ to the pixel
write the obtained image $I_w$.

I try to make a simple example:

In this case:

I read the 3x3 image $I_o$
$k = 2$
I extract the first two pixels (I start from the top-left and I move to lines): $k_1=00$, $k_2=01$. So $S=k_{1}^{(2)} | k_{2}^{(2)} = 01$ where the sign $|$ indicates the concatenation operation and $k_{i}^{(2)}$ indicates the second bit (from the left) of the $i$-th pixel
I calcule the histogram of the remaining pixels so it's as if my image had now 7 pixels and not 9, right? The histogram is located in the figure at step 4
In my case this occurs only if I consider $f_{min}=0$, but it is an extreme case (I think). So $l_i=l_1=1$ and $l_{i+1}=l_2=2$ and so $f(l_1)=1, f(l_2)=0$. What it means with "...to reduce the levels encoding overhead"?
$\Delta_1 = l_1-l_0=1-0=1, \Delta_2 = l_2-l_1=2-1=1, \Delta_3 = l_3-l_2=3-2=1$ with $n=2^k-1$ but I think there is an error and the correct form of $\Delta_i$ is $\Delta_i=f(l_i)-f(l_{i-1})$ so $\Delta_1=-3, \Delta_2=-1, \Delta_3=2$
now? I don't undertstand what I have to do..

I do not know if I did right up to this point, someone could help me out?
I did not find examples that could help me understand the algorithm.

Thank you very much


texts: MFCC help: Same sound, different coefficients?

texts:
Problem: I'm getting totally different MFCC coefficients for identical and near identical sounds like several finger snaps or several desk taps. What am I missing? I thought since the timbre doesn't really change, the coefficients wouldn't be that much different.

I'm using the aubio library to extract the MFCCs from microphone input, with a 44.1KHz sample rate, 1028 buffer length, and 512 hop size. When an onset is detected in a 512 sample buffer called in, for example, I send in to the MFCC extraction function.

Here's the callback that is called when there's a buffer full of audio ready to be processed:

int record( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
         double streamTime, RtAudioStreamStatus status, void *userData )
{
   if (status)
      std::cout << "Stream overflow detected!" << std::endl;

   // Do something with the data in the "inputBuffer" buffer.
   smpl_t * input = (smpl_t *) inputBuffer;

   InputData * data = (InputData *) userData;

   //only hop_size length samples allowed in in->data; must loop to fill bit by bit.
   while (data->offset < 1024)
   {
      std::copy(input + data->offset, input + data->offset + 511, in->data);

      aubio_onset_do(o,in,out);

      //do something with the onsets

      if (out->data[0] != 0)
      {
         fprintf(stderr, "ONSET DETECTED! \n");

         //compute mag spectrum (pv- phase vocoder obj; in- takes hop_size input; fftgrain- spectrum output.
         aubio_pvoc_do (pv, in, fftgrain);

         //compute mfccs (mfcc-mfcc object, mfcc_out- 13 MFCC coefficients)
         aubio_mfcc_do(mfcc, fftgrain, mfcc_out);

         fvec_print(mfcc_out);

    }
    data->offset += 512;
    }

    data->offset = 0;
    if (streamTime > 4)
       return 1; //abort the stream at 4 seconds

    return 0; //continue normal stream operation
}


texts: Given a -3dB/ octave filter that makes Pink Noise, how can I make a +3dB/ octave filter that makes Blue/ Azure Noise?

texts:
I learnt from here that the following filter can turn white noise into pink (-3dB/ octave).
  b0 = 0.99765 * b0 + white * 0.0990460;
  b1 = 0.96300 * b1 + white * 0.2965164;
  b2 = 0.57000 * b2 + white * 1.0526913;
  pink = b0 + b1 + b2 + white * 0.1848;

How would I turn white noise into blue/ azure noise (+3dB/ octave)?  Is it possible to do some simple 'inversion' on this filter or can you please give me a tip as to how I can calculate the filter coefficients.
EDIT
I probably should have mentioned that I need a C++ implementation but Robert's 2nd answer has me close.
Right now I do this in the header:
float *state = nullptr;
The in the implementation file:
state = new float[0.0]; in the constructor then inside the actual loop I take my white noise and do this:
float first = first_order_filter(whiteNoise, 0.99572754, 0.98443604, state);
float second = first_order_filter(first, 0.94790649, 0.83392334, state);
float third = first_order_filter(second, 0.53567505, 0.07568359, state);
out1 = third;

I am expecting pink noise as I have not yet swapped the Poles and Zeros (if I had then I would expect blue/ azure noise) but currently I get what looks and sounds like white noise.


texts: How is noise added in an image during image acquisition or image transmission?

texts:
Recently I read about image noise. I read about noise characteristics, but I am unable to understand the following two points:

The sources of noise in digital images arise during image acquisition
(digitization) and transmission.

Imaging sensors can be affected by ambient conditions
Interference can be added to an image during transmission


texts: Python - Normalized cross-correlation to measure similarites in 2 images

texts:
I'm trying to measure per-pixel similarities in two images (same array shape and type) using Python.

In many scientific papers (like this one), normalized cross-correlation is used. Here's an image from the ict paper showing the wanted result:

(b) and (c) are the 2 input images, and (d) is the per-pixel confidence.

I only used OpenCV before to do template matching with normalized cross correlation using cv2.matchTemplate function, but in this case it seems to be a really different use of cross correlation.

Do you know if I can approch this result using Python and image processing libraries (numpy, openCV, sciPy etc...), and the logic behind this use of cross correlation ?

Thanks.


texts:
this is for an application in which passwords are stored in the form of audio inputs .
In order to provide user access , the password(in audio form) will be matched with already stored password(audio only) in the database . I wanted to know how to measure the extent of similarity in two audio patterns . the audio patterns can be a clap sequence , knock sequence , whistle etc


texts: Impulse Response for an Anti Causal Linear Shift Invariant System

texts:
I have a system given by
$$y[n] - \frac{1}{4} y[n-1] - \frac{1}{8} y[n-2] =3x[n] $$
I'm asked to determine the impulse response of both an anti-causal and a causal Linear Shift Invariant System characterized by this difference equation.
The impulse response to the causal system is $$2\left(\frac{1}{2}\right)^{n}u[n]+\left(-\frac{1}{4}\right)^{n}u[n]$$
I found this without using Z transform or Fourier Transform but by solving the difference equation using the initial condition $h[n]=0$ for $n<0$.
How can I find the anti-causal impulse response without using Z-transform or Fourier Transform.
What boundary conditions do I use now?


texts: Removing drift from integration of accelerometer data

texts:
I am trying to get a positional data from the accelerometer data using the following steps:

Re-zero the accelerometer value
Removing mean from accelerometer value
First integration of accelerometer value to get velocity
Removing mean from velocity
Integrate velocity to get position

, and the following is the result from every integration value:

Can anyone suggest on how to remove the drift appear on the velocity value? Some suggest to push the velocity value to zero when accelerometer value is near to zero but I don't think this is very robust.


texts: Proximal Gradient Method (PGM) for a Function Model with More than 2 Functions (Sum of Functions)

texts:
I am currently working in signal reconstruction. I am trying to develop an algorithm where the user can plug any constraint to the main objective function (let's say chi2, least squares). I was trying to understand the proximal gradient algorithm where you have a sum of functions $ F \left( x \right) = f \left( x \right) + g \left( x \right) $.
In the case of FISTA, it is the algorithm where $ g \left( x \right) $ is the $ {L}_{1} $ Norm of the data. However, what I am trying to do right now is to use $ g \left( x \right) $ as a sum of the $ {L}_{1} $ Norm and the Total Variation (TV) function of the data. In other words:

$$ g \left( x \right) = \lambda_1{\left\| x \right\|}_{1} + \lambda_2 \operatorname{TV}(x) $$

The question is, how can apply the Proximal function in this case?
Can I do it in iterative method where I apply the Proximal of the $ {L}_{1} $ Norm (Soft Threshodling) and then the Proximal of the Total Variation Norm?


texts:
I want to write sonar/radar like sample application. For sake of simplicity (and not to use Arduino and specialized RTOS) - I simply used using audio in/out analog ports of a motherboard integrated card as a sample hardware setup + Windows API with MSVS 2015. So, for my latency tests, I just used jack-jack cable from output(green) to line in (blue) minijacks. And, in my application, I have 2 important callbacks:

void on_playback_finished(short* buffer, int length) {
    for(int i=0;i<length;i++)
        buffer[i]=(i<(length/16))?(short)(sin(i)*32767):0
}

It's quite simple, it produces short "spike" (1/16th of the length of the buffer) of sine signal of some frequency, then makes a long pause of silence for the rest of the buffer(resting 15/16 of it).

And then second callback - which is called just when I recorded buffer from the line in. And this is my question. I must somehow detect this spike and measure latency:

void on_recorded_buffer(short* buffer, int length) {
    // there is our spike, somewhere in the buffer[] samples array
    // how to detect beginning of that spike,
    // considering induced noise, attenuation and possible echo?
}

what to do? need assistance)

UPD. I am not a good drawer, but this could help to understand my question:

Red lines represent software<->hardware transitions.
The sampling rate is 192kHz, Signal length is 256 samples (1.33333ms), pause between signals is at least 768 samples (4ms). I am asking about proper algorithm of doing sample offset calculation!


texts: I want to know that why large laplacian spatial filtering is done on EEG signals? I tried a lot but could not find material on LLSF. And what is meant by spatial filter ( in context of Digital Signal Processing)? Why is it called "Large" and "laplacian"?


texts:
I'm new to DSP, and just discovered this StackExchange, so apologies if this isn't the right place to post this question.

Is there a resource that describes genres in a more mathematical terms? For example, if I've performed an FFT on the signal on this section of the song (2:09 if the link doesn't start there), is there any way of me being able to detect that this section has that rough sort of sound? Do sounds like this follow some mathematical function with which I can compare?
http://www.youtube.com/watch?v=SFu2DfPDGeU&feature=player_detailpage#t=130s (link starts playing sound straight away)

Is the only way to use supervised learning techniques, or is there a different approach (which  preferably doesn't require supervision)?

Thank you for any advice.


texts: Can the Hanning Window be represented in the time domain

texts:
I know the Hanning window, $w_{Hann}(n) = 1 - \cos \left(2\pi \frac{n}{N} \right)$, is typically applied to discrete Fourier transforms. $N$ being the total number of points in a transient signal that is to be transformed with the DFT. However, I'm trying to have a look at how this window (which is what I use to measure) affects the spectral line shape of the resultant Fourier transform.

For now I simply say my transient signal is a damped oscillator of the form
$$f(t) = e^{-t/\tau} \cos(\omega_0 t).$$The Fourier transorm of which is well known to be a Lorentzian profile. However As I measure my data with a Hanning window I want to take the Fourier transform of
$$f(t) w_{Hann}(t)$$
This means I need the Hanning window in the time domain, which I assume to be simply
$$w_{Hann}(t) = 1 - \cos \left(2\pi \frac{t}{T} \right)$$ where $T$ is the averaging time for my Fourier transform.

Is this a good approach and a sounds assumption I can make with the Hanning window in a time domain rather than for a discrete index of points?


texts:
I look at the equations for DFS (Discrete Fourier Series) and DFT (Discrete Fourier transform) and the only difference I notice is that one has a squiggle above the letter and the other doesn't. The equations for x[n] and X[k] are exactly the same except for the presence or absence of a squiggle.

Example:

DFS:  $\tilde{x}[n]$ / $\tilde{X}[k]$

compared to:

DTF:  $x[n]$ / $X[k]$

What's the difference between "Discrete Fourier Series" and "Discrete Fourier Transform"?


texts: Why do we need to write the noise as randn(2,1)./sqrt(2*SNR) instead of randn(1,1)/sqrt(2)?

texts:
I saw this code, about the error probability of on/off signal ,on the internet

Ts=10^4;
SNR_dB=[-3 0 3 6 9];
Ne=zeros(1,length(SNR_dB));

for i=1:length(SNR_dB)
    SNR=10^(SNR_dB(i)/10);
    for t=1:Ts
        s=((sign(rand()-0.5))+1)/2; %create the "on"signal or "off" signal ."on"signal=1,"off" signal=0
        r=randn(2,1)./sqrt(2.*SNR); %it seems that it is noise
        if (s+r)>0.5
            s_hat=1;
        else
            s_hat=0;
        end
        if abs(s_hat-s)>0
            Ne(i)=Ne(i)+1;
        end
        y=Ne./Ts;
    end
end
Pe=zeros(1,5);
for i=1:5
    SNR=10^(SNR_dB(i)/10);
    Pe(i)=erfc(sqrt(SNR/2)/(2^0.5))/2;
end
semilogy(SNR_dB,y,'-r',SNR_dB,Pe,'-k')

I don't understand why can the noise be written as

  r=randn(2,1)./sqrt(2.*SNR)

,why do we need to write as randn(2,1)./sqrt(2*SNR) instead of randn(1,1)/sqrt(2)?Is anyone know about this?


texts: Very basic question about how we define frequency in signal processing

texts:
When talking about general periodic continuous-time signals for which $$x(t + T_0) = x(t)$$ where $T_0$ is the fundamental period we define the fundamental frequency $\omega_0$ as $\omega_0 = 2\pi/T_0$.

The way I interpret this is that $1/T_0$ is the frequency of the signal in cycles per second and there are $2\pi$ radians in one cycle, therefore the angular frequency is $2\pi/T_0$ radians per second. But are there really $2\pi$ radians in one cycle in general?

Take $x(t) = \tan(t)$ for example. Its fundamental period is $\pi$ and using the definition of fundamental frequency above, its fundamental frequency is 2 radians per second. But in the case of the tangent function, aren't there $\pi$ radians in one cycle, as opposed to $2\pi$ radians? This would give us a definition of frequency as $\omega_0 = \pi / T_0$. Or do we refer to the unit circle by convention when talking about "cycles"?

Apologies if this question sounds very basic.


texts:
I am currently making a relatively simple EQ of a music app, for which we decide to have 5 bands. Other than that, we want to have a bass boost knob, which, as I view it, is just another Peak EQ filter — so a 6 band EQ.

Are there any standards on what a 5(or 6) band EQ's frequencies should be?
What should the bass boost's frequency be?

Also, we are making only one Q knob to control the Q for all bands, simply because there isn't any space left for more knobs to be added, but we still want to provide this functionality.

Is this a good practice/design?
If not, is it at least acceptable or useful?