Should mean be subtracted before convolution? Suppose I have a signal in the form of N real numbers. I am searching for a continuous pattern within this signal. The pattern is represented by M real numbers. (M < N)
To find the pattern's position within the signal I apply convolution operator c = conv(signal, pattern) and look for the highest value in c.
Should I subtract the mean from the signal and pattern before applying convolution? If so is there a formal justification?
EDIT: (since the above turned out to be trivial)
What if my signal doesn't necessarily contain the pattern and can vary in intensity (as in images) and I'm convolving with a small "patch" as a pattern? It's hard to set a threshold beyond which I decide the pattern is found.
 A: The meaning of "subtract the mean from the pattern" is ambiguous, because already mean is ambiguous in case the pattern is not periodic. What you are probably thinking of it taking a bounding box of the pattern and compute the mean over that bounding box. And you probably want to subtract this mean only inside of the bounding box, and let the pattern function stay zero outside of the bounding box.
The operation described above definitively can influence the position of the maximum, and might be a good idea. One of it's effects is that the integral over the "pattern kernel" will be zero, so that the low frequency content of the signal will get ignored. You might also thing about using a more general window function instead of the indicator function of the bounding box for achieving a similar effect (in case the pattern doesn't clearly indicate where it should end).
Regarding the question about the threshold, the maximum of the convolution of the "pattern kernel" with the (original) pattern gives a good indication how to set the threshold.
