# Does such filter exist?

Assume the following operation on input $$x$$ with filter $$w$$ of size $$2L+1$$:

$$y[i] = \frac{\sum_{k=-L}^{L} x[i+k] w[k]}{\sum_{k=-L}^{L} x[i+k]}$$

In other words, my desired filter does a convolution and divides by the sum. Does this operation has a name (or implemented in conventional software such as MATLAB or python's Scipy)?

In case you are wondering why I need that, this is my problem: I'm having a 1-D temporal signal in which some textures (say edges) are to be discovered. The noise has attenuated locally (in time) some of the textures by some scaling factor which is unknown to me. Now I want to discover the potential time locations where a certain texture happens by normalizing the output of usual filter to the sum of absolute values of my signal (I've dropped the abs() since my signal is positive always).

• That's a strange way of doing things. Any input that that's mean free is going to produce potentially very large output and it's going to look rather noisy. If you want to normalize to the input power, it's typically done by dividing by something derived from the sliding sum of the squares not the signal itself. What are you trying to do ? – Hilmar Jan 3 '20 at 16:10
• Edges and textures are somehow different. Is the noise positive as well (since you assume that $x$ including noise is positive)? What do you want the $w$ to like like? – Laurent Duval Jan 3 '20 at 17:15

It is not really a convolution, more a weighting. Your expression is $$0$$ homogeneous in $$x$$, as you divide $$x$$s values by $$x$$s. Specifically:

• it is not defined if $$\sum_{-K,K} x[i+k] = 0$$
• if $$x[k]$$ is locally a constant, the output does not depend on it (because it will be equal to $$\sum h[k]$$)
• if $$h[k]$$ is an averaging filter ($$h[k] = \frac{1}{2K+1}$$), the output will be $$\frac{1}{2K+1}$$

So globally I would not consider it as a classical filter for $$x$$. But it could be seen as an adaptive weighting for $$h$$, based on a unit-normalized window $$\chi$$ with $$\chi[n] = \frac{x[n]}{\sum_{|k|\le K} x[n]}$$. As such, it is easily implemented in Matlab or Python. So far, I don't have a use for it. What was your purpose?

• I'm aware of the points you mentioned. Specifically, for my signal, the first case never happens as it is always positive. I'm also OK with the second and third properties. I updated my question to address your question. – arash Jan 3 '20 at 17:01
• Thank you. It is important to know whether the noise is positive as well, and the shape of the $w$ filter – Laurent Duval Jan 3 '20 at 17:29

If the signal is positive (or at least non-negative, with no long runs of zeros that could make the sum in denominator zero), then what you have is a basic filter with kernel $$w[-n]$$, combined with a simple automatic gain control.

Note that the term in the denominator could be implemented recursively:

$$\bar{x}[i]=\sum_{k=-L}^{L}x[i+k]=\bar{x}[i-1]+x[i+L]-x[i-L-1]$$