# Tag Info

2

and how to avoid it? Address the NaN in your input data. Don't "fix", "paper over it" or "replace by 0". Find the root cause for the NaN, understand what's happening and take meaningful corrective action. NaN means your input data is bad. Doing anything with bad data is pointless since your output will be bad. Doing cosmetic adjustment just so the code ...

0

I'm unsure why this happens Well, you know the formula of for convolution. Every single time, no matter what you do, you add to NaN, you get NaN. Same for multiplication. So, 499 "left and right" of each NaN, you'll get NaN. how to avoid it? This might sound stupid, but: don't have NaNs in your input, simple as that! Whether you want to replace the ...

1

For the 1-d case, I think that conv() is implemented in the direct domain while xcorr is implemented in the frequency domain. This indicates that conv will be faster for small kernels, while xcorr will be faster when inputs are equal size. I dont know if this still is the case, and if it extends to the 2-d case. Operations that allows for native single-...

1

The problem with your code is that you need to get the indexing and time gating right. Matlab represents the frequencies in the FFT vector somewhat out of order , i.e. from $[0,N-1]$ instead of $[-N/2+1,N/2]. Once you rotate them so that DC is in the center and grab the correct frequencies after convolution, this does indeed work. %% Create two signals n = ... 3 Let's assume you have 2 signals: vX and vY. So: clear(); numSamplesX = length(vX); numSamplesY = length(vY); numSamplesConv = numSamplesX + numSamplesY - 1; vTimeDomainConv = conv(vX, vY); vFrequencyDomainConv = ifft(fft(vX, numSamplesConv) .* fft(vY, numSamplesConv), 'symmetric'); max(abs(vTimeDomainConv - vFrequencyDomainConv)) %<! Should be < ... 1 My answer is not from speech processing angle but from a generic signal processing involving Linear and Circular Convolution. Is zero-padding necessary for speech processing to satisfy linear convolution property? If the FFT size is$N$, and the length of result of linear convolution size is$\gt N$, then you need to do zero-padding. Otherwise it will ... 2 I would recommend three approaches: Try your own implementations first, especially if you haven’t written image processing code in a while. Google “Python image processing library.” There are a number of choices, and you know enough to pick what’s right for you. Opt for simplicity and usability first. Install OpenCV on a Pi. Don’t worry about performance; ... 2 Python has a lot of import libraries for image processing, and they are running on platforms that support Linux, such as Raspberry Pi. Pi runs with ARM based processors, and every limitation of that CPU (especially on SIMD floating point ops) is also a limitation for image processing. Pi also comes with a dedicated hardware GPU which can be used to ... 4 Apart from the formulae, let us go back to their actual meaning, and how they are derived. Talking about convolution: this operation is inherent to Linear-Time-Invariant (LTI) systems. In other words: if you want to analyse a system that is linear, and time-invariant, or you want to apply a processing or a filter that does not vary in time or space then ... 1 One of the most important classes of systems are Linear Time Invariant (or LTI) systems. These can fully described by either their transfer function or their impulse response (which are Fourier transforms of each other). If you apply an input signal to an LTI system and you want calculate the output signal, you can simply convolve the input with the ... 0 If you have convolution given by: $$\boldsymbol{y} = \boldsymbol{h} \ast \boldsymbol{x}$$ You can transform it into Matrix Form: $$\boldsymbol{y} = H \boldsymbol{x}$$ Then the operator$ {H}^{T} $means doing the correlation: $${H}^{T} \boldsymbol{x} = \boldsymbol{h} \star \boldsymbol{x}$$ In MATLAB Code, if you use the convolution as black box ... 1 For a convolution resulting in N+M-1 elements, with N>=M, best result might be to discard M-1 elements from both sides of the result. All the other convolutional result elements are "contaminated" by your assumptions about padding (zero, circular, random, etc.), and how closely that assumption corresponds to something useful or actual. 1 In this particular example best practice would be zero pad both signals to 2048 samples, FFT, multiply, and inverse FFT. This will result in 2048 time samples. The first 1999 are your convolution result and the last 49 are zero. Whether you want to discard the last 49 samples or just leave them as zeros, depends on what you want to do with them. If you ... 0 I modified the code to do Hamming window filtering (window input signal with time domain of window). Since I do not have your dat file, I assumed random values. X_t is the time domain signal corresponding to X. This needs to be windowed with hamming window. (convolution in frequency domain) time = 5; % in nano-seconds z0 = 50; %A ... 0 Yes, they are the same. Let us take the linear convolution of$x[t]$and$y[t]$as 2 portions$H_1$of length$N$corresponding to first$N$samples, and$H_2$of remaining$N-1$samples. Circular convolution between$x$and$y$causes$H_2$to overlap over$H_1$because of time-aliasing. So the first$N-1$samples of the result is$H_1 + H_2with only the ... 1 Circular convolution is basically linear convolution with aliasing. The circular convolution calculated at a sample number that does not involve wrap around values of the signal and are calculated within the one period of both signals might have the same value as the linear convolution. 1 Lot of good comments and a nice answer but still I felt OP's question may have gone unanswered. A is length 100 sequence, B is length 80 sequence. So conv(A,B) linear convolution operation results in a 179 length sequence. The important thing to keep in mind is that the resulting sequence is 179 length. Now, coming to DFT of these sequences (remember FFT ... 0 You get the time domain values of hamming window from the hamming function. Multiplying it with the frequency domain data will not give the correct result. Smoothing is usually performed by multiplying in time domain. You could try multiplying the fourier transform of hamming window with the Frequency domain signal. and then performing the inverse fft. 1 the following matlab/octave code gives the linear convolution result using frequency domain : A = ((-1).^[0:79]').*hamming(80); % input one B = blackman(100); % input two C1 = conv(A,B); % A * B (convolution) in time domain C2 = real( ifft( fft(A,179).*fft(B,179) ) ); % convolution using freq domain The output will be identical of length 179 ... 2 After playing with the notebook for a while, I figured out the following: The result from scipy is shifted by one pixel in each axis (probably due to its definition of the "same" mode). Or, alternatively, both the analytic result and pyfftw results are shifted the opposite way. After working around that, the result is exactly (within error) the same as the ... 0 Let's rearrange \begin{align} x(n,m) * \left[ f_1(n,m) + f_2(n,m) + f_3(n,m)\right] &= x(n,m) + kx(n,m) - x(n,m) * kg(n,m)\\ x(n,m) * \left[ f_1(n,m) + f_2(n,m) \right] &= x(n,m) + kx(n,m)\\ &=(1+k)x(n,m) \end{align} It directly follows from the linearity of convolution thatf_1+f_2=(1+k)\delta_{n,m}^{(N \times M)}$, where$\delta^{(N\times M)}\$ ...

Top 50 recent answers are included