# Check whether a given equation is linear

$$a = (x, y) \in \mathbb{Z}^2$$ is given as a pixel. My equation in which $$g$$ is image(matrix) is defined as,

$$f(x, y) = 56g(x,y)+93g(x−1,y)+92g(x+1, y)−57g(x, y−1)+555g(x, y+1)$$

How can we know whether $$f(x,y)$$ is linear, proving? By saying linear, it is like a filter which is linear. $$g(x,y)$$ means a pixel at $$x$$ and $$y$$. I'm really newbie for image processing and the question will help me a lot what's going on underneath.

• Linearity is more fundamental that filters. It means that: suppose that you have two images (of the same size, but ok you are in $\mathbb{Z}$). Does processing on each image $g_1$ and $g_2$ independently and adding then with different weights $af_1+bf_2$ give the same result as directly acting on the image sum $ag_1 + bg_2$? – Laurent Duval Nov 1 '18 at 13:05

## 2 Answers

To write what Laurent says in the comments a bit more fully, what you want to show is that if

$$f_1(x, y) = 56g_1(x,y)+93g_1(x−1,y)+92g_1(x+1, y)−57g_1(x, y−1)+555g_1(x, y+1)$$

and

$$f_2(x, y) = 56g_2(x,y)+93g_2(x−1,y)+92g_2(x+1, y)−57g_2(x, y−1)+555g_2(x, y+1)$$

and

$$f_3(x, y) = 56(g_3(x,y)+93g_3(x−1,y)+92g_3(x+1, y)−57g_3(x, y−1)+555g_3(x, y+1)$$ where $$g_3 = g_1 + g_2$$, then $$f_3 = f_1 + f_2$$

Does that help?

• Too fast for me:) – Laurent Duval Nov 1 '18 at 13:49
• @LaurentDuval I can cut-and-paste with the best of them. :-) – Peter K. Nov 1 '18 at 16:14

In a math manner: just consider two functions $$g_1$$ and $$g_2$$. Their individual linearly filtered outputs are:

$$f_1(x, y) = 56g_1(x,y)+93g_1(x−1,y)+92g_1(x+1, y)−57g_1(x, y−1)+555g_1(x, y+1)$$ and $$f_2(x, y) = 56g_2(x,y)+93g_2(x−1,y)+92g_2(x+1, y)−57g_2(x, y−1)+555g_2(x, y+1)$$

Their separate linear combination is $$af_1(x, y)+bf_2(x, y)$$. Now suppose the combinaison happens first: $$g_{12}(x, y) = ag_1(x, y)+bg_2(x, y)$$. Replace it in the following equation:

$$f_{12}(x, y) = 56g_{12}(x,y)+93g_{12}(x−1,y)+92g_{12}(x+1, y)−57g_{12}(x, y−1)+555g_{12}(x, y+1)$$ and verify whether $$af_1(x, y)+bf_2(x, y)-f_{12}(x, y)$$ is zero. And you are done. Here, it seems to work well.

In filtering terms, this amounts to using this 2D filter:

$$\begin{bmatrix}0 &555& 0 \\ 92& 56 &93\\ 0 &-57& 0 \end{bmatrix}$$

which is improbable for real matrix filtering problems, by the way, because I do not see enough symmetry, or meaningful arithmetic properties in it.