44

The only difference between cross-correlation and convolution is a time reversal on one of the inputs. Discrete convolution and cross-correlation are defined as follows (for real signals; I neglected the conjugates needed when the signals are complex): $$ x[n] * h[n] = \sum_{k=0}^{\infty}h[k] x[n-k] $$ $$ corr(x[n],h[n]) = \sum_{k=0}^{\infty}h[k] x[n+k] $$ ...


13

For continuous convolution $$[Hf](x) \equiv f(x) * h(x) \equiv \int\mathrm{d}x' h(x-x')f(x')$$ and continuous cross-correlation $$[Gf](x) \equiv f(x) \star h(x) \equiv \int \mathrm{d}x'h^*(x'-x)f(x')$$ It's easy to show that the cross-correlation operator $G$ is the adjoint operator of the the convolution operator $H$. Also, the convolution operation is ...


10

One-dimensional version The one-dimensional version that you list won't work. When there is a large enough shift in images (more than one or two pixels in real-world images), there will be nothing relating the column pixels. For an example of this, try: I5 = rand(100,100)*255; I6 = zeros(100,100); I6(11:100,22:100) = I5(1:90,1:79); So that we have I5: ...


9

As I've said in the comments, medical image registration is a topic with lots of research available, and I'm not an expert. From what I've read, the basic idea commonly used is to define a mapping between two images (in your case an image and its mirror image), then define energy terms for smoothness and for image similarity if the mapping is applied, and ...


8

Are you sure you shouldn't be using numpy.correlate instead of numpy.convolve? To estimate delay, you want to cross-correlate your signals, not convolve them. You'll possibly end up with a much larger delay by convolving. Trying something simple: x = [1, 0, 0, 0, 0 ]; y = [0, 0, 0, 0, 1 ]; conv = numpy.convolve(x,y); conv array([0, 0, 0, 0, 1, 0, 0, 0, ...


7

As a student I was involved in the same problem as you are. Let me explain to you in the simplest words without any math. Convolution: It is used to convolute two function. May sound redundant but I´ll put an example: You want to convolute (in a non math term to "combine") a unit cell (which can contain anything you want: protein, image, etc) and a ...


7

No. If the words are pronounced with a different speed or intonation (prosody), or by different speakers, the cross-correlation won't have any significance. A solution more robust to changes in prosody is to use audio features which are less dependent on pitch (such as MFCCs), and a comparison method that is robust to local time stretching (such as DTW or a ...


7

I can tell you of at least three applications related to audio. Auto-correlation can be used over a changing block (a collection of) many audio samples to find the pitch. Very useful for musical and speech related applications. Cross-correlation is used all the time in hearing research as a model for what the left and ear and the right ear use to figure ...


7

Let $\theta_a$ and $\theta_c$ respectively denote the maximum magnitudes of the off-peak or out-of-phase periodic autocorrelation functions and the periodic crosscorrelation functions of a set of $K$ sequences of length $N$ and energy $\sum_{n=0}^{N-1}|x[n]]|^2 = N$. In a seminal paper published in 1974, Welch proved that $$\max\big(\theta_a, \theta_c\big)\...


7

No. Quoting Wikipedia's article Independence (probability theory): If $X$ and $Y$ are independent random variables, then the expectation operator $\operatorname{E}$ has the property $$\operatorname{E}[X Y] = \operatorname{E}[X]\operatorname{E}[Y].$$ Consider your $X(t_1)$ and $Y(t_2)$ as $X$ and $Y$ in this answer. If both $\operatorname{E}[X] \ne ...


6

Use an onset detector - a classic method is described in Duxbury's paper "A combined phase and amplitude based approach to onset detection for audio segmentation". If you want a ready to use solution, you can use Sonic Visualizer / Sonic annotator, which can export onset positions as a text file. It works well for your example, with only one false positive -...


6

This is basically what @hooman suggests: fit a parabola to the three points near the peak of the sample cross-correlation of the data. Using the formula for $p$ here: $$ p = \frac{1}{2} \frac{\alpha - \gamma}{\alpha - 2\beta + \gamma} $$ where $\alpha,\beta,$ and $\gamma$ are the values of the sample cross-correlation just before the peak, at the peak, and ...


5

Inferring whether two signals are independent is very hard to do (given finite observations) without any prior knowledge/assumptions. Two random variable $X$ and $Y$ are independent if the value of $X$ doesn't give any information about the value of $Y$ (i.e. doesn't affect our prior probability distribution for $Y$). This is equivalent to any nonlinear ...


5

There is no such thing as the phase angle between two signals unless they both consist of a single sinusoid at the same frequency, that is, $x(t) = A\cos(\omega t+\psi)$ and $y(t) = B\cos(\omega t + \phi)$. If you have $N$ samples of these signals $x(t)$ and $y(t)$, taken at times $0$, $T$, $2T, \ldots$, $(N-1)T$, so that $$x[n] = x(nT), ~~ y[n] = y(nT), 0 \...


5

I guess you can compute for each pixel the correlation coefficient between patches centered on this pixel in the two images of interest. Here is an example where I downloaded the figure attached here and tried to compute the correlation in such a way. The output looks different from the one of the article, but it was to be expected since the resolution is ...


5

I suppose you mean the cross-correlation at lag zero. Well take an Hilbert space $H$ (i.e. a metric space in which you can define a scalar product $\langle\cdot ,\cdot\rangle$). Then $x,y\in H$ are orthogonal if $\langle x,y\rangle=0$, by definition. If your Hilbert Space is $L_2(\mathbb{R})$ (the space of real square integrable functions) then the scalar ...


5

What are reasons to choose for cross-correlation or cross-covariance when comparing signals with non-zero mean? Well, part of the issue is that cross-correlation as defined in your equation: $$(f \star g)[n]\ \stackrel{\mathrm{def}}{=} \sum_{m=-\infty}^{\infty} f^*[m]\ g[m+n].$$ will not exist (or be infinite) if $f$ and $g$ have non-zero mean. So, in ...


5

The general topic of finding similarities between signals is wide ranging: are the signals of same sampling, length, offset, shift or scale? where do they take their values (discrete, real, complex)? are they stationary? noisy? what do you consider similar (whole signals, chunks, specific features)? which are the invariances looked for? and most important:...


5

Lagrange parabolic estimator The standard Lagrange polynomial parabolic interpolation peak finding formula from Peter's answer, $$p = \frac{1}{2} \frac{\alpha - \gamma}{\alpha - 2\beta + \gamma}$$ has bias as function of the true delay $d$ if the cross-correlation peak is that of a critically sampled sinc. If the sampling frequency is increased, the ...


5

Cross correlation is a measure of similarity between two signals, where one signal is allowed to be time-shifted. In this sense, the correlation is not a single number, but a function of the time shift. We say, "these two signal have a certain correlation $R(\Delta)$ for a time shift $\Delta$". Intuitively, two signals that tend to have the same sign (both ...


5

As your plot shows, the second form allows for the correlation peak to be negative. Now, what does a strong negative cross correlation mean? It means the signals are very similar, except one has a negative sign in front of it, i.e., $x_1 \approx -x_2$. Whether or not this makes sense depends a lot on the actual application. In the application you describe, ...


5

Since this is an FIR, the group delay is D=(N-1)/2=20 samples. No, since this is a linear phase (i.e. symmetric or anti-symmetric) filter, the group delay is half the length! (being a FIR isn't sufficient.) The issue is that I get too peaks in the cross correlation, one at zero lag and another at 20 lag. Write down the formula for auto-correlation at ...


4

Interesting question. First, maybe you are after approaches based on interest keypoint detector and matching. This would include SIFT (Scale-Invariant Feature Transform), SURF, ORB, etc ... or even a simpler approach based solely on the Harris operator (csce.uark.edu/~jgauch/library/Features/Harris.1988.pdf). It is not clear from your post what you have ...


4

Sawtooth: Even and odd harmonics, falling off at 1/n Square: Odd harmonics only, falling off at 1/n Triangle: Odd harmonics only, falling off at 1/n2 So while triangle and square have the same set of frequencies present, the spectral envelope of sawtooth and square is more similar, with much stronger high frequency harmonics. Triangle waves are ...


4

Broadly speaking, image blurring replaces each pixel value by a weighted sum of adjacent pixel values. Now, this weighted sum can be represented as convolution or as a correlation for the simple reason that a convolution of $I$ and $g$ (where $I$ is the image and $g$ the kernel) is the same as the correlation of $I$ and $\hat{g}$ where $\hat{g}$ is just $g$ ...


4

I suspect your problem occurs due to some scaling issues. Basically you need to normalize your research image to the pattern template by subtracting the mean value of the template. And it is better calculate the ratio of correlation to the standard deviation of both images. I don't know which programming language you are using. I wrote a Matlab code for you ...


4

I'm afraid your statement isn't true. This can best be seen in a suitable choice of basis, one that simplifies the cross correlation. This basis if of course the shift invariant periodic Fourier basis on your support interval. Let's label the basis vectors $F_n$ for integer $n$. The cross correlation of two different such basis vectors vanishes, because the ...


4

This would be a cumbersome way to detect heart beats (or the QRS complex), if that is what you are trying to do ultimately. A little bit about what you are trying to do currently: Your observations are correct and to these I would like to add that no two heart beats are the same and therefore, strictly speaking, your template will be aligning just with ...


4

On closer inspection, I discovered that the erroneous correlation result resembles the correct result, but shifted up and to the left. The former was displayed in scientific format, so it was hard to see the pattern at first. The reason is that taking the conjugate is equivalent to flipping the whole zero-padded kernel, and not just the original kernel (...


4

When using a constant tone audio beacon, beware of room echoes causing multi-path interference and distortion, especially around the leading and trailing portions of your received waveforms. Try using a frequency sweep instead of a constant tone for your transmit waveform. This might provide you with a sharper correlation peak that is less likely to have ...


Only top voted, non community-wiki answers of a minimum length are eligible